Page 1 of 1

Renderer Process doesn't end after app has closed

Posted: Mon Apr 16, 2018 1:34 pm
by Albus
Hi, I have a very big problem with the multiprocess system of CEF. We are currently in the process of integrating chromium into our application. Now we have noticed, however, that the rendering process does not end after exiting the application, but continues to run headlessly. However, I can't explain why the rendering process gets stuck. I also tried to define a dedicated executable for the subprocesses, but that didn't work either. The integration of chromium into the dpr file was done correctly. In a test application this also works perfectly, only in our existing application I could determine the problem.

Re: Renderer Process doesn't end after app has closed

Posted: Mon Apr 16, 2018 2:53 pm
by salvadordf
Hi,

Are you using the latest CEF4Delphi version?

Are you calling TChromium.CloseBrowser and waiting until the TChromium.BeforeClose event is triggered in all your browsers before closing your app ?
For a detailed description of this "destruction sequence" read the code comments in the CEF4Delphi demo that is similar to your app.
There are slight differences in that sequence depending on the components you use or how you use them.

Please, also check that GlobalCEFApp is freed in the last line of your DPR file.

If you already do all these things and you still see an orphan subprocess give me more details about your app :
  • Components used.
  • Number of browsers your app creates.
  • Do you use TChromium in OSR mode or normal mode ?
  • Delphi version
  • Windows version
  • Can you replicate this with any of the demos?

Re: Renderer Process doesn't end after app has closed

Posted: Mon Apr 16, 2018 3:00 pm
by Albus
It seems as if I am not calling TChromium.CloseBrowser. I call GlobalCEFApp.free in finalization, is that too late? The strange thing is that it works in my test application without any problems, even without CloseBrowser.
I have now also put a CloseBrowser(True) into FormClose, but the rendering process still hangs.

Re: Renderer Process doesn't end after app has closed

Posted: Mon Apr 16, 2018 3:09 pm
by salvadordf
This is the destruction sequence in the MiniBrowser demo :
  • 1. FormCloseQuery sets CanClose to FALSE calls TChromium.CloseBrowser which triggers the TChromium.OnClose event.
  • 2. TChromium.OnClose sends a CEFBROWSER_DESTROY message to destroy CEFWindowParent1 in the main thread, which triggers the TChromium.OnBeforeClose event.
  • 3. TChromium.OnBeforeClose sets FCanClose := True and sends WM_CLOSE to the form.
Follow all these steps if you use TChromium and TCEFWindowParent in normal mode.

If you close your app before receiving the TChromium.OnBeforeClose event you may have shutdown problems.

Re: Renderer Process doesn't end after app has closed

Posted: Mon Apr 16, 2018 3:10 pm
by salvadordf
The previous sequence is used here :
https://github.com/salvadordf/CEF4Delph ... rowser.pas

Re: Renderer Process doesn't end after app has closed

Posted: Tue Apr 17, 2018 9:17 am
by Albus
Thank you, this works perfectly!