Hang with CEF129

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.

Hang with CEF129

Postby aligre » Wed Nov 06, 2024 11:39 am

Hello
we have migrated recently on CEF 129 and we see a serious hang when a CEF window is resized.
Our configuration is :
Offscreen mode
Message loop not in the main thread : CefSettings.multi_threaded_message_loop==1
OS : Windows 10
This is a regression from our previous configuration with CEF 125

I haven't reproduce the issue with cefclient but one point seems important :
in cefclient, CefRefPtr<CefBrowserHost>::WasResized is called in the CEF_UIT thread
(in file cef\tests\cefclient\browser\osr_window_win.cc)
while in our code its called in our main thread which is different from CEF_UIT.
So in our case, a task (calling CefRenderWidgetHostViewOSR::WasResized) is posted on CEF_UIT to be executed later and I've seen this can be long ...
Maybe there a lots of task to execute before ... For the moment I don't get why there is a such delay between the task post and the task execution.

If someone has any hint ...
Thanks
aligre
Techie
 
Posts: 39
Joined: Fri Apr 09, 2021 7:38 am

Re: Hang with CEF129

Postby magreenblatt » Wed Nov 06, 2024 12:07 pm

You can also try "cefclient --off-screen-rendering-enabled --multi-threaded-message-loop"
magreenblatt
Site Admin
 
Posts: 12809
Joined: Fri May 29, 2009 6:57 pm

Re: Hang with CEF129

Postby aligre » Wed Nov 06, 2024 12:17 pm

I've tested "cefclient --off-screen-rendering-enabled --multi-threaded-message-loop" and cefclient is as reactive as without "--multi-threaded-message-loop"
Is there a way to see with task are executed on UI thread ? maybe we're responsible of posting of a high number of tasks ...
aligre
Techie
 
Posts: 39
Joined: Fri Apr 09, 2021 7:38 am

Re: Hang with CEF129

Postby magreenblatt » Wed Nov 06, 2024 12:42 pm

Are you doing any blocking work on the UI thread (accessing files, acquiring locks, etc)? That's more likely to be an issue then a high volume of tasks.
magreenblatt
Site Admin
 
Posts: 12809
Joined: Fri May 29, 2009 6:57 pm

Re: Hang with CEF129

Postby aligre » Thu Nov 07, 2024 4:42 am

I haven't seen blocking tasks on the UI thread in our case.
I guess the task is actually executed but some conditions blocks the effective work, maybe a non focus criteria or something else.
I'll try to debug that
Also, with the CEF sample cefclient --off-screen-rendering-enabled --multi-threaded-message-loop
it does not reproduce the issue because CefRefPtr<CefBrowserHost>::WasResized is still called in the CEF_UIT thread so there is no task posted, the work is executed synchronuously.

Code: Select all
OsrWindowWin::OsrWndProc (tests\cefclient\browser\osr_window_win.cc)
...
OsrWindowWin::OnSize
...
ClientHandlerOsr::GetViewRect
aligre
Techie
 
Posts: 39
Joined: Fri Apr 09, 2021 7:38 am

Re: Hang with CEF129

Postby aligre » Fri Nov 08, 2024 6:50 am

Hi
With some traces in VS debugger, I saw that sometime, the execution "CefRenderWidgetHostViewOSR::WasResized" task is stopped quickly due to the following test at its beginning
Code: Select all
 if (hold_resize_) {
    if (!pending_resize_) {
      pending_resize_ = true;
    }
    return;
  }

then after the resize of the windows is not taking into account.
aligre
Techie
 
Posts: 39
Joined: Fri Apr 09, 2021 7:38 am

Re: Hang with CEF129

Postby amaitland » Fri Nov 08, 2024 4:31 pm

aligre wrote:Hi
With some traces in VS debugger, I saw that sometime, the execution "CefRenderWidgetHostViewOSR::WasResized" task is stopped quickly due to the following test at its beginning
Code: Select all
 if (hold_resize_) {
    if (!pending_resize_) {
      pending_resize_ = true;
    }
    return;
  }

