Page 1 of 1

Re: Avoid empty screen blinking before loading a page

Posted: Sat Oct 20, 2018 9:21 am
by salvadordf
Hi,

Try this to minimize the blinking effect :
  • Set TChromium.DefaultURL to your local file URL as soon as the browser is initialized. It must be set before the TChromium.CreateBrowser call.
  • Don't call TChromium.LoadURL in the TChromium.AfterCreated event because setting TChromium.DefaultURL will load your homepage automatically.
  • Use TChromium.Reload when you need to refresh the browser contents.
  • If you still see a brief "blink" when you reload the page try this :
    • Call TChromium.TakeSnapshot to save the browser contents in a bitmap.
    • Draw that bitmap in a hidden TImage.
    • Before reloading the web page, show the TImage and call TImage.BringToFront. Then hide the TCEFWindowParent and call TCEFWindowParent.SendToBack. TImage should have the same dimensions and coordinates as TCEFWindowParent.
    • Use the TChromium.OnLoadingStateChange event and check the "isLoading" parameter to know when the web page is loaded. Send a message to the main form to show TCEFWindowParent and hide TImage when isLoading is FALSE.

Re: Avoid empty screen blinking before loading a page

Posted: Sat Oct 20, 2018 2:52 pm
by salvadordf
Depending on the contents of the web page it can be tricky to know when it's fully loaded.

If the web page has several frames or if it changes the HTML contents from JavaScript then it can be hard to tell if it ever finishes loading.

The TChromium.OnLoadingStateChange event is one of the ways to know that but you can also use TChromium.OnLoadStart and TChromium.OnLoadEnd to check if all the frames are finished.

About refreshing TCEFWindowParent, CEF creates several child "windows" inside TCEFWindowParent. (I'm using the Windows API term for "window")

Perhaps you would get better results if you send the refresh messages to TChromium.RenderHandle, TChromium.WidgetHandle or TChromium.BrowserHandle.

Please, read this post about the child "windows" that CEF creates :
https://www.briskbard.com/forum/viewtop ... 530&p=2347

Are you using the DoubleBuffered property in your app?
If you use it, please, try disabling it. It's been reported that it causes problems :
https://www.briskbard.com/forum/viewtop ... 368&p=1696

Re: Avoid empty screen blinking before loading a page

Posted: Sat Oct 20, 2018 6:45 pm
by salvadordf
Thank you! :D

I just added your solution to CEF4Delphi and added the TCEFWinControl.InvalidateChildren procedure to invalidate all the children using RedrawWindow.