CefRenderHandler::OnPaint called with stale pixels

Having problems with building or using CEF's C/C++ APIs? This forum is here to help. Please do not post bug reports or feature requests here.

CefRenderHandler::OnPaint called with stale pixels

Postby callum » Wed Jan 24, 2018 9:18 pm

Latest Win64 CEF and testing ability of embedded browser in my OSR app to change size - playing a YouTube video as a test.

As I vigorously resize the embedded browser, it normally continues to play correctly but sometimes the updated pixels from the still playing video fail to arrive in my CefRenderHandler::OnPaint override. I capture a hash of the pixels each time and when visually, the video appears to freeze (audio still playing) the hash stays constant.

Resizing again usually puts things back to normal and I see a different hash each frame as expected.

The unpredictable nature suggests a race condition somewhere.

I resize the embedded browser by making the new size available to CefRenderHandler::GetViewRect..) then calling CefBrowser:: GetHost()::WasResized();

Maybe another way to phrase this is : What would cause CefRenderHandler::OnPaint(...) to be called but with bad data ?
callum
Expert
 
Posts: 326
Joined: Mon Feb 23, 2015 6:19 pm

Re: CefRenderHandler::OnPaint called with stale pixels

Postby amaitland » Wed Jan 24, 2018 9:55 pm

The changes in https://bitbucket.org/chromiumembedded/ ... ce-for-osr were merged late last year.

Rather than saying your using the latest version, please specify the exact version you are using.
Maintainer of the CefSharp project.
amaitland
Virtuoso
 
Posts: 1292
Joined: Wed Jan 14, 2015 2:35 am

Re: CefRenderHandler::OnPaint called with stale pixels

Postby callum » Wed Jan 24, 2018 10:24 pm

Version 3.3239.1723.g071d1c1 Windows 64.
callum
Expert
 
Posts: 326
Joined: Mon Feb 23, 2015 6:19 pm

Re: CefRenderHandler::OnPaint called with stale pixels

Postby amaitland » Wed Jan 24, 2018 10:33 pm

Thanks.

Do you have a sample YouTube video that highlights the problem? I'm guessing that with some videos the issue will be more pronounced than others or will any old video do?
Maintainer of the CefSharp project.
amaitland
Virtuoso
 
Posts: 1292
Joined: Wed Jan 14, 2015 2:35 am

Re: CefRenderHandler::OnPaint called with stale pixels

Postby callum » Wed Jan 24, 2018 10:40 pm

The one I have been using to test is https://www.youtube.com/watch?v=h4rZE_J1beA

I feel like it must be something in my code - next step is to write a standalone test that illustrates it happening.
callum
Expert
 
Posts: 326
Joined: Mon Feb 23, 2015 6:19 pm

Re: CefRenderHandler::OnPaint called with stale pixels

Postby amaitland » Wed Jan 24, 2018 10:48 pm

Looks like a bug, reproduces with `cefclient --multi-threaded-message-loop --off-screen-rendering-enabled`
Maintainer of the CefSharp project.
amaitland
Virtuoso
 
Posts: 1292
Joined: Wed Jan 14, 2015 2:35 am

Re: CefRenderHandler::OnPaint called with stale pixels

Postby callum » Wed Jan 24, 2018 10:53 pm

Well that's a surprise - thank you for taking the time to look.

I didn't even think to bother trying cefclient - I'm working in macOS right now but once I'm done, I'll switch my laptop over to Windows and try it.

Actually, I'll try it in macOS too - see if it's OS specific.

Thank you.
callum
Expert
 
Posts: 326
Joined: Mon Feb 23, 2015 6:19 pm

Re: CefRenderHandler::OnPaint called with stale pixels

Postby callum » Wed Jan 24, 2018 11:05 pm

Wasn't able to repo on macOS (10.13) with same build of cefclient.

Repro's readily on Windows cefclient though as you said (I'm not using multi-threaded message loop).

Also repros on other YouTube videos like this one: https://www.youtube.com/watch?v=r2LpOUwca94 - so it's not something special about the first URL.

Should I file a bug? Happy to if you point me at the right place.

Thank you again - I've been tearing my hair out for the last couple of days with this.
callum
Expert
 
Posts: 326
Joined: Mon Feb 23, 2015 6:19 pm

Re: CefRenderHandler::OnPaint called with stale pixels

Postby callum » Fri Jan 26, 2018 4:57 pm

callum
Expert
 
Posts: 326
Joined: Mon Feb 23, 2015 6:19 pm

Re: CefRenderHandler::OnPaint called with stale pixels

Postby salvadordf » Sat Jan 27, 2018 6:58 am

If you are using an external message pump you may need to create a message loop that handles all cases.

These are the comments in /tests/shared/browser/main_message_loop_external_pump.h
Code: Select all
// This MessageLoop implementation simulates the embedding of CEF into an
// existing host application that runs its own message loop. The scheduling
// implementation provided by this class is very simplistic and does not handle
// all cases (for example, nested message loops on Windows will not function
// correctly). See comments in Chromium's platform-specific
// base/message_loop/message_pump_* source files for additional guidance when
// implementing CefBrowserProcessHandler::OnScheduleMessagePumpWork() in your
// application. Run cefclient or ceftests with the
// "--external-message-pump" command-line flag to test this mode.


I originally translated most of that code to Delphi (Windows) to include it in CEF4Delphi but there were some reentrancy problems moving and resizing one of the demos so I had to make some modifications to that code.
Maintainer of the CEF4Delphi, WebView4Delphi, WebUI4Delphi and WebUI4CSharp projects.
User avatar
salvadordf
Expert
 
Posts: 129
Joined: Sun Dec 18, 2016 8:39 am
Location: Spain

Next

Return to Support Forum

Who is online

Users browsing this forum: Google [Bot] and 46 guests