How to listen for this event to end? WebGLRenderer.restoreContext()

How to listen for this event to end?

.restoreContext If there is a .then method is the best , I can know when the event is end,and do my work

You can listen for webglcontextrestored: WebGL Specification

I do this

    const gl = this.renderer.getContext();
    if (gl && gl.getExtension('WEBGL_lose_context')) {


I can then run some setup on boundOnWebGLContextRestored which is bound to my webglapp class.

Thank you for your answer.restoredContext It will take some time, which seems impossible to capture, and the screen will be white for a period of time.
It will block the process of the JavaScript

What’s your use case?

It’s not something that should happen in the normal execution of your app.
The process involves ‘awaiting a restorable render buffer’ so yes it will take some time.

In a single page application I leave the current route and execute the forceContextLoss method and in returning to this route I execute forceContextRestored to recover the rendering of webgl.

In the process of forceContextRestored, because the volume of the model is a little large, there will be a 3s white screen, but this is better than 10s for reloading those models.

The current problem is that the 3s white screen, which will block the JavaScript process, causing the web page not to appear until the end of the white screen.