manubb / Leaflet.PixiOverlay

Bring Pixi.js power to Leaflet maps
MIT License
474 stars 84 forks source link

WebGL: CONTEXT_LOST error #80

Closed RoboVij closed 1 year ago

RoboVij commented 1 year ago

How to solve the WebGL: CONTEXT_LOST_WEBGL: loseContext: context lost error? The webpage crashes, it goes blank and freezes. This happens after switching between tabs a few times. Mostly happens in Chrome and Edge but not in Firefox. I came across a few forums suggesting to use something like this:

var canvas = document.getElementById("myCanvas");
canvas.addEventListener("webglcontextlost", function(event) {
    event.preventDefault();
}, false);

canvas.addEventListener(
    "webglcontextrestored", setupWebGLStateAndResources, false);

I tried but I'm failing to implement it. Is this supposed to be done on my side or in the plugin or Pixi.js? Help is much appreciated.

manubb commented 1 year ago

This is handled on Pixi.js side. Consider reporting the problem in pixi's issues.