Skip to content

Commit 4451b83

Browse files
linesightclaude
andcommitted
Fix macOS ARM OSR: exclude disable-surfaces/begin-frame switches, extend init timeout
On macOS ARM, the viz Surfaces API is required for OSR browser creation. --disable-surfaces (and its companion --enable-begin-frame-scheduling) prevent viz from initialising, causing CefBrowserHost::CreateBrowserSync() to return null. Exclude both switches on macOS so the Surfaces pipeline stays alive. Also extend the OnContextInitialized pump loop from 6 s to 30 s to give slower CI environments enough time before CreateBrowserSync() falls back to the deferred (None-returning) path. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 72a16c0 commit 4451b83

2 files changed

Lines changed: 10 additions & 8 deletions

File tree

src/cefpython.pyx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -622,18 +622,18 @@ def Initialize(applicationSettings=None, commandLineSwitches=None, **kwargs):
622622
# guarantees that CreateBrowserSync() can be called immediately after
623623
# Initialize() without hitting the deferred-creation path or getting
624624
# a null browser from CefBrowserHost::CreateBrowserSync().
625-
# 200 * 10ms = 2 seconds max; OnContextInitialized typically fires
626-
# within the first few iterations.
625+
# OnContextInitialized typically fires within the first few iterations;
626+
# allow up to 30 seconds for slow CI environments.
627627
if ret:
628-
for _ in range(600):
628+
for _ in range(3000):
629629
with nogil:
630630
CefDoMessageLoopWork()
631631
if g_context_initialized:
632632
break
633633
time.sleep(0.01)
634634
if not g_context_initialized:
635635
Debug("CefInitialize() WARNING: OnContextInitialized not received"
636-
" within 6 seconds")
636+
" within 30 seconds")
637637

638638
if sys.platform.startswith("linux"):
639639
# Install by default.

unittests/osr_test.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -107,11 +107,13 @@ def test_osr(self):
107107
# it using these Chromium switches (Issue #240 and #463)
108108
"disable-gpu": "",
109109
"disable-gpu-compositing": "",
110-
# Tweaking OSR performance by setting the same Chromium flags
111-
# as in upstream cefclient (Issue #240).
112-
"enable-begin-frame-scheduling": "",
113-
"disable-surfaces": "", # This is required for PDF ext to work
114110
}
111+
if not MAC:
112+
# Tweaking OSR performance (Issue #240). On macOS ARM the viz
113+
# Surfaces API is required for OSR browser creation, so these
114+
# switches (which disable it) must not be passed there.
115+
switches["enable-begin-frame-scheduling"] = ""
116+
switches["disable-surfaces"] = "" # Required for PDF ext to work
115117
if LINUX:
116118
# Sandbox setup fails on CI runners.
117119
switches["no-sandbox"] = ""

0 commit comments

Comments
 (0)