Browser subprocess not shutting down on Win7

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.

Browser subprocess not shutting down on Win7

Postby callum » Wed Mar 07, 2018 2:02 pm

Trying to debug issue that appeared with 3.3282.1742.g96f907e version of CEF on 64bit Windows.

Because I use CEF in a DLL, (my understanding is that) I have to build a small host executable and point to it during initialization via CefSettings::browser_subprocess_path.

The source code for the host exe is trivial:

Code: Select all
int CALLBACK WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
    CefMainArgs args(GetModuleHandle(nullptr));

    return CefExecuteProcess(args, nullptr, nullptr);
}


This works fine in most cases but as of the switch to the new CEF, the host process exes often don't close down and remain running after my app closes. This didn't happen when I built against an earlier version of CEF (cef_3239.1723.g071d1c1).

No one is able to repro it on Windows 10 (my dev environment) but it does so readily on Windows 7 for QA folk. Constructing a Windows 7 dev environment isn't an option sadly.

It's hard to fix or debug if I can't repro it - does this ring any bells?
callum
Expert
 
Posts: 326
Joined: Mon Feb 23, 2015 6:19 pm

Re: Browser subprocess not shutting down on Win7

Postby magreenblatt » Wed Mar 07, 2018 3:50 pm

Does the problem reproduce with the cefclient sample application?

Do sub-processes always remain behind on Win7, or just sometimes? Is it always the same number of sub-processes left behind? What is the command-line for the left-behind processes (using a tool like Process Explorer to find out)?

How are you running the CEF message loop in your main app? Are you calling CefShutdown?
magreenblatt
Site Admin
 
Posts: 12409
Joined: Fri May 29, 2009 6:57 pm

Re: Browser subprocess not shutting down on Win7

Postby callum » Wed Mar 07, 2018 5:24 pm

Does the problem reproduce with the cefclient sample application?


No. I asked QA to start cefclient several times and 3 x cefclient.exe instances seen for each but all are cleaned up on exit.


Do sub-processes always remain behind on Win7, or just sometimes? Is it always the same number of sub-processes left behind? What is the command-line for the left-behind processes (using a tool like Process Explorer to find out)?


On systems where it fails, some of the host exes close as expected and some do not. No pattern to how many - potentially dozens running at any one time and usually 2-3 left open once main app closes. Command line for one that is left behind is : ""

How are you running the CEF message loop in your main app? Are you calling CefShutdown?


Regularly calling CefDoMessageLoopWork(). I follow the recommended closedown procedure of calling CloseBrowser(), waiting for :OnBeforeClose() then exiting my message loop, calling CefShutdown() before exiting the app.

Looking through my code, I came across this:

Code: Select all
    CEF_REQUIRE_UI_THREAD();

    BrowserList::iterator bit = mBrowserList.begin();
    for (; bit != mBrowserList.end(); ++bit)
    {
        if ((*bit)->IsSame(browser))
        {
            mBrowserList.erase(bit);
            break;
        }
    }

    if (mBrowserList.empty())
    {
        // necessary to enforce CEF finishes work before exit - writing cookies file for example.
        // see: https://github.com/chromiumembedded/cef/blob/2773518869b5f57a848e807ddb2ee30adbf1c255/tests/shared/browser/main_message_loop_external_pump_win.cc#L91
        // and: https://bitbucket.org/chromiumembedded/cef/issues/1805/
        const int num_extra_cef_work_loops = 10;
        const int sleep_time_between_calls = 50;

        for (int i = 0; i < num_extra_cef_work_loops; ++i)
        {
            CefDoMessageLoopWork();
            Sleep(sleep_time_between_calls);
        }

        mParent->getCallbackManager()->onRequestExit();
    }


The code that makes extra calls to CefDoMessageWorkLoop() is new and I think was ultimately found via a post here somewhere.
callum
Expert
 
Posts: 326
Joined: Mon Feb 23, 2015 6:19 pm

Re: Browser subprocess not shutting down on Win7

Postby magreenblatt » Wed Mar 07, 2018 5:29 pm

callum wrote: Command line for one that is left behind is : ""

This is a very unlikely command-line. Are you sure this is the helper exe launched by Chromium? At what point does the process appear?
magreenblatt
Site Admin
 
Posts: 12409
Joined: Fri May 29, 2009 6:57 pm

Re: Browser subprocess not shutting down on Win7

Postby callum » Wed Mar 07, 2018 5:33 pm

No - I'm sorry - I hit Submit instead of Preview while composing and waiting for QA team with a box that repros it to get back to me - was going to edit as soon as they did.
callum
Expert
 
Posts: 326
Joined: Mon Feb 23, 2015 6:19 pm

Re: Browser subprocess not shutting down on Win7

Postby callum » Wed Mar 07, 2018 5:45 pm

