Page 1 of 1

customize browser_background_color causes a flash white

PostPosted: Thu Aug 03, 2017 10:42 am
by shangyi
hi,
When I customize the CEFClient's browser_background_color_ to CefColorSetARGB(255, 0, 0, 255), it causes a flash white after the rootWindow is created.

IN "CefBrowserViewImpl.h" it only change the resizeBackgroundColor, and in "view_view.h" the backgroundColr is set to be white and not changed after.

I wonder if there already had a way to change the browser's backgroundColor without flashing white, or could privide one, thanks for your kind help.

1. cef/libcef/browser/views/browser_view_impl.cc

void CefBrowserViewImpl::SetBackgroundColor(cef_color_t color) {
CEF_REQUIRE_VALID_RETURN_VOID();
ParentClass::SetBackgroundColor(color);
if (root_view())
root_view()->SetResizeBackgroundColor(color);
}

2. libcef "view_view.h"

virtual void Initialize() {
// Use our defaults instead of the Views framework defaults.
ParentClass::set_background(views::Background::CreateSolidBackground(
view_util::kDefaultBackgroundColor));
}

3.chromium / experimental / chromium / src / refs/wip/bajones/webvr / . / ui / views / controls / native / native_view_host.cc
void NativeViewHost::OnPaint(gfx::Canvas* canvas) {
// Paint background if there is one. NativeViewHost needs to paint
// a background when it is hosted in a TabbedPane. For Gtk implementation,
// NativeTabbedPaneGtk uses a NativeWidgetGtk as page container and because
// NativeWidgetGtk hook "expose" with its root view's paint, we need to
// fill the content. Otherwise, the tab page's background is not properly
// cleared. For Windows case, it appears okay to not paint background because
// we don't have a container window in-between. However if you want to use
// customized background, then this becomes necessary.
OnPaintBackground(canvas);
// The area behind our window is black, so during a fast resize (where our
// content doesn't draw over the full size of our native view, and the native
// view background color doesn't show up), we need to cover that blackness
// with something so that fast resizes don't result in black flash.
//
// It would be nice if this used some approximation of the page's
// current background color.
if (native_wrapper_->HasInstalledClip())
canvas->FillRect(GetLocalBounds(), resize_background_color_);
}


thx

Re: customize browser_background_color causes a flash white

PostPosted: Thu Aug 03, 2017 11:07 am
by magreenblatt
What OS and CEF version are you using?

Re: customize browser_background_color causes a flash white

PostPosted: Thu Aug 03, 2017 9:04 pm
by shangyi
hi,

OS: win7
CEF version: cef_binary_3.3071.1649.g98725e6_windows32

it did not work when i customize browser_background_color to CefColorSetARGB(255, 19, 34, 34)[In "qbbrowser/browser/main_context_impl.h"].

I also set the "settings.background_color = CefColorSetARGB(255, 19, 34, 34);" after "MainContext::Get()->PopulateBrowserSettings(&settings);".

But browser_window_'s background-color is still white when loading url. If document's background-color is set to be transparent(like about:blank page), the browser shows a white page.

I wonder how to custom browser_background_color in a right way for windows.


thx

Re: customize browser_background_color causes a flash white

PostPosted: Thu Nov 16, 2017 5:57 am
by bobogavin
I has the same problem, it will show a flash white background when loading even if I set CefSettings.background_color

Re: customize browser_background_color causes a flash white

PostPosted: Fri Nov 17, 2017 3:16 pm
by callum
I'd also like to solve this - we are trying to make the web component as seamless as possible with the rest of the UI and that white flash doesn't help at all.

I saw a solution for a much older version of CEF that had a setting to change the default style sheet. Not available now but perhaps there is a different way to do that now.

I'll investigate.

Re: customize browser_background_color causes a flash white

PostPosted: Fri Nov 17, 2017 3:30 pm
by magreenblatt
Are you seeing the white flash with 3202 on Windows?

Re: customize browser_background_color causes a flash white

PostPosted: Fri Nov 17, 2017 4:25 pm
by callum
No!

It's quite an arduous sequence of steps to go from the code in my test framework to the place it's used in our product so I wanted to sort the crash on exit I mentioned in another thread before I did that.

However, after seeing your question, I hacked it in by hand and no more white flash. Makes such a big difference to the feel of the UI.

Thank you.