When can a (WebGL) context be lost

#1

Hello

I am trying to change my code to be able to recover from lost contexts.

However, it’s a PITA to change the code everytime the context is used.

My question : can the context be lost in the MIDDLE of a frame rendering, or can I assume that once the context is successfuly made current, It will not be lost unless the next webglcontextlost event?

That is, can I simply do this :

  • set a flag that ensures webGL is not used after a webglcontextlost event
  • inside the webglcontextrestored handler, recreate all the shaders, … and clear the above flag.

?
The thing is, I am afraid that the context could get lost inside my event loop. “Ruggedizing” my code against these random context losses would be is a much bigger challenge!

Thanks for your help