then after the resize of the windows is not taking into account.


Having what I believe is the same issue that users are seeing in `CefSharp` starting in M127

https://github.com/cefsharp/CefSharp/is ... 2441118464

According to user report WasResized calls are no longer reliably triggering GetViewRect calls. Performing an action like scrolling redraws the window and it works correctly again.

I've been unable to reproduce this with cefclient to date, haven't reviewed the cefclient code to see how it's differing in behavior.
Maintainer of the CefSharp project.
amaitland
Virtuoso
 
Posts: 1315
Joined: Wed Jan 14, 2015 2:35 am

Re: Hang with CEF129

Postby aligre » Fri Nov 08, 2024 4:35 pm

Thanks

Some extra information from my last debug session :

Some steps I saw with debugger during the resize operations that are failing

A first call to WasResized set the hold_resize_ flag
Code: Select all
CefRenderWidgetHostViewOSR::WasResized {
  ... hold_resize_  = true;
  ... expected_size = handler->GetViewRect       
}

The OnPaint method is called (from the rendering process I assume)
this disables the flag because the current rendered image has the expected sizes
Code: Select all
CefRenderWidgetHostViewOSR::OnPaint(pixel_size) {
  handler->OnPaint
  if (hold_resize_ && pixel_size==expected_size)
    hold_resize_ = false
}


Sometimes OnPaint is called with pixel_size different from Expected_size,
then the hold_resize_ flag remains set and subsequent calls to CefRenderWidgetHostViewOSR::WasResized
have no effect
Code: Select all
CefRenderWidgetHostViewOSR::WasResized {
  if (hold_resize_)
    return
}

This results in the view not being updated.
The view can become correct again thanks to a subsequent OnPaint,
for example caused by a refresh (F5).
But it can also remain incorrect indefinitely if there is no new rendering calculation.

Now I don't know how to move forward: why is OnPaint not called with the right image size?
aligre
Techie
 
Posts: 39
Joined: Fri Apr 09, 2021 7:38 am

Re: Hang with CEF129

Postby aligre » Tue Nov 12, 2024 5:23 am

An issue is already opened on the same topic
https://github.com/chromiumembedded/cef/issues/3822

I've tested my application with "--disable-gpu" option and the issue "seems" not to be reproduced.
I don't know if the problem is completely eliminated or just less frequent.
aligre
Techie
 
Posts: 39
Joined: Fri Apr 09, 2021 7:38 am

Re: Hang with CEF129

Postby aligre » Tue Nov 12, 2024 3:34 pm

Based on official build of CEF, version 129.0.11+g57354b8+chromium-129.0.6668.90
I succeeded to reproduce this issue with cefclient, like indicated in issue #3822
launch "cefclient --off-screen-rendering-enabled --enable-gpu"
and open the file e:\index.html with the below html content.
Then, resize several time the cef window.
After few steps, the image is not updated with the last window size.

But I didn't reproduce the issue without the option "--enable-gpu"

Code: Select all
<!DOCTYPE html>
<html lang="fr">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Page full screen with border</title>
    <style>
        html, body {
            margin: 0;
            padding: 0;
            height: 100%;
            width: 100%;
            box-sizing: border-box;
        }

        body {
            border: 5px solid red; /* Bordure visible */
            display: flex;
            justify-content: center;
            align-items: center;
            font-family: Arial, sans-serif;
        }

        h1 {
            color: green;
        }
    </style>
</head>
<body>
    <h1>The page is full screen</h1>
     <script>
        document.addEventListener('dragstart', (event) => {
            event.preventDefault();
        });

        document.addEventListener('drop', (event) => {
            event.preventDefault();
        });
    </script>
</body>
</html>
aligre
Techie
 
Posts: 39
Joined: Fri Apr 09, 2021 7:38 am


Return to Support Forum

Who is online

Users browsing this forum: No registered users and 18 guests