command line of an orphaned process is:
dullahan_host.exe --type=renderer --disable-browser-side-navigation --no-sandbox --service-pipe-token=B5366053E1FACDF69B654F89DB3A8AC7 --lang=en-US --lang=en-US --log-file="C:\Users\rgrk\AppData\Roaming\SecondLife\logs\cef_log.txt" --product-version="(Dullahan:1.1.1050 [64bit] - SecondLife/5.1.2.512957 (Second Life Release; default skin)) Chrome/64.0.3282.119 [64bit]" --enable-system-flash --enable-pinch --device-scale-factor=1 --num-raster-threads=2 --enable-main-frame-before-activation --enable-gpu-async-worker-context --content-image-texture-target=0,0,3553;0,1,3553;0,2,3553;0,3,3553;0,4,3553;0,5,3553;0,6,3553;0,7,3553;0,8,3553;0,9,3553;0,10,3553;0,11,3553;0,12,3553;0,13,3553;0,14,3553;0,15,3553;0,16,3553;0,17,3553;0,18,3553;1,0,3553;1,1,3553;1,2,3553;1,3,3553;1,4,3553;1,5,3553;1,6,3553;1,7,3553;1,8,3553;1,9,3553;1,10,3553;1,11,3553;1,12,3553;1,13,3553;1,14,3553;1,15,3553;1,16,3553;1,17,3553;1,18,3553;2,0,3553;2,1,3553;2,2,3553;2,3,3553;2,4,3553;2,5,3553;2,6,3553;2,7,3553;2,8,3553;2,9,3553;2,10,3553;2,11,3553;2,12,3553;2,13,3553;2,14,3553;2,15,3553;2,16,3553;2,17,3553;2,18,3553;3,0,3553;3,1,3553;3,2,3553;3,3,3553;3,4,3553;3,5,3553;3,6,3553;3,7,3553;3,8,3553;3,9,3553;3,10,3553;3,11,3553;3,12,3553;3,13,3553;3,14,3553;3,15,3553;3,16,3553;3,17,3553;3,18,3553;4,0,3553;4,1,3553;4,2,3553;4,3,3553;4,4,3553;4,5,3553;4,6,3553;4,7,3553;4,8,3553;4,9,3553;4,10,3553;4,11,3553;4,12,3553;4,13,3553;4,14,3553;4,15,3553;4,16,3553;4,17,3553;4,18,3553;5,0,3553;5,1,3553;5,2,3553;5,3,3553;5,4,3553;5,5,3553;5,6,3553;5,7,3553;5,8,3553;5,9,3553;5,10,3553;5,11,3553;5,12,3553;5,13,3553;5,14,3553;5,15,3553;5,16,3553;5,17,3553;5,18,3553;6,0,3553;6,1,3553;6,2,3553;6,3,3553;6,4,3553;6,5,3553;6,6,3553;6,7,3553;6,8,3553;6,9,3553;6,10,3553;6,11,3553;6,12,3553;6,13,3553;6,14,3553;6,15,3553;6,16,3553;6,17,3553;6,18,3553 --service-request-channel-token=B5366053E1FACDF69B654F89DB3A8AC7 --renderer-client-id=3 --mojo-platform-channel-handle=1376 /prefetch:1
callum
Expert
 
Posts: 326
Joined: Mon Feb 23, 2015 6:19 pm

Re: Browser subprocess not shutting down on Win7

Postby magreenblatt » Wed Mar 07, 2018 8:56 pm

Is it possible that your app is not calling CefShutdown in all cases (perhaps exiting early with exit() or similar)? Does the problem reproduce with 'cefclient --external-message-pump'? Are you implementing CefDoMessageLoopWork as shown in cefclient?
magreenblatt
Site Admin
 
Posts: 12409
Joined: Fri May 29, 2009 6:57 pm

Re: Browser subprocess not shutting down on Win7

Postby callum » Wed Mar 07, 2018 9:03 pm

Understood. I'll ask QA with the Windows 7 box to try the cefclient test.

It don't think the DLL is exiting early and not shutting down correctly but that's certainly possible given the complexity of the whole system - I'll focus on that.

I am as far as I know, doing everything the same way as cefclient but I'll double check that again too.

The extra calls to CefDoMessageLoopWork() are suspect because adding them was the same time the issue appeared but I expect you'd have mentioned if it that was a possibility.

Everything works as expected in my small test app of course - only fails in the big, more complex system and only on certain OS versions.
callum
Expert
 
Posts: 326
Joined: Mon Feb 23, 2015 6:19 pm

Re: Browser subprocess not shutting down on Win7

Postby magreenblatt » Wed Mar 07, 2018 9:10 pm

Calling CefDoMessageLoopWork multiple times before shutdown should be fine and has been known to fix various issues in the past. Do you have logging enabled in your application? Does it output anything relevant in cases where the processes are left behind?
magreenblatt
Site Admin
 
Posts: 12409
Joined: Fri May 29, 2009 6:57 pm

Re: Browser subprocess not shutting down on Win7

Postby callum » Wed Mar 07, 2018 9:25 pm

I do have logging enabled but I might have it turned up too high - I'll check, All the instances share one log file too - is that valid or should I create a separate log file for each?
callum
Expert
 
Posts: 326
Joined: Mon Feb 23, 2015 6:19 pm

Next

Return to Support Forum

Who is online

Users browsing this forum: Google [Bot] and 112 guests