Page 1 of 1

CreateBrowser vs. CreateBrowserSync

PostPosted: Fri Feb 19, 2021 3:40 pm
by sdiverdi
I just had quite a debugging experience and I'm curious about the behavior I observed. I changed CreateBrowser to CreateBrowserSync and found that after that change, when closing the browser through browser->GetHost()->CloseBrowser(false), that the usual DoClose call happens and after that, no call to OnBeforeClose ever comes and the app fails to quit. If I change CreateBrowserSync back to CreateBrowser (no other changes) then the shutdown sequence occurs as expected (CloseBrowser, then DoClose, then OnBeforeClose, then process terminates).

The CefBrowserHost comments for CreateBrowser and CreateBrowserSync don't seem to indicate a difference like this. Is there some different shutdown behavior necessary for CreateBrowserSync? Or is this a bug? This is on osx, with build 88.2.0+g6a304f5+chromium-88.0.4324.96 .

Re: CreateBrowser vs. CreateBrowserSync

PostPosted: Fri Feb 19, 2021 5:16 pm
by magreenblatt
How are you running the message loop? Where are you calling CreateBrowser/CreateBrowserSync?

Re: CreateBrowser vs. CreateBrowserSync

PostPosted: Fri Feb 19, 2021 5:48 pm
by sdiverdi
My code is based on cefsimple so the message loop is run in the app main and CreateBrowser is called in SimpleApp's OnContextInitialized. In fact I just tested: a fresh clone of cef-project, build cefsimple and run works fine, change the call to CreateBrowser in simple_app.cc to CreateBrowserSync and has the same problem: DoClose gets called but not OnBeforeClose and the process doesn't terminate until I kill it.

Re: CreateBrowser vs. CreateBrowserSync

PostPosted: Fri Feb 19, 2021 7:29 pm
by magreenblatt
Does the browser otherwise behave normally?

Re: CreateBrowser vs. CreateBrowserSync

PostPosted: Fri Feb 19, 2021 8:42 pm
by sdiverdi
Yep seems like it. When I use CreateBrowserSync in cefsimple I'm able to search on Google, go to other pages, create new windows, close those windows (and see calls to OnBeforeClose), keep browsing, and then when I quit (command-q) the last OnBeforeClose never comes in. (Presumably the new windows that are creating during usage aren't created with CreateBrowserSync, which may be why they're able to close successfully.)

I should add using the fresh cef-project clone, it's using CEF binary 87.1.12+g03f9336+chromium-87.0.4280.88 instead. That's why I wonder if this is a usage problem instead of a bug -- the CreateBrowserSync comments don't seem to suggest that it needs to be called / handled differently than CreateBrowserSync, but this same behavior exists in both 4280 and 4324. But the problem is easy to see, just take the regular cefsimple project and replace the CreateBrowser call in simple_app.cc with CreateBrowserSync, and the app will fail to quit properly (on osx at least, I'm building with xcode 12.4 on 10.15.7).

Re: CreateBrowser vs. CreateBrowserSync

PostPosted: Fri Feb 19, 2021 9:04 pm
by magreenblatt
Please add a bug.

Re: CreateBrowser vs. CreateBrowserSync

PostPosted: Thu Apr 29, 2021 4:45 pm
by magreenblatt
This is likely the same problem that’s described at https://bitbucket.org/chromiumembedded/ ... t-60442115. Maybe something to do with NSAutoReleasePool scope.