Skip to content

Commit d0e7e31

Browse files
linesightclaude
andcommitted
Extend OnContextInitialized wait from 6s to 30s; add fallback in CreateBrowserSync
In CI (GitHub Actions), the storage service utility subprocess fails at startup (global descriptor lookup 7) which delays OnContextInitialized past the previous 6-second pump-loop ceiling. Increase the ceiling to 30 seconds in Initialize(), and add a matching 30-second fallback pump in CreateBrowserSync() in case it is called right at the boundary after Initialize() returns. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 4f1fbb9 commit d0e7e31

1 file changed

Lines changed: 15 additions & 6 deletions

File tree

src/cefpython.pyx

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -627,18 +627,18 @@ def Initialize(applicationSettings=None, commandLineSwitches=None, **kwargs):
627627
# guarantees that CreateBrowserSync() can be called immediately after
628628
# Initialize() without hitting the deferred-creation path or getting
629629
# a null browser from CefBrowserHost::CreateBrowserSync().
630-
# 200 * 10ms = 2 seconds max; OnContextInitialized typically fires
631-
# within the first few iterations.
630+
# Use a generous ceiling (30s) for CI environments where utility
631+
# subprocesses (storage service) crash and delay context initialization.
632632
if ret:
633-
for _ in range(600):
633+
for _ in range(3000):
634634
with nogil:
635635
CefDoMessageLoopWork()
636636
if g_context_initialized:
637637
break
638638
time.sleep(0.01)
639639
if not g_context_initialized:
640640
Debug("CefInitialize() WARNING: OnContextInitialized not received"
641-
" within 6 seconds")
641+
" within 30 seconds")
642642

643643
if sys.platform.startswith("linux"):
644644
# Install by default.
@@ -676,8 +676,17 @@ def CreateBrowserSync(windowInfo=None,
676676
# Defer browser creation until OnContextInitialized fires inside MessageLoop.
677677
# In CEF 123+, browser creation before OnContextInitialized causes
678678
# blink.mojom.WidgetHost rejection and renderer shows no content.
679-
# Initialize() pumps the loop until OnContextInitialized fires, so this
680-
# path is only taken if CreateBrowserSync() is called before Initialize().
679+
# Initialize() pumps the loop for up to 30s; if still not initialized
680+
# (e.g. slow CI), pump an additional 30s before giving up.
681+
if not g_context_initialized:
682+
Debug("CreateBrowserSync(): OnContextInitialized not yet received,"
683+
" pumping message loop")
684+
for _ in range(3000):
685+
with nogil:
686+
CefDoMessageLoopWork()
687+
if g_context_initialized:
688+
break
689+
time.sleep(0.01)
681690
if not g_context_initialized:
682691
Debug("CreateBrowserSync() deferred until OnContextInitialized")
683692
g_pending_browsers.append({

0 commit comments

Comments
 (0)