CefInitialize hangs when CefApp parameter isn't null

Having problems with building or using CEF's C/C++ APIs? This forum is here to help. Please do not post bug reports or feature requests here.

CefInitialize hangs when CefApp parameter isn't null

Postby cybersight » Sat Jan 20, 2024 3:23 am

In the call to CefInitialize, I've been passing a nullptr for the application parameter and everything works fine. However, when I pass an actual CefApp, the program hangs inside somewhere inside CefInitialize.

If I add debug logs to the CefApp callbacks, I can see that the hang happens after a call to OnBeforeCommandLineProcessing and OnRegisterCustomSchemes. In both cases, I'm not modifying the arguments.

Here are the settings I'm using when initializing:

Code: Select all
settings := CefSettings new.
settings
   browser_subprocess_path: 'cefclient.exe' asCefString;
   log_severity: 0;
   log_file: 'cef.log' asCefString;
   cache_path: 'cef-cache' asCefString;
   no_sandbox: true;
   multi_threaded_message_loop: true;
   windowless_rendering_enabled: true


Note: I'm calling CefInitialize immediately after a call to CefExecuteProcess, and the behavior seems to be the same whether or not I pass the same CefApp argument to CefExecuteProcess.

Platform: Windows 32-bit, C API
cybersight
Techie
 
Posts: 38
Joined: Mon Dec 11, 2023 11:04 am

Re: CefInitialize hangs when CefApp parameter isn't null

Postby cybersight » Sat Jan 20, 2024 6:59 am

I realize this isn't a lot of information to go on, but even with logging set to VERBOSE, nothing shows up in logs. :/

viewtopic.php?f=6&t=19276&p=52899&hilit=+initialize+hangs#p52910 seems to be describing something similar, though I don't know why it would be a logging issue if logs work just fine when the application parameter is null.
cybersight
Techie
 
Posts: 38
Joined: Mon Dec 11, 2023 11:04 am

Re: CefInitialize hangs when CefApp parameter isn't null

Postby magreenblatt » Sat Jan 20, 2024 9:28 am

All CefSettings path and file arguments need to be absolute.
magreenblatt
Site Admin
 
Posts: 12409
Joined: Fri May 29, 2009 6:57 pm

Re: CefInitialize hangs when CefApp parameter isn't null

Postby cybersight » Sat Jan 20, 2024 12:15 pm

magreenblatt wrote:All CefSettings path and file arguments need to be absolute.


Ah, I am using absolute paths in my actual code, but abbreviated it here. I guess that was a mistake.

Also, the logs do work when I don't initialize with an app. I.e., they go to the correct file with the correct verbosity level.
cybersight
Techie
 
Posts: 38
Joined: Mon Dec 11, 2023 11:04 am

Re: CefInitialize hangs when CefApp parameter isn't null

Postby cybersight » Sat Jan 20, 2024 12:45 pm

Okay, I found a fix though I don't quite understand why it works.

If I run CefInitialize on a separate thread, it no longer hangs and completes successfully. Which makes it seem like there's some blocking behavior in CefInitialize that depends on another thread that for whatever reason is getting starved.

Any idea why that might be happening? Or alternative explanations?
cybersight
Techie
 
Posts: 38
Joined: Mon Dec 11, 2023 11:04 am

Re: CefInitialize hangs when CefApp parameter isn't null

Postby cybersight » Sat Jan 20, 2024 1:14 pm

cybersight wrote:Okay, I found a fix though I don't quite understand why it works.

If I run CefInitialize on a separate thread, it no longer hangs and completes successfully. Which makes it seem like there's some blocking behavior in CefInitialize that depends on another thread that for whatever reason is getting starved.

Any idea why that might be happening? Or alternative explanations?


Actually no, it doesn't entirely work. It still hangs on the call to CefInitialize, but hitting my IDE's break key opens a debugger, and then if I resume execution it continues and CefInitialize completes successfully. As opposed to before, where it would hang and hitting the break key had no effect.
Last edited by cybersight on Sun Jan 21, 2024 1:14 am, edited 1 time in total.
cybersight
Techie
 
Posts: 38
Joined: Mon Dec 11, 2023 11:04 am

Re: CefInitialize hangs when CefApp parameter isn't null

Postby magreenblatt » Sat Jan 20, 2024 1:43 pm

Your example doesn’t look like C/C++. What language or CEF wrapper are you using? Are you calling CefInitialize on the main application thread? I suggest comparing your code to available sample applications.
magreenblatt
Site Admin
 
Posts: 12409
Joined: Fri May 29, 2009 6:57 pm

Re: CefInitialize hangs when CefApp parameter isn't null

Postby cybersight » Sun Jan 21, 2024 1:10 am

magreenblatt wrote:Your example doesn’t look like C/C++. What language or CEF wrapper are you using? Are you calling CefInitialize on the main application thread? I suggest comparing your code to available sample applications.


I'm using Dolphin Smalltalk, with a wrapper I'm building as I go. And I'm calling CefInitialize on the main application thread, or at least the closest equivalent to it. Smalltalk has green threads and I don't know enough about how they're implemented in the VM so say how they correspond to threads in a typical C/C++ application.

At this point I'm pretty sure it's an issue and/or quirk with the Dolphin runtime and not CEF, so I created [an issue in the Dolphin repo][https://github.com/dolphinsmalltalk/Dolphin/issues/1278]. I'll post an update here if I find a solution since it might be relevant to other runtimes too.
cybersight
Techie
 
Posts: 38
Joined: Mon Dec 11, 2023 11:04 am

Re: CefInitialize hangs when CefApp parameter isn't null

Postby magreenblatt » Sun Jan 21, 2024 10:38 am

Have you looked as existing projects, like https://github.com/JBetz/Dolphin-CEF (unless that’s you)?
magreenblatt
Site Admin
 
Posts: 12409
Joined: Fri May 29, 2009 6:57 pm

Re: CefInitialize hangs when CefApp parameter isn't null

Postby cybersight » Sun Jan 21, 2024 10:49 pm

magreenblatt wrote:Have you looked as existing projects, like https://github.com/JBetz/Dolphin-CEF (unless that’s you)?


Yeah, that's me :D

I made some progress by talking to one of the Dolphin developers. Their guess was that it had something to do with the message loop, so I tried setting `multi_threaded_message_loop` to false in my code, and voilà, CefInitialize returned immediately. So that seems to be the right track of investigation.

Does CefInitialize somehow depend on the message loop being pumped or otherwise advanced in order to finish? And does it make sense for this to only happen with a CefApp parameter?
cybersight
Techie
 
Posts: 38
Joined: Mon Dec 11, 2023 11:04 am

Next

Return to Support Forum

Who is online

Users browsing this forum: No registered users and 181 guests