Question for CefRenderHandler::OnPaint

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.

Question for CefRenderHandler::OnPaint

Postby JokerLD » Wed Apr 07, 2021 2:27 am

I am little confused about the CefRenderHandler::OnPaint function, does every time when chromium doing paint in its render pipeine, the OnPaint function get called synchronously?
In my project, I opened one single website, and execuate JS code to play animation, then get frame data from the OnPaint function, it seems that after one animation update, the OnPaint function get called one or more times. And the timing of OnPaint callback is not consistent with the paint of chromium.
In order to get one frame after I do one time JS animation update, I register CefMessageRouterBrowserSide::Handler.
My logic is
(1) I execuate JS function to update one frame by calling CefFrame::ExecuteJavaScript in Cpp side.
(2) After the JS function completed updating one frame, it will call sendMessage to send a message to Cpp side
(3) I get frame data from OnPaint function, but the OnPaint function may be called multiple times so I get one or more frames after one update.
(4) I receive message from the JS side, then I know that one update is completed, so I will start next update which means we will go back to (1)

I open the same website in chrome, and use performance tools to see the execuation order. And just like the image shows below.

As the image shows, it will first seek(the animation update function), then paint, composite and finally sendmessage to the cpp side. So I assume that OnPaint shall be called before receiving message. However, I found that in my code the OnPaint functions were always being called after I received message from JS side. And that cause my frame update logic messed up, because I don't know the exact time of the completion of the frame update.

So could someone help explain the when and how OnPaint function being called?
Attachments
onpaint2.png
onpaint2.png (165.83 KiB) Viewed 1775 times
JokerLD
Newbie
 
Posts: 3
Joined: Tue Mar 30, 2021 10:12 pm

Re: Question for CefRenderHandler::OnPaint

Postby magreenblatt » Wed Apr 07, 2021 8:56 am

magreenblatt
Site Admin
 
Posts: 12382
Joined: Fri May 29, 2009 6:57 pm


Return to Support Forum

Who is online

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