Skip to content

Commit 2c0a356

Browse files
linesightclaude
andcommitted
macos: embed Info.plist in subprocess binary via -sectcreate
Replace the broken SubprocessMacInit() runtime injection approach with a reliable compile-time solution: embed Info.plist in the subprocess Mach-O binary using the -sectcreate __TEXT __info_plist linker flag. CoreFoundation reads the __TEXT,__info_plist section automatically, so CFBundleGetMainBundle() returns CFBundleIdentifier = "org.cefpython" without any runtime code. This matches the service name the browser process registers with MachPortRendezvousServer, fixing bootstrap_look_up. The previous approach (CFDictionarySetValue on the info dict) was broken because CFBundleGetInfoDictionary() returns an immutable CFDictionaryRef for flat binaries; the set operation silently did nothing. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 3dc5afe commit 2c0a356

4 files changed

Lines changed: 17 additions & 48 deletions

File tree

src/subprocess/CMakeLists.txt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,10 +151,14 @@ elseif(APPLE)
151151
"-F${CEFPYTHON_CEF_ROOT}/bin"
152152
"-framework" "Chromium Embedded Framework"
153153
"-Wl,-rpath,@loader_path/"
154+
# Embed Info.plist so CFBundleGetMainBundle() returns CFBundleIdentifier
155+
# = "org.cefpython", matching the service name the browser process
156+
# registers with MachPortRendezvousServer.
157+
"-sectcreate" "__TEXT" "__info_plist"
158+
"${CMAKE_CURRENT_SOURCE_DIR}/Info.plist"
154159
)
155160
target_link_libraries(cefpython_subprocess PRIVATE
156161
"${CEFPYTHON_CEF_ROOT}/lib/libcef_dll_wrapper.a"
157-
"-framework CoreFoundation"
158162
)
159163
else()
160164
target_compile_options(cefpython_subprocess PRIVATE -DNDEBUG -O3)

src/subprocess/Info.plist

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>CFBundleIdentifier</key>
6+
<string>org.cefpython</string>
7+
<key>CFBundleName</key>
8+
<string>cefpython-subprocess</string>
9+
<key>CFBundleExecutable</key>
10+
<string>subprocess</string>
11+
</dict>
12+
</plist>

src/subprocess/main.cpp

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -28,23 +28,8 @@ int APIENTRY wWinMain(HINSTANCE hInstance,
2828

2929
#include <string.h>
3030

31-
#if defined(OS_MAC)
32-
// CEF 130+: MachPortRendezvousClientMac builds the service name as
33-
// CFBundleIdentifier + ".MachPortRendezvousServer." + parent_pid
34-
// The browser process injects CFBundleIdentifier = "org.cefpython" in
35-
// MacInitialize() before CefInitialize(). This subprocess binary is a flat
36-
// binary (not an app bundle), so CFBundleGetMainBundle() returns no
37-
// CFBundleIdentifier, producing a lookup name starting with "." that never
38-
// matches the registered service. Call SubprocessMacInit() to inject the
39-
// same identifier so bootstrap_look_up finds the server.
40-
extern "C" void SubprocessMacInit();
41-
#endif
42-
4331
int main(int argc, char **argv)
4432
{
45-
#if defined(OS_MAC)
46-
SubprocessMacInit();
47-
#endif
4833
#if defined(OS_LINUX)
4934
// Chrome 130+ passes --pseudonymization-salt-handle to directly-launched
5035
// (non-zygote) subprocesses, expecting GlobalDescriptors[key] to be

src/subprocess/main_mac.mm

Lines changed: 0 additions & 32 deletions
This file was deleted.

0 commit comments

Comments
 (0)