diff --git a/ci/app_identity_check.py b/ci/app_identity_check.py index 8009c6763e..a2bbdbb07a 100644 --- a/ci/app_identity_check.py +++ b/ci/app_identity_check.py @@ -110,6 +110,30 @@ def check_bundle(root: Path) -> None: raise RuntimeError("packaged SUPublicEDKey is not obs-rust's Sparkle key") if not (root / "Contents/Frameworks/Sparkle.framework").is_dir(): raise RuntimeError("packaged app has an update feed but no Sparkle.framework") + check_browser_helpers(root, metadata["CFBundleExecutable"]) + + +# Chromium finds the browser source's helper apps by the main executable's +# name, and their bundle IDs follow the app's (#2386). +BROWSER_HELPER_FLAVORS = (("", ""), (" (GPU)", ".gpu"), (" (Plugin)", ".plugin"), (" (Renderer)", ".renderer")) + + +def check_browser_helpers(root: Path, executable: str) -> None: + frameworks = root / "Contents/Frameworks" + helpers = sorted(path.name for path in frameworks.glob("* Helper*.app")) + if not helpers: + return # built without the browser source + expected = {f"{executable} Helper{suffix}.app": f"{APP_ID}.helper{plist}" for suffix, plist in BROWSER_HELPER_FLAVORS} + if sorted(expected) != helpers: + raise RuntimeError(f"browser helpers are {helpers}, expected {sorted(expected)}: Chromium cannot launch them") + for name, bundle_id in expected.items(): + with (frameworks / name / "Contents/Info.plist").open("rb") as stream: + helper = plistlib.load(stream) + if helper.get("CFBundleExecutable") != name.removesuffix(".app") or helper.get("CFBundleIdentifier") != bundle_id: + raise RuntimeError( + f"browser helper {name} has executable {helper.get('CFBundleExecutable')!r} and bundle ID " + f"{helper.get('CFBundleIdentifier')!r}, expected {name.removesuffix('.app')!r} and {bundle_id!r}" + ) def main() -> None: diff --git a/ci/test_macos_browser_helpers.py b/ci/test_macos_browser_helpers.py new file mode 100644 index 0000000000..91f610fe12 --- /dev/null +++ b/ci/test_macos_browser_helpers.py @@ -0,0 +1,120 @@ +#!/usr/bin/env -S uv run --script +"""The browser source's helper apps follow the app identity on macOS (#2386). + + uv run --no-project ci/test_macos_browser_helpers.py + +Chromium finds its helpers by the main executable's name: " Helper", +" Helper (GPU)", "(Plugin)" and "(Renderer)" in Contents/Frameworks. +obs-browser named them "OBS Helper" while the Rust brand's app is +"OBS-Studio-Rust", so the GPU process failed to launch (error_code=1003) and +adding a browser source crashed OBS. The helpers' bundle IDs follow the app's +bundle ID the same way (".helper", ".helper.gpu", ...). +""" + +from __future__ import annotations + +import importlib.util +import plistlib +import re +import tempfile +import unittest +from pathlib import Path + +ROOT = Path(__file__).resolve().parent.parent +BROWSER_CMAKE = ROOT / "plugins/obs-browser/cmake/os-macos.cmake" +# Jobs that check out no submodules (the Format job) skip the source checks; +# the bundle checks below still run, and the release workflow runs +# app_identity_check.py on every built macOS app. +NEEDS_BROWSER = unittest.skipUnless(BROWSER_CMAKE.is_file(), "plugins/obs-browser is not checked out") +FLAVORS = (("", ""), (" (GPU)", ".gpu"), (" (Plugin)", ".plugin"), (" (Renderer)", ".renderer")) + + +def identities() -> dict[str, dict[str, str]]: + """OBS_MACOS_BUNDLE_NAME and _ID per brand, from cmake/common/app-identity.cmake.""" + text = (ROOT / "cmake/common/app-identity.cmake").read_text() + head, rust = text.split("if(OBS_BRAND_RUST)", 1) + rust = rust.split("endif()", 1)[0] + + def values(block: str) -> dict[str, str]: + return dict(re.findall(r"set\((OBS_MACOS_BUNDLE_(?:NAME|ID))\s+(\S+)\)", block)) + + upstream = values(head) + return {"upstream": upstream, "rust": {**upstream, **values(rust)}} + + +def browser_helpers(identity: dict[str, str]) -> list[tuple[str, str]]: + """(name, bundle id) of each helper that obs-browser's macOS CMake builds.""" + text = BROWSER_CMAKE.read_text() + name = re.search(r'set\(helper_output_name\s+"([^"]+)"\)', text).group(1) + bundle = re.search(r"XCODE_ATTRIBUTE_PRODUCT_BUNDLE_IDENTIFIER\s+(\S+)", text).group(1) + for var, value in identity.items(): + name = name.replace(f"${{{var}}}", value) + bundle = bundle.replace(f"${{{var}}}", value) + return [(name + suffix, bundle.replace("${helper_plist}", plist)) for suffix, plist in FLAVORS] + + +def load_identity_check(): + spec = importlib.util.spec_from_file_location("app_identity_check", ROOT / "ci/app_identity_check.py") + module = importlib.util.module_from_spec(spec) + spec.loader.exec_module(module) + return module + + +def write_bundle(root: Path, helper_name: str, helper_id: str) -> Path: + """A minimal OBS-Studio-Rust.app that check_bundle() accepts, with browser helpers.""" + check = load_identity_check() + app = root / "OBS-Studio-Rust.app" + (app / "Contents/MacOS").mkdir(parents=True) + (app / "Contents/MacOS/OBS-Studio-Rust").write_bytes(b"") + (app / "Contents/Frameworks/Sparkle.framework").mkdir(parents=True) + with (app / "Contents/Info.plist").open("wb") as stream: + plistlib.dump( + { + "CFBundleIdentifier": check.APP_ID, + "CFBundleExecutable": "OBS-Studio-Rust", + "CFBundleDisplayName": "OBS-Studio-Rust", + "SUFeedURL": f"{check.UPDATE_FEED_PREFIX}updates_arm64_v2.xml", + "SUPublicEDKey": check.SPARKLE_PUBLIC_KEY, + }, + stream, + ) + for suffix, plist in FLAVORS: + helper = app / f"Contents/Frameworks/{helper_name}{suffix}.app/Contents" + (helper / "MacOS").mkdir(parents=True) + (helper / f"MacOS/{helper_name}{suffix}").write_bytes(b"") + with (helper / "Info.plist").open("wb") as stream: + plistlib.dump({"CFBundleExecutable": f"{helper_name}{suffix}", "CFBundleIdentifier": helper_id + plist}, stream) + return app + + +class MacosBrowserHelpersTest(unittest.TestCase): + @NEEDS_BROWSER + def test_helpers_follow_the_app_identity(self): + for brand, identity in identities().items(): + with self.subTest(brand=brand): + expected = [ + (f"{identity['OBS_MACOS_BUNDLE_NAME']} Helper{suffix}", f"{identity['OBS_MACOS_BUNDLE_ID']}.helper{plist}") + for suffix, plist in FLAVORS + ] + self.assertEqual(browser_helpers(identity), expected) + + @NEEDS_BROWSER + def test_upstream_names_are_unchanged(self): + self.assertEqual(browser_helpers(identities()["upstream"])[0], ("OBS Helper", "com.obsproject.obs-studio.helper")) + + def test_bundle_check_rejects_upstream_helper_names(self): + check = load_identity_check() + with tempfile.TemporaryDirectory() as tmp: + app = write_bundle(Path(tmp), "OBS Helper", "com.obsproject.obs-studio.helper") + with self.assertRaisesRegex(RuntimeError, "Helper"): + check.check_bundle(app) + + def test_bundle_check_accepts_branded_helpers(self): + check = load_identity_check() + with tempfile.TemporaryDirectory() as tmp: + app = write_bundle(Path(tmp), "OBS-Studio-Rust Helper", f"{check.APP_ID}.helper") + check.check_bundle(app) + + +if __name__ == "__main__": + unittest.main() diff --git a/docs/features.md b/docs/features.md index 5e4e92c6bd..dfbad2ebb7 100644 --- a/docs/features.md +++ b/docs/features.md @@ -405,18 +405,22 @@ not get a line. version it is based on, in the window title, log, About dialog, `--version` and package metadata. On first run it copies the upstream OBS settings without changing them. Plugins still see a valid OBS version. - *All*, 2026-10-10. Issues + On macOS the browser source's helper apps take the app's name too, so + adding a browser source no longer crashes OBS. *All*, 2026-10-10. Issues [#111](https://github.com/obs-rust/obs-studio/issues/111), [#631](https://github.com/obs-rust/obs-studio/issues/631), [#632](https://github.com/obs-rust/obs-studio/issues/632), - [#1087](https://github.com/obs-rust/obs-studio/issues/1087), PRs + [#1087](https://github.com/obs-rust/obs-studio/issues/1087), + [#2386](https://github.com/obs-rust/obs-studio/issues/2386), PRs [#67](https://github.com/obs-rust/obs-studio/pull/67), [#112](https://github.com/obs-rust/obs-studio/pull/112), [#510](https://github.com/obs-rust/obs-studio/pull/510), [#515](https://github.com/obs-rust/obs-studio/pull/515), [#657](https://github.com/obs-rust/obs-studio/pull/657), [#706](https://github.com/obs-rust/obs-studio/pull/706), - [#1088](https://github.com/obs-rust/obs-studio/pull/1088). + [#1088](https://github.com/obs-rust/obs-studio/pull/1088), + [#2390](https://github.com/obs-rust/obs-studio/pull/2390), + [obs-rust/obs-browser#9](https://github.com/obs-rust/obs-browser/pull/9). - **Daily beta packages.** A beta is published every day as the latest release: an AppImage for Linux, zips for Windows x64 (with the Visual C++ runtime) and ARM64, and DMGs for Apple silicon and Intel Macs. *All*, @@ -1551,6 +1555,13 @@ area. own goes away. *Linux*, 2026-10-25. Issue [#2261](https://github.com/obs-rust/obs-studio/issues/2261), upstream [obsproject/obs-studio#5502](https://github.com/obsproject/obs-studio/issues/5502). +- On macOS, a first browser source created by obs-websocket (`CreateInput`) + renders. Before, CEF started on obs-websocket's thread, and no browser + source rendered for the rest of the session, also ones added in the UI + later. *macOS*, pending merge. Issue + [#2387](https://github.com/obs-rust/obs-studio/issues/2387), PRs + [#2390](https://github.com/obs-rust/obs-studio/pull/2390), + [obs-rust/obs-browser#10](https://github.com/obs-rust/obs-browser/pull/10). ### Scenes and UI diff --git a/plugins/obs-browser b/plugins/obs-browser index 4583599fe8..9aa4a60440 160000 --- a/plugins/obs-browser +++ b/plugins/obs-browser @@ -1 +1 @@ -Subproject commit 4583599fe86df1bcb28aca1fd96ea92c269373cf +Subproject commit 9aa4a60440a245e5d1aed3219365a894b19a0008