manubb / Leaflet.PixiOverlay

Bring Pixi.js power to Leaflet maps
MIT License
478 stars 86 forks source link

WebGL: CONTEXT_LOST error #80

Closed RoboVij closed 2 years ago

RoboVij commented 2 years 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 2 years ago

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