Skip to content

Set CEF main bundle path on MacOS so the engine works inside player builds - #441

Open
Z-Oleksandr wants to merge 1 commit into
Voltstro-Studios:masterfrom
Z-Oleksandr:fix/macos-main-bundle-path
Open

Z-Oleksandr wants to merge 1 commit into
Voltstro-Studios:masterfrom
Z-Oleksandr:fix/macos-main-bundle-path

Conversation

@Z-Oleksandr

@Z-Oleksandr Z-Oleksandr commented Oct 10, 2026 •

Copy link
Copy Markdown

The problem

On MacOS the CEF engine works in the Editor but crashes in player builds. The case discussed in #374. Every helper process dies on startup and the engine gives up:

ERROR:content/browser/gpu/gpu_process_host.cc:1005] GPU process exited unexpectedly: exit_code=5
WARNING:content/browser/gpu/gpu_process_host.cc:1447] The GPU process has crashed 1 time(s)
ERROR:content/browser/network_service_instance_impl.cc:613] Network service crashed or was terminated, restarting service.
...
FATAL:content/browser/gpu/gpu_data_manager_impl_private.cc:415] GPU process isn't usable. Goodbye.

Unity then reports It appears that the engine process has quit!, followed by EndOfStreamException on every input event. The macOS crash reports show the helpers stopping on an internal assertion (EXC_BREAKPOINT / SIGTRAP inside cef_execute_process).

The cause

CefSettings.MainBundlePath is never set. CEF documents that an empty value defaults to the top-level app bundle. In the Editor, UnityWebBrowser.Engine.Cef.app is the top-level bundle. In a build it is embedded in <Game>.app/Contents/Frameworks/, so CEF treats the Unity player as its main bundle, and every helper fails at startup.

I reproduced this without Unity by running the engine executable directly, with the same arguments UWB passes:

Engine (stock 2.2.8, arm64) Result
Standalone, anywhere on disk OK
Nested inside any outer .app (a dummy Outer.app/Contents/Frameworks/) GPU process crashes ×8–9, engine quits
Nested, plus --main-bundle-path=<engine .app> on the command line OK, 0 crashes

This is also why moving the engine outside the player's .app works around the problem, as described in this comment. The hardened runtime isn't required to trigger it: my player build was ad-hoc signed without the hardened runtime and still crashed. Code signing isn't the cause either. Re-signing the engine and the app ad hoc (inside-out) makes codesign --verify pass, but the crash stays.

The change

On MacOS, set MainBundlePath to the engine's own .app. It is resolved as ../.. from the working directory, the same base the existing frameworksPath uses (Contents/MacOS -> .app):

Windows and Linux are untouched. The engine can now stay in Contents/Frameworks/, where the existing post-processor puts it, so no changes are needed on the Unity side.

Testing

Apple M1 Max, macOS 26.6.2, Unity 6000.3.25f1. Engines built with build_cef_macosarm64.py / build_cef_macosx64.py (CEF 143.0.13).

Test Result after the fix
arm64 engine, standalone OK
arm64 engine, nested in an outer .app OK, 0 crashes
x64 engine, nested in an outer .app (under Rosetta) OK, 0 crashes
Unity Editor OK
Unity macOS player build (Apple Silicon, no re-signing) page renders, 0 helper crashes, clean shutdown

Notes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant