Skip to content

Commit

Permalink
Merge pull request #132 from cycjimmy/update-from-origin-jsmpeg
Browse files Browse the repository at this point in the history
Update from origin jsmpeg
  • Loading branch information
cycjimmy authored Sep 5, 2022
2 parents 1d10489 + 6a6fcc6 commit 37d115d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
8 changes: 8 additions & 0 deletions src/lib/webgl.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,14 @@ class WebGLRenderer {
throw new Error('Failed to get WebGL Context');
}

// WebGLRenderer.destroy() will explicitly lose the GL context. Calling
// .getContext('webgl') on a Canvas element whose GL context has previously
// been lost, will return an un-restored GL context. So we try to catch this
// case here and try restore the GL context.
if (this.gl.isContextLost()) {
this.gl.getExtension('WEBGL_lose_context').restoreContext();
}

this.canvas.addEventListener('webglcontextlost', this.handleContextLost.bind(this), false);
this.canvas.addEventListener(
'webglcontextrestored',
Expand Down
7 changes: 6 additions & 1 deletion src/lib/websocket.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,12 @@ export default class WSSource {
this.progress = 0;
this.established = false;

this.socket = new WebSocket(this.url, this.options.protocols || null);
if (this.options.protocols) {
this.socket = new WebSocket(this.url, this.options.protocols);
}
else {
this.socket = new WebSocket(this.url);
}
this.socket.binaryType = 'arraybuffer';
this.socket.onmessage = this.onMessage.bind(this);
this.socket.onopen = this.onOpen.bind(this);
Expand Down

0 comments on commit 37d115d

Please sign in to comment.