Capture context lost error


(Eriol726) #1

Hi, I wonder if there is a way to control if the viewer has lost its context? My first thought was to catch the canvas element from the iframe and then do canvas.addEventListener('webglcontextlost', function (e) { console.log (e); }, false);
But I can’t access the Iframe child because of CORS policy.
My second idea was to capture the warning message “webgl context lost” when it appears. But that message is returned from the “vendors” script which isn’t loaded in my app and then I cannot reach that eighter. My last idea was to check if the viewer stops when then the web-gl context get lost by using the api function api.addEventListener('viewstop') but this event doesn’t fire even if the viewer stops rendering. So I have no idea how I can capture the context lost error in the code.


(Paul Sketch) #2

Hi,

We do not fire any event in this case.
We could though I’m not sure what you could do with it ?


(Eriol726) #3

Hi Paul.
I’m developing a AngularJs app to view different sketchfab models. If I’m loading about 7-9 models and start the viewers, this error can appear within a few hours. If it appears I want to restart the browser and reload the page. I can do that by running a test with Protractor. If I can change a state in my viewer app when the error appears I can capture it in the test and restart the browser.


(Shaderbytes) #4

why not just hard code a time cycle to reload every few hours , regardless of if an error occurred or not.


(Eriol726) #5

That is one solution but I want the app to reload directly after the error occurred, otherwise the app will be unusable until the time the page is reloaded.