Fix macOS native CEF bundle layout in PrepareJustCefNative - #4
Open
jensrot wants to merge 2 commits into
Open
Conversation
PrepareJustCefNative copied the downloaded CEF archive's contents into a plainly-named cef/ output folder on every platform. On macOS the archive is actually a full app bundle (Contents/MacOS/, Contents/Frameworks/, etc.), and both JustCefProcess.GenerateSearchPaths() and CEF's own bundle-relative resource resolution (e.g. icudtl.dat) require that directory to literally be named *.app - a plain cef/ folder with identical contents isn't enough. Copy into justcefnative.app/ on macOS RIDs instead, matching what GenerateSearchPaths() already expects. Linux/Windows still use cef/, unchanged.
jensrot
force-pushed
the
fix/macos-native-cef-bundle
branch
from
August 24, 2026 17:55
4ef1f75 to
7c28a7c
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
On macOS, a completely clean checkout can never run:
dotnet build/dotnet runon a consuming app (e.g.Grayjay.Desktop.CEF) fails at startup with:The
PrepareJustCefNativeMSBuild target inJustCef.csprojdownloads the platform-specific CEF archive and copies its contents into<output>/cef/..., preserving the archive's internal structure. That's correct for Linux/Windows, where the archive is a flat binary andcef/<binary>is exactly whereJustCefProcess.GenerateSearchPaths()looks.On macOS, though, the archive is a full
.appbundle (Contents/MacOS/,Contents/Frameworks/,Contents/Resources/). Copying that into a folder namedcef/producescef/Contents/MacOS/justcefnative— butGenerateSearchPaths()only ever checks forjustcefnative.app/Contents/MacOS/...orJustCef.app/Contents/MacOS/.... It never checkscef/. So the binary is never found.It's not just a search-path bug
I first tried the "obvious" fix — teaching
GenerateSearchPaths()to also checkcef/Contents/MacOS/{binary}. That does letJustCefProcessfind and launch the binary, but CEF/Chromium then immediately fails on its own:...and the child process silently exits. CEF resolves bundle-relative resources (
icudtl.datunderContents/Frameworks/*.framework/Resources, and presumably others) against the real containing directory, which has to actually be named*.appfor its own internal bundle-resolution logic to work — a plaincef/directory with the identical internal layout isn't enough, even once the executable itself is locatable.Fix
Change
PrepareJustCefNative's output folder name based on RID:justcefnative.app/on macOS (osx-*), unchangedcef/everywhere else. This means the bundle root is named correctly for both problems at once —GenerateSearchPaths()'s existing (unmodified)justcefnative.app/Contents/MacOS/...check now matches, and CEF's own resource resolution works because the directory really is*.app. No C# changes needed at all.How to reproduce (before this fix)
On a clean macOS checkout of
Grayjay.Desktop(which consumes this repo as a submodule):Result:
System.Exception: Failed to find justcefnative, every time, on a first build. Inspecting the output directory shows the bundle sitting atbin/Debug/net8.0/osx-arm64/cef/Contents/MacOS/justcefnative— never a pathGenerateSearchPaths()actually checks.How I verified the fix
JustCefcommit pinned byGrayjay.Desktop's submodule.bin/objoutput for a fully clean rebuild — no manual workarounds, no pre-existingjustcefnative.appfolder.dotnet build+dotnet runinGrayjay.Desktop.CEF: output now correctly lands atbin/Debug/net8.0/osx-arm64/justcefnative.app/Contents/MacOS/justcefnative.icudtl.daterror, no missing-binary error.JustCefRid.StartsWith('osx-')is false for every other RID, soJustCefOutputSubdirstill resolves tocefexactly as before.Scope
Single file,
JustCef.csproj, +13/-1 lines. No C# changes. No behavior change for non-macOS RIDs.