I measured this by inserting a Date.now() timestamp in a div in the webpage and comparing this time in the rendered frame to a timestamp generated in the C++ OnAcceleratedPaint() with chrono::system_clock::now().time_since_epoch().
Results are ~60-100 milliseconds of latency between when the frame is rendered by CEF to when I receive the callback. This occurs with multi-threaded message loop on or off. With it off I tried pumping CefDoMessageLoopWork() more frequently (every 2ms) but it made no difference.
Any ideas on how to reduce this or is it an issue with OSR? Thanks!
Method:
I added a custom <Framestamp> React element that updates a <div> with Date.now() every 5 seconds. This triggers a CEF render and a call to OnAccelleratedPaint(). I compared the timestamp rendered to the frame by React with the chrono::system_clock::now().time_since_epoch() in the callback on the C++ side, i.e. when the native app is notified by CEF of the frame.
- Code: Select all
468 TaCefBrowserRenderer::onAcceleratedPaint at time: 1630589012894
Type: View
Rect: 0, 0, 3000, 1800
469 TaCefBrowserRenderer::onAcceleratedPaint at time: 1630589012910
Type: View
Rect: 2563, 23, 170, 29
470 TaCefBrowserRenderer::onAcceleratedPaint at time: 1630589012911
Type: View
Rect: 0, 0, 3000, 1800
Results:
For each div update, for some reason I get 3-4 callbacks to OnAccelleratedPaint. One dirty rect is the div area and the others are the entire CEF window.
So in the above sample the latency is:
1630589012894 - 1630589012825 = 69 ms
1630589012910 - 1630589012825 = 85 ms
1630589012911 - 1630589012825 = 86 ms
Note this is with CEF 75.1.4+g4210896+chromium-75.0.3770.100 with OSR.