Hi,
I'm having a problem with CEF4Delphi that happens when I close my application. I have a TChromium component that creates a browser that shows a static html, the problem is that when I close my program it hangs.
Debugging I saw that on the line -> if FMustShutDown then ShutDown;
Before closing the form I execute the following code: FChromium.CloseBrowser (True);
I think it's also valid to say that I use RunTime Packages.
Thank you.
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.
CefShutdown hangs
- salvadordf
- Posts: 4564
- Joined: Thu Feb 02, 2017 12:24 pm
- Location: Spain
- Contact:
Re: CefShutdown hangs
Hi Kewin,
Do you use the TChromium.Close and TChromiu.BeforeClose events after calling TChromium.CloseBrowser ?
What component are you using?
TChromium or TChromiumWindow?
Did you use a demo as a base for your app ? Which one ?
Do you use the TChromium.Close and TChromiu.BeforeClose events after calling TChromium.CloseBrowser ?
What component are you using?
TChromium or TChromiumWindow?
Did you use a demo as a base for your app ? Which one ?
-
- Posts: 3
- Joined: Thu Feb 22, 2018 12:11 pm
Re: CefShutdown hangs
Hi,
Basically I have a TCustomControl with a TChromium encapsulated. I create my TCustomControl in the following way:
where "Self" is the CustomControl
in the destroy method of my CustomControl I do the following:
At the beginning of development I think i used the "MdiBrowser" demo.
Basically I have a TCustomControl with a TChromium encapsulated. I create my TCustomControl in the following way:
Code: Select all
FChromium: = TChromium.Create (Self);
...
FChromium.CreateBrowser (Self);
in the destroy method of my CustomControl I do the following:
Code: Select all
begin
if not (csDesigning in ComponentState) then
FChromium.CloseBrowser (True);
inherited;
end;
- salvadordf
- Posts: 4564
- Joined: Thu Feb 02, 2017 12:24 pm
- Location: Spain
- Contact:
Re: CefShutdown hangs
If TCustomControl is destroyed at the same time that you close your application then you may not need to call CloseBrowser at all.
However, if you create and destroy your TCustomControl manually at run time then you need to follow the destruction sequence described in the MDIBrowser demo.
Every TChildForm in the MDIBrowser follows this sequence :
The main form waits until all child forms are correctly closed before closing the app. If you miss any of these steps CEF won't be able to shut down correctly.
Other demos, like SimpleExternalPumpBrowser, also follow the same destruction sequence even if they don't destroy the browser at run time.
However, if you create and destroy your TCustomControl manually at run time then you need to follow the destruction sequence described in the MDIBrowser demo.
Every TChildForm in the MDIBrowser follows this sequence :
- FormCloseQuery calls TChromium.CloseBrowser which triggers TChromium.OnClose
- TChromium.OnClose sends a CEFBROWSER_DESTROY message to destroy CEFWindowParent1 in the main thread which triggers TChromium.OnBeforeClose.
- TChromium.OnBeforeClose sets FCanClose := True and sends WM_CLOSE to the child form.
The main form waits until all child forms are correctly closed before closing the app. If you miss any of these steps CEF won't be able to shut down correctly.
Other demos, like SimpleExternalPumpBrowser, also follow the same destruction sequence even if they don't destroy the browser at run time.