Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Webgl Context Lost and not restored

I have a problem with webgl context lost/restored.

My application is very heavy with allot of information, graphs, lists, ... and map.

In the map i'm using webGL in order to get the best performances. My code is handling context lost and restored properly.

I'm starting a big operation that causes loading data from the server, parsing it,... This sometimes making the browser loose my webgl context. The problem is that the context is never restored. When I do again this big operation, then i got the restore event.

In my opinion it is related to memory and the garbage collector freeing time.

But I don't really know what to do, and how to solve this.

like image 969
Raziza O Avatar asked Oct 19 '22 18:10

Raziza O


1 Answers

An approach to handling the lost could be to recreate the canvas and re-initialize your application for the GL parts. In the end, all resources are gone, so the added overhead for context re-creation should not be too troubling and you can take action immediately when the webglcontextlost event arrived.

(not sure if that's the best idea though...)

Commenting on the Answer by Raziza regarding WEBGL_lose_context:

Don't use this one like you proposed there. This extension is merely a debugging tool and should only be used to simulate this behavior.

See also here: https://www.khronos.org/registry/webgl/extensions/WEBGL_lose_context/

like image 73
Matthias Avatar answered Oct 28 '22 19:10

Matthias