Some iframes are rendered as grey rectangles

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.

Some iframes are rendered as grey rectangles

Postby Slvlan » Thu Jan 27, 2022 3:05 pm

CEF Version: 96.0.18+gfe551e4
Chromium Version: 96.0.4664.110

I'm using prebuild binaries and did not build CEF manually.
I'm using offscreen rendering.
JavaScript is enabled and functional.
I don't have any command-line switches enabled.

Problem:
Many iframes (but not all) only show as grey rectangles and can't be interacted with. This includes embedded YouTube videos, Google Maps, some ads, etc.

Example #1:
A very simple test iframe: http://pragma-engine.com/test_cef_iframe.php?example=1
This one works just fine when I load the URL with CEF:
Image

I can also interact with it (i.e. select the text).


Example #2:
A generic YouTube video embed: https://pragma-engine.com/test_cef_iframe.php?example=2
This one shows as a grey rectangle when loading it with CEF:
Image

The rectangle cannot be interacted with (i.e. it's not just a rendering issue, the video can't be started either).
Loading the video (https://www.youtube.com/embed/jNQXAC9IVRw) directly in CEF works just fine (including audio), so it's not a codec issue:
Image


Example #3:
An OpenStreetMap embed: http://pragma-engine.com/test_cef_iframe.php?example=3
Once again, it only shows up as a grey rectangle when trying to load it via CEF:
Image



Here are some of my settings:
Code: Select all
   CefSettings settings {};
   settings.windowless_rendering_enabled = true;
   settings.multi_threaded_message_loop = false;
   settings.uncaught_exception_stack_size = 1;
   settings.no_sandbox = true; // I've also tried setting this one to false, but the issue with the iframes remained
   CefString(&settings.cache_path).FromASCII("path/to/cache"); // (This isn't the actual path)
   CefString(&settings.browser_subprocess_path).FromASCII("path/to/subprocess.exe"); // (This isn't the actual path)
   [...]

   CefWindowInfo windowInfo;
   windowInfo.SetAsWindowless(nullptr);
   [...]

   CefBrowserSettings browserSettings;
   // Default browser settings
   [...]


I call CefDoMessageLoopWork approximately 60 times per second.


When loading Example #1, I'm not getting any output from CefDisplayHandler::OnConsoleMessage or BrowserRenderProcessHandler::OnUncaughtException.

When loading Example #2 I get the following output:
[0127/202859.290:WARNING:browser_info.cc(298)] Returning a speculative frame for 386547056645 [90,5]
[0127/202859.368:WARNING:browser_info.cc(298)] Returning a speculative frame for 386547056645 [90,5]
[0127/202859.369:WARNING:browser_info.cc(298)] Returning a speculative frame for 386547056645 [90,5]
[0127/202859.371:WARNING:browser_info.cc(298)] Returning a speculative frame for 386547056645 [90,5]
[0127/202859.371:WARNING:browser_info.cc(298)] Returning a speculative frame for 386547056645 [90,5]
OnConsoleMessage: [Lv:3] Error with Permissions-Policy header: Unrecognized feature: 'ch-ua-full-version-list'. [Src::0
[0127/202859.377:INFO:CONSOLE(0)] "Error with Permissions-Policy header: Unrecognized feature: 'ch-ua-full-version-list'.", source: (0)


When loading Example #3 I get the following output:
[0127/202829.281:WARNING:browser_info.cc(298)] Returning a speculative frame for 377957122053 [88,5]
[0127/202829.282:WARNING:browser_info.cc(298)] Returning a speculative frame for 377957122053 [88,5]
[0127/202829.283:WARNING:browser_info.cc(298)] Returning a speculative frame for 377957122053 [88,5]
[0127/202829.283:WARNING:browser_info.cc(298)] Returning a speculative frame for 377957122053 [88,5]
[0127/202829.284:WARNING:browser_info.cc(298)] Returning a speculative frame for 377957122053 [88,5]


I don't think any of these messages are related to the actual issue, however. I can load https://www.w3schools.com/html/html_iframe.asp in CEF just fine (including the iframe), but I also get a bunch of "Returning a speculative frame for..." for that one:
Image


Any tips or ideas would be much appreciated :) .
Slvlan
Newbie
 
Posts: 2
Joined: Thu Jan 27, 2022 2:38 pm

Re: Some iframes are rendered as grey rectangles

Postby magreenblatt » Thu Jan 27, 2022 7:15 pm

What OS? Does the problem reproduce with “cefclient --off-screen-rendering-enabled”?
magreenblatt
Site Admin
 
Posts: 12382
Joined: Fri May 29, 2009 6:57 pm

Re: Some iframes are rendered as grey rectangles

Postby Slvlan » Fri Jan 28, 2022 5:51 am

magreenblatt wrote:What OS? Does the problem reproduce with “cefclient --off-screen-rendering-enabled”?

I'm on Windows 10 x64. Adding that switch didn't change anything, however after a bunch of testing I found the cause of the problem:

I'm using a custom CefLoadHandler, which overrides the OnLoadStart and OnLoadEnd methods, and sends a process message from both:
Code: Select all
void BrowserLoadHandler::OnLoadStart(CefRefPtr<CefBrowser> browser,CefRefPtr<CefFrame> frame,TransitionType transition_type)
{
   browser->GetMainFrame()->SendProcessMessage(PID_BROWSER,CefProcessMessage::Create("LoadStart"));
}
void BrowserLoadHandler::OnLoadEnd(CefRefPtr<CefBrowser> browser,CefRefPtr<CefFrame> frame,int httpStatusCode)
{
   if(httpStatusCode == 200)
      browser->GetMainFrame()->SendProcessMessage(PID_BROWSER,CefProcessMessage::Create("LoadComplete"));
}

I'm not actually using those messages anymore, so I got rid of the SendProcessMessage calls and that fixed the problem, although I'm not entirely sure why...
Slvlan
Newbie
 
Posts: 2
Joined: Thu Jan 27, 2022 2:38 pm

Re: Some iframes are rendered as grey rectangles

Postby dmo » Fri Feb 10, 2023 8:37 am

Sorry, for the necromancy.

I stumbled on the same problem with the grey rectangles in my project.

I found out that the render process was crashing for that frame when it was hosted on a different origin.

On further inspection with gdb (great resource btw.: https://github.com/huningxin/chromium/b ... bugging.md ) I could pinpoint it also to my messaging system and found that browser->GetMainFrame() returns NULL (as documented so definitely on me) in e.g. a CORS context.

Doc Snippet:
In the renderer process this will return NULL if the main frame is hosted in a different renderer process (e.g. for cross-origin sub-frames)


So in short, null pointer dereference in a renderer subprocess leads to subprocess crash.

Maybe if someone stumbles on this in the future it will be helpful.
dmo
Newbie
 
Posts: 1
Joined: Fri Feb 10, 2023 8:26 am


Return to Support Forum

Who is online

Users browsing this forum: No registered users and 28 guests