Disclosure Statement: This site contains affiliate links, which means that I may receive a commission if you make a purchase using these links. As an eBay Partner, I earn from qualifying purchases.

Renderer Process doesn't end after app has closed

Post Reply
Albus

Renderer Process doesn't end after app has closed

Post 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.
User avatar
salvadordf
Posts: 4057
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

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

Post 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?
Albus

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

Post 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.
User avatar
salvadordf
Posts: 4057
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

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

Post 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.
User avatar
salvadordf
Posts: 4057
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

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

Post by salvadordf »

The previous sequence is used here :
https://github.com/salvadordf/CEF4Delph ... rowser.pas
Albus

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

Post by Albus »

Thank you, this works perfectly!
Post Reply