Page 1 of 1

AV in TCefUpdatePrefsTask.Execute & TCefCustomDeleteCookiesCallback.OnComplete

Posted: Wed Nov 27, 2019 11:14 am
by dian
We are getting access violations in TCefUpdatePrefsTask.Execute() and in TCefCustomDeleteCookiesCallback.OnComplete()

Looks like events occurs after TChromium been closed and freed.

How to free TChromium correct and completely?


CEF version is 76.0.3809.132

Re: AV in TCefUpdatePrefsTask.Execute & TCefCustomDeleteCookiesCallback.OnComplete

Posted: Wed Nov 27, 2019 1:59 pm
by salvadordf
Hi,

Read the code comments in the demo you used as the template for your application.
There you'll find the "Destruction steps" that you must follow to destroy the browsers.

The CEF version 76.0.3809.132 needed to disable the "Network Service" before calling GlobalCEFApp.StartMainProcess in the DPR file.

The CEF4Delphi version uploaded today has fixed the shutdown issues we had recently. Read this for more information :
https://github.com/salvadordf/CEF4Delphi/issues/230

Re: AV in TCefUpdatePrefsTask.Execute & TCefCustomDeleteCookiesCallback.OnComplete

Posted: Fri Nov 29, 2019 3:22 am
by dian
Experimenting with disabling of NetworkService. Seems it didn't help.

Destruction steps are generally about freeing TCEFWindowParent while in my case I'd like to re-create browser with same TCEFWindowParent

Re: AV in TCefUpdatePrefsTask.Execute & TCefCustomDeleteCookiesCallback.OnComplete

Posted: Fri Nov 29, 2019 8:31 am
by salvadordf
TCEFWindowParent is the father of some controls generated by CEF to draw the web contents.

Those controls need to be destroyed to trigger the TChromium.OnBeforeClose event. Without that event the browser is not destroyed properly and that's the cause of the access violations.

If you're planning on shutting down the browser wait until the cookies are deleted. Wait until the TChromium.OnCookiesDeleted event is triggered.

It's not necessary to call TChromium.UpdatePreferences each time you need to set new preferences if you plan to navigate to a new URL because they are updated automatically in TChromiumCore.doOnBeforeBrowse.