The OffscreenCanvas API currently has no available mechanism for running animations in a way that is synchronized with the display.
We basically need something to fulfill the role of requestAnimationFrame that can be used in workers. It cannot be as simple as exposing requestAnimationFrame in workers because the processing model of rAF is based on the fact that the main thread (the browsing context’s event loop) has a graphics update step, which is not the case in workers. There are also plenty of non-trivial use cases that need to thought of.
I’ve summarized various use cases, requirements, and solution ideas in this document: https://github.com/junov/OffscreenCanvasAnimation/blob/master/OffscreenCanvasAnimation.md
This is still an early draft. In the coming days, I will be actively editing that document to add more details and to list various arguments for and against the different ideas.
Please share you feedback.
Thanks,
Justin