Skip to content

Commit 076f8dc

Browse files
linesightclaude
andcommitted
Fix Linux CefMainArgs empty command line; log subprocess type
cefpython.pyx: Linux was using the default CefMainArgs() constructor (argc=0, argv=nullptr), leaving Chromium's base::CommandLine with no program name. CEF 146 relies on a valid CommandLine::GetProgram() when bootstrapping IPC shared-memory channels for subprocesses (global descriptor 7). Pass argc=1, argv[0]=sys.executable so Chromium has a proper program name to work from. cefpython_app.cpp: change OnBeforeChildProcessLaunch log from INFO to ERROR so the subprocess command line (including --type=) is visible in CI output regardless of log_severity setting, aiding diagnosis. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent ebc151a commit 076f8dc

2 files changed

Lines changed: 8 additions & 3 deletions

File tree

src/cefpython.pyx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -577,8 +577,13 @@ def Initialize(applicationSettings=None, commandLineSwitches=None, **kwargs):
577577
cdef HINSTANCE hInstance = GetModuleHandle(NULL)
578578
cdef CefMainArgs cefMainArgs = CefMainArgs(hInstance)
579579
ELIF UNAME_SYSNAME == "Linux":
580-
# TODO: use the CefMainArgs(int argc, char** argv) constructor.
581-
cdef CefMainArgs cefMainArgs
580+
# Pass argv[0] = Python executable so Chromium's CommandLine is
581+
# initialized with a valid program name. CEF 146 relies on this for
582+
# correct IPC channel bootstrap in subprocesses (global descriptor 7).
583+
cdef bytes _cefMainArgv0 = sys.executable.encode('utf-8')
584+
cdef char* _cefMainArgv0Ptr = _cefMainArgv0
585+
cdef char** _cefMainArgv = &_cefMainArgv0Ptr
586+
cdef CefMainArgs cefMainArgs = CefMainArgs(1, _cefMainArgv)
582587
ELIF UNAME_SYSNAME == "Darwin":
583588
# TODO: use the CefMainArgs(int argc, char** argv) constructor.
584589
cdef CefMainArgs cefMainArgs

src/subprocess/cefpython_app.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ void CefPythonApp::OnBeforeChildProcessLaunch(
204204
logMessage.append("OnBeforeChildProcessLaunch() command line: ");
205205
std::string clString = command_line->GetCommandLineString().ToString();
206206
logMessage.append(clString.c_str());
207-
LOG(INFO) << logMessage.c_str();
207+
LOG(ERROR) << logMessage.c_str();
208208
}
209209

210210
CefRefPtr<CefPrintHandler> CefPythonApp::GetPrintHandler() {

0 commit comments

Comments
 (0)