SendExternalBeginFrame Synchronization

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.

SendExternalBeginFrame Synchronization

Postby pwsynth » Thu Jun 29, 2023 8:46 am

Hello,

I previously asked about SendExternalBeginFrame, but now I have a better idea of what needs to happen, so I'm making a new post with a better phrased question.

My application is using CefRunMessageLoop, which causes CEF to internally update until Javascript hits requestAnimationFrame as external_begin_frame_enabled is true.

So from a separate thread I call SendExternalBeginFrame to cause the Javascript to advance. However, the problem is this thread just spins in a loop calling SendExternalBeginFrame over and over regardless of if the Javascript is waiting on requestAnimationFrame or not.

Putting a sleep of 16ms between SendExternalBeginFrame calls causes mostly the correct behavior, but obviously this is extremely hacky, the render could take more than 16ms, or the waiting could be unnecessarily long. Also a Javascript function can call back to native just before requestAnimationFrame to set a flag indicating a BeginFrame is needed, however this is also hacky since the render process could concurrently be busy with graphics API calls so this method does not synchronize with OnPaint.

So my question is, is there a way I can know Javascript is waiting on another BeginFrame call? Or can an OnPaint be guranteed once per a SendExternalBeginFrame another way?

Using an external message loop I have the same problem, I don't know if CefDoMessageLoopWork is complete.
pwsynth
Newbie
 
Posts: 2
Joined: Mon Jun 26, 2023 9:37 am

Re: SendExternalBeginFrame Synchronization

Postby pwsynth » Thu Jun 29, 2023 11:06 am

It looks as if it's not currently possible to tell if the message loop is idle.

https://github.com/chromiumembedded/cef ... ump_win.cc

Code: Select all
  // We need to run the message pump until it is idle. However we don't have
  // that information here so we run the message loop "for a while".
  for (int i = 0; i < 10; ++i) {
    // Do some work.
    CefDoMessageLoopWork();

    // Sleep to allow the CEF proc to do work.
    Sleep(50);
  }


Unless anybody else has worked it out before I will start looking in to possible ways to hook this up.
pwsynth
Newbie
 
Posts: 2
Joined: Mon Jun 26, 2023 9:37 am


Return to Support Forum

Who is online

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