Skip to content

Commit b33250e

Browse files
linesightclaude
andcommitted
macos: fix GPU crash, drop redundant switches, codesign wheel binaries
- screenshot.py: add macOS switches matching osr_test.py; remove dead switches (enable-begin-frame-scheduling, disable-surfaces not present anywhere in CEF 146 source) from the macOS path - osr_test.py: drop --no-sandbox (cefpython.pyx already sets no_sandbox=1 at the C level) and --in-process-gpu (macos-14-arm64 CI has real Apple Silicon GPU; subprocess is ad-hoc signed in the test setup step); update comments to cite actual mechanism (restricted bootstrap namespace for ad-hoc-only signed processes) verified against CEF source - ci-macos.yml wheel job: ad-hoc codesign subprocess and .so before packaging so installed wheels don't ship unsigned binaries; unsigned subprocess binary is the root cause of GPU_DEAD_ON_ARRIVAL (exit code 1003) on macOS 14+ Gatekeeper Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent fddf226 commit b33250e

3 files changed

Lines changed: 44 additions & 23 deletions

File tree

.github/workflows/ci-macos.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,16 @@ jobs:
181181
- name: Set up cefpython3 package
182182
run: cp -r build/artifacts/. cefpython3/
183183

184+
- name: Codesign binaries for distribution
185+
run: |
186+
# Ad-hoc sign the subprocess binary so macOS 14+ Gatekeeper allows
187+
# it to execute when users install the wheel. Without signing,
188+
# macOS blocks the unsigned binary and the GPU process (which uses
189+
# the same binary with --type=gpu-process) exits with code 1003
190+
# (GPU_DEAD_ON_ARRIVAL), causing a fatal crash.
191+
codesign --force --sign - cefpython3/subprocess
192+
for f in cefpython3/cefpython_py*.so; do codesign --force --sign - "$f"; done
193+
184194
- name: Build wheel
185195
run: python tools/build_distrib.py
186196

examples/screenshot.py

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,11 +74,26 @@ def main():
7474
# it using these Chromium switches (Issue #240 and #463)
7575
"disable-gpu": "",
7676
"disable-gpu-compositing": "",
77-
# Tweaking OSR performance by setting the same Chromium flags
78-
# as in upstream cefclient (Issue #240).
79-
"enable-begin-frame-scheduling": "",
80-
"disable-surfaces": "", # This is required for PDF ext to work
8177
}
78+
if sys.platform.startswith("darwin"):
79+
# Suppress macOS keychain authorization dialogs in headless use.
80+
switches["use-mock-keychain"] = ""
81+
# MachPortRendezvousServer bootstrap name requires a bundle ID.
82+
# Without one, renderer subprocess bootstrap_look_up fails.
83+
# --single-process runs the renderer in-process, avoiding the lookup.
84+
switches["single-process"] = ""
85+
# --single-process puts V8 in the browser process and requires a large
86+
# contiguous CodeRange; --jitless disables JIT to remove that need.
87+
switches["js-flags"] = "--jitless"
88+
# Run network service in-process to avoid Mach port rendezvous
89+
# failures for utility subprocesses on macOS.
90+
switches["enable-features"] = "NetworkServiceInProcess2"
91+
else:
92+
# Tweaking OSR performance (Issue #240). On macOS ARM the viz
93+
# Surfaces API is required for OSR browser creation, so these
94+
# switches must not be passed on macOS.
95+
switches["enable-begin-frame-scheduling"] = ""
96+
switches["disable-surfaces"] = "" # This is required for PDF ext to work
8297
browser_settings = {
8398
# Tweaking OSR performance (Issue #240)
8499
"windowless_frame_rate": 30, # Default frame rate in CEF is 30

unittests/osr_test.py

Lines changed: 15 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -136,30 +136,26 @@ def test_osr(self):
136136
# The feature string in Chrome 130+ is "NetworkServiceInProcess2".
137137
switches["enable-features"] = "NetworkServiceInProcess2"
138138
if MAC:
139-
# cefpython does not ship a chrome-sandbox binary.
140-
switches["no-sandbox"] = ""
141-
# No real GPU available on macOS CI runners.
142-
switches["in-process-gpu"] = ""
143-
# Prevent macOS keychain authorization prompts during init
144-
# (matches CEF's own test infrastructure on macOS).
139+
# Prevent macOS keychain authorization prompts during init.
140+
# CEF's own test infrastructure (client_app_browser.cc) does
141+
# the same on macOS.
145142
switches["use-mock-keychain"] = ""
146-
# Chrome 130+ MachPortRendezvousServer registers via
147-
# bootstrap_check_in; renderer subprocesses look up the service
148-
# via bootstrap_look_up, which fails on unsigned CI processes
149-
# because Chrome gives them a restricted bootstrap namespace.
150-
# --in-process-renderer was removed from Chrome 130+.
151-
# --single-process runs the renderer in the browser process,
152-
# eliminating renderer subprocess bootstrap_look_up failures.
143+
# Chrome 130+ MachPortRendezvousServer registers its bootstrap
144+
# service as BaseBundleID()+".MachPortRendezvousServer."+pid.
145+
# Python processes with only ad-hoc code signing receive a
146+
# restricted bootstrap namespace from macOS, so renderer
147+
# subprocesses cannot bootstrap_look_up the service.
148+
# --single-process runs the renderer inside the browser process,
149+
# eliminating the subprocess bootstrap_look_up entirely.
150+
# (--in-process-renderer was removed in Chrome 130+.)
153151
switches["single-process"] = ""
154152
# --single-process puts the renderer's V8 in the browser process,
155153
# which requires a large contiguous CodeRange for JIT code.
156-
# On constrained CI runner images this reservation fails with an
157-
# OOM error. --jitless disables all V8 JIT compilers, eliminating
158-
# the CodeRange requirement entirely.
154+
# --jitless disables V8 JIT, removing that requirement.
159155
switches["js-flags"] = "--jitless"
160-
# Run network service in-process to avoid Mach port rendezvous
161-
# failures for utility subprocesses on macOS CI runners.
162-
# The feature string in Chrome 130+ is "NetworkServiceInProcess2".
156+
# Run the network service in-process to avoid Mach port rendezvous
157+
# failures for the network utility subprocess on macOS.
158+
# (Feature name in Chrome 130+: "NetworkServiceInProcess2".)
163159
switches["enable-features"] = "NetworkServiceInProcess2"
164160
browser_settings = {
165161
# Tweaking OSR performance (Issue #240)

0 commit comments

Comments
 (0)