You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm using JSMpeg using websockets. Player works fine the first time using a webSocket URL. I then I call player.destroy() which works fine.
BUT when I try to call JSMpeg.Player(webSocketURL, options) again I get the following error:
host-report-errors.js?44de:6 Unhandled promise rejection TypeError: Cannot read properties of null (reading 'restoreContext')
at new WebGLRenderer (jsmpeg.js?bbb2:4180:1)
at new Player (jsmpeg.js?bbb2:325:1)
at SourceView.setupNewPlayer (source-view.js?0110:260:1)
at eval (source-view.js?0110:326:1)
at eval (es.promise.js?e6cf:107:1)
I've gone into the code and commented out the renderer.destroy() and it works fine:
Turns out, explicitly calling gl.getExtension('WEBGL_lose_context').loseContext() to destroy the WebGL context is not a good idea. loseContext() should only be used to "simulate" the glcontextlost event. So I have removed this functionality from the WebGL .destroy() method.
Furthermore, the canvas element is only removed from the document when calling .destroy() if it was created by the renderer. If the canvas element was handed over to the renderer (through the options.canvas in the Player constructor), it is left alone.
So, with this you can destroy() and re-create a JSMpeg.Player with the same canvas element, provided that it uses the same rendering method (2d or WebGL) as before.
I figured there was probably more to it. I've been testing these changes and so far so good. I haven't noticed any issues. Thank you for your help and efforts!!
I'm using JSMpeg using websockets. Player works fine the first time using a webSocket URL. I then I call player.destroy() which works fine.
BUT when I try to call JSMpeg.Player(webSocketURL, options) again I get the following error:
I've gone into the code and commented out the renderer.destroy() and it works fine:
This is what my instantiation of the player looks like:
Is there some other way I should be doing this?
The text was updated successfully, but these errors were encountered: