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.
If you find these projects useful please consider becoming a sponsor with Patreon, GitHub or Liberapay.

New close order with CEF_RUNTIME_STYLE_CHROME

Post Reply
R. Eisenkolb
Posts: 8
Joined: Fri May 14, 2021 8:13 am

New close order with CEF_RUNTIME_STYLE_CHROME

Post by R. Eisenkolb »

Hello Salvador,

our application has been running quite well with CEF4D for years.
But we are not happy with the changes in the CEF 128.4.8 update.
So far our application ran with ChromeRuntime = false.
Now we read that the Runtime is now always switched on and that for full UI support and for intensive JavaScript use the RuntimeStyle = CEF_RUNTIME_STYLE_CHROME is recommended.
Since we use TinyMCE with JavaScript in Chromium, CEF_RUNTIME_STYLE_ALLOY doesn't seem useful to us.

But CEF_RUNTIME_STYLE_CHROME comes with a new close mechanism that needs to be implemented in the application.
With all due respect: The recommendation to artificially run OnCloseQuery twice to reverse the closing order of CEF objects reads like a makeshift hack.
For us, that would mean massive modifications to dozens of code locations - with a high risk of crashes.
Is it planned that the "normal" closing sequence is also maintained for RuntimeStyle CEF_RUNTIME_STYLE_CHROME at this point?

Best regards
Reinhard
User avatar
salvadordf
Posts: 4620
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: New close order with CEF_RUNTIME_STYLE_CHROME

Post by salvadordf »

Hello Reinhard,

I'm sorry that this feature requires some modifications in your application but the documentation in the CEF project recommends using this multistage closing sequence in order to avoid crashes.

These are the code comments in the CEF project where the closing sequence is described :
https://bitbucket.org/chromiumembedded/cef/src/6f44cfcb65e4b596a85ca08a4ffb7202e20682a6/include/capi/cef_life_span_handler_capi.h#lines-141
https://bitbucket.org/chromiumembedded/cef/src/6f44cfcb65e4b596a85ca08a4ffb7202e20682a6/include/capi/cef_browser_capi.h#lines-304

I copied and adapted to CEF4Delphi those code comments here :
https://github.com/salvadordf/CEF4Delphi/blob/0aebca3630b3a1bf7404dbb7acc9ca44b85b01c5/source/uCEFChromiumCore.pas#L2714
https://github.com/salvadordf/CEF4Delphi/blob/0aebca3630b3a1bf7404dbb7acc9ca44b85b01c5/source/uCEFChromiumCore.pas#L733

If you don't use the off-screen rendering mode, the Alloy style requires :
  1. Calling TChromiumCore.CloseBrowser.
  2. Wait for the TChromiumCore.OnClose event.
  3. Destroy the parent control that hosts the browser.
  4. Wait for the TChromiumCore.OnBeforeClose event.
  5. Close the application.
If you don't use the off-screen rendering mode, the Chrome style requires :
  1. Calling TChromiumCore.CloseBrowser.
  2. Destroy the parent control that hosts the browser.
  3. Wait for the TChromiumCore.OnBeforeClose event.
  4. Close the application.
The closing sequence in the demos is a safe way to close the application but it's not the only way to do it.

You can adapt those steps to your application in any way you want but make sure all the browsers triggered the TChromiumCore.OnBeforeClose event before closing the application.
R. Eisenkolb
Posts: 8
Joined: Fri May 14, 2021 8:13 am

Re: New close order with CEF_RUNTIME_STYLE_CHROME

Post by R. Eisenkolb »

Thanks very much for the quick answer and your background information.
We will check this out and try to find a more convenient way to close the form(s).
Thank you.
Best regards
Reinhard
R. Eisenkolb
Posts: 8
Joined: Fri May 14, 2021 8:13 am

Re: New close order with CEF_RUNTIME_STYLE_CHROME

Post by R. Eisenkolb »

Hello Salvador,
we are now using the 130 version of CEF. First we configured the alloy runtime style to keep the old close procedure and avoided critical changes in our code. Then sometime we randomly tried the chrome runtime style and observed that everything worked fine without changes.
Before our application closed immediately after freeing the browser when using the chrome style.
Does version 130 restore the original close procedure? No matter if runtime style chrome or alloy is used?
What do you observe?
Thanks in advance
Reinhard
User avatar
salvadordf
Posts: 4620
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: New close order with CEF_RUNTIME_STYLE_CHROME

Post by salvadordf »

I haven't noticed any change.

The Chrome style skips the TChromium.OnClose event as before.

If an application uses the OSR mode then it always uses the Alloy style.
Post Reply