Page 1 of 1

Browser background

Posted: Thu Jun 07, 2018 6:11 pm
by petko
I use TChromiumWindow and create a browser using CreateBrowser method (and then load an HTML using LoadStringW method).

However, after upgrading to the latest release (was using 3.3282.1741 previously [February 25, 2018 commit]), when I create a browser, there are two visual glitches during creation. First the browser background is gray, then part of it is black and then it is rendered with content. In the previous version the background was always white and no gray/black areas were shown.

What could be changed that causes this? I see that TChromiumWindow has a Color properly, but it can't be changed (the change won't stick).

Re: Browser background

Posted: Thu Jun 07, 2018 7:12 pm
by salvadordf
Please, check if any of the TChromiumWindow parents uses the "doublebuffer" property.
Some other users reported similar glitches when they used that property.

Make sure you set GlobalCEFApp.BackgroundColor in the DPR file too.

Re: Browser background

Posted: Thu Jun 07, 2018 8:37 pm
by petko
I have no DoubleBuffer property set anywhere.

The GlobalCEFApp.BackgroundColor helped though: if I set it to clWhite, the gray flicker no longer happens (interestingly, if I set it to clWindow, instead of gray, I get black).

The partial black flicker however remains. Even if I set a minimal html (for example <p>text</p>), there is a partial black flicker on the bottom of the chrome window on browser creation..

Re: Browser background

Posted: Fri Jun 08, 2018 7:05 am
by salvadordf
petko wrote: Thu Jun 07, 2018 8:37 pm I have no DoubleBuffer property set anywhere.
The GlobalCEFApp.BackgroundColor helped though: if I set it to clWhite, the gray flicker no longer happens (interestingly, if I set it to clWindow, instead of gray, I get black).
That property has a TCefColor type. Use this code to set it to white :

Code: Select all

GlobalCEFApp.BackgroundColor := CefColorSetARGB($FF, $FF, $FF, $FF);
petko wrote: Thu Jun 07, 2018 8:37 pm The partial black flicker however remains. Even if I set a minimal html (for example <p>text</p>), there is a partial black flicker on the bottom of the chrome window on browser creation..
This could be a Delphi redrawing issue. Do you see that flicker in the SimpleBrowser demo?

Re: Browser background

Posted: Fri Jun 08, 2018 1:27 pm
by petko
Yes, probably its Delphi-drawing issue, because I create the browser in a frame. I suspect that the problem is somewhere in the frame initialization. I was just wondering what could've changed in Cef4Delphi, because it was working without this glitch in the previous versions.

SimpleBrowser does not have this issue

Re: Browser background

Posted: Fri Jun 08, 2018 2:05 pm
by salvadordf
I did a quick check in the recent commits since February and there is one change that might result in different behavior.

I had to modify TCEFWindowParent.GetChildWindowHandle to avoid some problems creating popup browsers with CEF3. Now it checks that the component's handle is allocated before trying to use it, which would create the handle automatically.

That function is used when the component receives WM_ERASEBKGND so it could have a different behavior erasing the background before the component's handle is created.

If you create the frame in runtime, try calling TChromiumWindow.CreateHandle after you create TChromiumWindow and you set TChromiumWindow.parent.

It's also possible that Chromium has changed the way it draws the web contents.

Re: Browser background

Posted: Fri Jun 08, 2018 8:41 pm
by petko
The CreateHandle trick doesn't work, but I've found some hack that makes thing bearable for now. Thanks!

Re: Browser background

Posted: Wed Jul 15, 2020 12:07 pm
by tscheidegger
@petko
I encounter a similar problem with a frame created in runtime and I don't get it to draw.
You wrote "I've found some hack"
Could you share your it?