Skip to content

frontend-tools: Host code behind frontend-tools-host.h (#855) - #1292

Merged
zackees merged 3 commits into
masterfrom
facade/855-frontend-tools-host
Oct 17, 2026
Merged

zackees merged 3 commits into
masterfrom
facade/855-frontend-tools-host

Conversation

@zackees

@zackees zackees commented Oct 17, 2026

Copy link
Copy Markdown
Member

Fixes #855. Same structure as #1248 / #1252 / #1257 / #1263.

Moved

  • frontend-tools.c.h: InitCaptions/FreeCaptions under _WIN32 become frontend_tools_host_load() / frontend_tools_host_unload(). Windows calls the captions functions; the other hosts do nothing.
  • auto-scene-switcher.cpp.hpp: the Wayland skip becomes frontend_tools_host_scene_switcher_supported(), defined next to each host's window lookup in the existing auto-scene-switcher-{nix,win,osx}. Only nix checks platformName() for wayland; Windows and macOS return true.
  • scripts.cpp.hpp:
    • The _WIN32 || __APPLE__ part of PYTHON_UI becomes frontend_tools_host_python_ui() (true on Windows and macOS). The non-host Python_FOUND check stays as it was. Note: nothing in this tree defines Python_FOUND for frontend-tools, so the tab stays off everywhere, as before.
    • The macOS /Python.framework/Versions trim becomes frontend_tools_host_python_path_len(). macOS cuts the path there; the other hosts keep the full length.
  • Captions (Windows only): <windows.h> and the _MSC_VER pragmas around <sphelper.h> move into the new Windows-named captions-host-windows.hpp. captions-mssapi.hpp and captions-mssapi-stream.hpp include it. The captions PCH is renamed build/frontend-tools-captions-windows.pch.hpp. No upstream file is renamed.
  • New files:
    • frontend-tools-host.h (no host conditionals)
    • frontend-tools-host-{windows,macos,posix}.c.h
    • unity groups build/frontend-tools.host-{windows,macos,posix}+.h.c and their PCHs; CMake picks one per platform.

Baseline delta (ci/platform-ifdef-baseline.json, regenerated with --update after rebasing)

All six frontend-tools entries go to 0, removing 12 findings:

File Findings removed
auto-scene-switcher.cpp.hpp 1
build/frontend-tools-captions.pch.hpp 3
captions-mssapi-stream.hpp 1
captions-mssapi.hpp 2
frontend-tools.c.h 3
scripts.cpp.hpp 2

Behaviour fix, in its own commit

"frontend-tools: Keep the trimmed Python path alive (macOS)" fixes a use-after-free from upstream. python_path pointed at a std::string that was destroyed at the end of its block, and was then passed to obs_scripting_load_python. The trimmed string now lives as long as python_path. Every other change in this PR is meant to keep behaviour exactly as it was.

Tests

New self-contained cmocka tests: test/cmocka/test_frontend_tools_host.c (posix host) and test_frontend_tools_host_macos.c (the macOS host is plain C, so its trim is tested on Linux). They link only cmocka and leave existing test targets unchanged.

  • RED (cfcf22128, stub hosts): rust/tools/linux-validate/run.sh --repeat 1 --tests test_frontend_tools_host gave 282/284 passing. Only the two new tests failed: posix test_python_path_kept; macOS test_python_ui, test_python_path_trimmed and test_python_path_kept.
  • GREEN: 284/284 passed, and the repeat run of both new tests passed.
  • ./lint was clean on each commit.

Windows/macOS coverage

ci/ci_scope.py puts plugins/frontend-tools/ in QT_AREAS, so this PR selects no Windows lane. It selects macOS only through the cross/scope flag; no macOS app build runs. I added frontend-tools-host-cross to cmake/cross/CMakeLists.txt, which compiles the Windows and macOS host groups. I ran it locally with cmake/cross/docker.sh:

  • win-x64: frontend-tools.host-windows+.h.c compiled. The run then stopped on errors in win-dshow, unrelated to this PR (dshowcapture headers missing in this worktree).
  • mac-arm64: all 73/73 targets compiled, including frontend-tools.host-macos+.h.c.

No CI job runs cmake/cross/ (the cross lane is Rust only), so that check is local evidence only.

Files no CI job compiles (they need Qt, the Windows SDK or AppKit):

  • plugins/frontend-tools/frontend-tools-host-windows.c.h (local cross check only)
  • plugins/frontend-tools/frontend-tools-host-macos.c.h (local cross check, plus the Linux cmocka test)
  • plugins/frontend-tools/captions-host-windows.hpp, captions-mssapi.hpp, captions-mssapi-stream.hpp, captions.cpp.hpp, build/frontend-tools-captions-windows.pch.hpp, build/frontend-tools.captions-windows+.hpp.cpp
  • plugins/frontend-tools/auto-scene-switcher-win.cpp.hpp, auto-scene-switcher-osx.mm.hpp, build/frontend-tools-{windows,macos}.pch.hpp
  • The Windows and macOS builds of scripts.cpp.hpp and auto-scene-switcher.cpp.hpp. The Linux Qt lane compiles their shared code.

frontend-tools-host.h with stub POSIX/macOS/Windows hosts; the new
test_frontend_tools_host{,_macos} cmocka tests fail against the stubs.
The captions load/unload, the scene switcher's Wayland check, the Python
settings tab and the macOS Python.framework path trim move behind a
conditional-free host interface: frontend-tools-host-{windows,macos,posix}
in per-OS unity groups, the switcher check next to each host's window
lookup. The captions' Windows SDK includes and MSVC pragmas move into the
Windows-named captions-host-windows.hpp and the captions PCH takes the
Windows name. The cross check compiles the Windows and macOS host groups.
Baseline: the six plugins/frontend-tools entries (12 findings) go to 0.
InitScripts pointed python_path at a std::string that was destroyed at
the end of its block, then passed it to obs_scripting_load_python: a
use-after-free whenever a saved path under Python.framework/Versions was
trimmed. The trimmed string now lives as long as python_path.
@zackees

zackees commented Oct 17, 2026

Copy link
Copy Markdown
Member Author

CI coverage gap for this PR's Windows/macOS files filed as #1294 (under #897). Until then, only master's push and release builds compile them.

@zackees
zackees added this pull request to the merge queue Oct 17, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Oct 17, 2026
@zackees
zackees added this pull request to the merge queue Oct 17, 2026
Merged via the queue into master with commit 9800275 Oct 17, 2026
29 checks passed
@zackees
zackees deleted the facade/855-frontend-tools-host branch October 26, 2026 15:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

facade: plugins/frontend-tools: move 10 platform conditionals behind a per-platform layer

1 participant