Hi everyone,
Note: this post is a copy of this issue, but I couldn't post here due to an account creation issue.
I’ve derived the cef_simple example to implement offscreen rendering in a restapi.
The webpage I’m trying to capture renders asynchronously, through some JS code. It renders one or several canvas, with a few html elements overlaid on top.
The JS code can notify me when all the canvas/html elements have been drawn/updated, which allows me to trigger a JS callback, which in turn raises a flag to tell my RenderHandler that on the next OnPaint() it needs to copy the provided buffer, and finally calls Invalidate(PET_VIEW) in order to trigger a repaint.
OnPaint() is indeed triggered, the buffer and the one dirty region have the same expected size (usually 1024x1024).
The content of the buffer might however be incorrect: the canvas and/or the html elements might not have been rendered, or the buffer can be partially filled with random noise.
It happens approx. 15% of the time, it looks like its linked to my server’s load.
I’ve tried wrapping my JS callback in requestAnimationFrame, but that does not seems to have any effect (which might actually be expected, since requestAnimationFrame is there to ensure some code is executed before the next repaint, while I’m trying to notify CEF that everything has been painted).
The only solution I found is to delay my JS callback with setTimeout(), but even with a 250ms delay I can still get some incorrect results (and obviously I would like to avoid such delay).
Is there something I need to do to ensure the buffer is completely repainted?
CEF versions : 97.1.9, 98.1.0, 98.1.19, 98.2.0, 98.2.1, 99.2.7 (will try some older versions).
Running in a Docker container, on Linux, with no GPU available.