exokitxr / exokit

Native VR/AR/XR engine for JavaScript 🦖

Home Page:https://exokit.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Websocket close is crashing Exokit

bknill opened this issue · comments

I'm using Redux and in the code base is the Redux enhancer which uses a websocket for debugging.

I've tried commenting it out with some success.. however this isn't ideal and if I try and test for Exokit before running it still tries to set up the Websocket connection, and crashes with this error:

uncaught exception: Error: WebSocket was closed before the connection was established
    at WebSocket.close (/home/owner/workspace/client/exokit/node_modules/ws/lib/websocket.js:217:14)
    at WebSocketTransport.push../node_modules/sockjs-client/lib/transport/websocket.js.WebSocketTransport.close (https://localhost:3000/static/js/7.chunk.js:478842:8)
    at SockJS.push../node_modules/sockjs-client/lib/main.js.SockJS._transportTimeout (https://localhost:3000/static/js/7.chunk.js:476435:23)
    at listOnTimeout (internal/timers.js:533:17)
    at processTimers (internal/timers.js:475:7)

This is deep in the Redux code, is there anyway to handle this in Exokit to stop the crash?

This looks like it's not Exokit crashing -- Exokit is catching the error.

This might be a bug in Exokit though, if this throw is non-standard behavior. I'll look into this. Thanks for filing!

Indeed, I think this should be a non-throwing case, but it throws in Exokit:

c = new WebSocket('ws://lol.com');
c.close();

@bknill Could you try #1388 to see if it handles this issue?

The error has changed but the crash appears to be more serious

core:a-node:error Failure loading node:   TypeError: ctx.setGrContext is not a function
    at _onGl2DConstruct (/home/owner/workspace/client/exokit/src/native-bindings.js:435:9)
    at new CanvasRenderingContext2D (/home/owner/workspace/client/exokit/src/native-bindings.js:456:5)
    at HTMLCanvasElement.getContext (/home/owner/workspace/client/exokit/src/DOM.js:2557:23)
    at setup (https://localhost:3000/static/js/7.chunk.js:64257:36)
    at NewComponent.init (https://localhost:3000/static/js/7.chunk.js:64229:13)
    at NewComponent.initComponent (https://localhost:3000/static/js/7.chunk.js:69876:16)
    at NewComponent.updateProperties (https://localhost:3000/static/js/7.chunk.js:69856:18)
    at HTMLElement.value (https://localhost:3000/static/js/7.chunk.js:68371:25)
    at HTMLElement.value (https://localhost:3000/static/js/7.chunk.js:71553:49)
    at HTMLElement.value (https://localhost:3000/static/js/7.chunk.js:68343:20)
    at entityLoadCallback (https://localhost:3000/static/js/7.chunk.js:68104:20)
    at emitLoaded (https://localhost:3000/static/js/7.chunk.js:69171:19)
    at runNextTicks (internal/process/task_queues.js:55:5)
    at processTimers (internal/timers.js:472:9)
Error: WebSocket was closed before the connection was established
    at WebSocket.close (/home/owner/workspace/client/exokit/node_modules/ws/lib/websocket.js:217:14)
    at WebSocket.close (/home/owner/workspace/client/exokit/src/WindowBase.js:184:24)
    at WebSocketTransport.push../node_modules/sockjs-client/lib/transport/websocket.js.WebSocketTransport.close (https://localhost:3000/static/js/7.chunk.js:478867:8)
    at SockJS.push../node_modules/sockjs-client/lib/main.js.SockJS._transportTimeout (https://localhost:3000/static/js/7.chunk.js:476460:23)
    at listOnTimeout (internal/timers.js:533:17)
    at processTimers (internal/timers.js:475:7)

Thanks, that looks like progress. I can't tell from this why the Canvas2D would be uninitialized however.

Are you able to console.log(ctx) on this line?

nativeWindow.setCurrentWindowContext(windowHandle);

Do I need to rebuild exokit with this change?

If it's on Linux then no rebuild needed, it should just be a JS file change. 👍

Its not even starting at the moment.

unhandled rejection: TypeError: nativeWindow.hasCurrentWindowContext is not a function
    at _waitLocalSyncs (/home/owner/workspace/client/exokit/src/Window.js:1037:24)
    at Array._renderLocal (/home/owner/workspace/client/exokit/src/Window.js:1156:13)
    at _recurse (/home/owner/workspace/client/exokit/src/Window.js:1171:19)
    at /home/owner/workspace/client/exokit/src/Window.js:1185:5
    at new Promise (<anonymous>)
    at _render (/home/owner/workspace/client/exokit/src/Window.js:1167:39)
    at window.tickAnimationFrame (/home/owner/workspace/client/exokit/src/Window.js:1191:12)
    at global.onrunasync (/home/owner/workspace/client/exokit/src/Window.js:1351:21)
    at MessagePort.<anonymous> (/home/owner/workspace/client/exokit/src/WindowBase.js:320:45)
    at MessagePort.emit (events.js:196:13)

Took that console log out and get this far:

ore:a-node:error Failure loading node:   TypeError: ctx.setGrContext is not a function
    at _onGl2DConstruct (/home/owner/workspace/client/exokit/src/native-bindings.js:436:9)
    at new CanvasRenderingContext2D (/home/owner/workspace/client/exokit/src/native-bindings.js:457:5)
    at HTMLCanvasElement.getContext (/home/owner/workspace/client/exokit/src/DOM.js:2557:23)
    at NewShader.init (https://localhost:3000/static/js/4.chunk.js:883:31)
    at NewComponent.updateShader (https://localhost:3000/static/js/4.chunk.js:62334:26)
    at NewComponent.update (https://localhost:3000/static/js/4.chunk.js:62258:18)
    at NewComponent.initComponent (https://localhost:3000/static/js/4.chunk.js:69884:16)
    at NewComponent.updateProperties (https://localhost:3000/static/js/4.chunk.js:69856:18)
    at HTMLElement.value (https://localhost:3000/static/js/4.chunk.js:68371:25)
    at HTMLElement.value (https://localhost:3000/static/js/4.chunk.js:68343:20)
    at entityLoadCallback (https://localhost:3000/static/js/4.chunk.js:68104:20)
    at emitLoaded (https://localhost:3000/static/js/4.chunk.js:69171:19)
    at processTicksAndRejections (internal/process/task_queues.js:89:5)
core:a-node:error Failure loading node:   TypeError: ctx.setGrContext is not a function
    at _onGl2DConstruct (/home/owner/workspace/client/exokit/src/native-bindings.js:436:9)
    at new CanvasRenderingContext2D (/home/owner/workspace/client/exokit/src/native-bindings.js:457:5)
    at HTMLCanvasElement.getContext (/home/owner/workspace/client/exokit/src/DOM.js:2557:23)
    at NewShader.init (https://localhost:3000/static/js/4.chunk.js:883:31)
    at NewComponent.updateShader (https://localhost:3000/static/js/4.chunk.js:62334:26)
    at NewComponent.update (https://localhost:3000/static/js/4.chunk.js:62258:18)
    at NewComponent.initComponent (https://localhost:3000/static/js/4.chunk.js:69884:16)
    at NewComponent.updateProperties (https://localhost:3000/static/js/4.chunk.js:69856:18)
    at HTMLElement.value (https://localhost:3000/static/js/4.chunk.js:68371:25)
    at HTMLElement.value (https://localhost:3000/static/js/4.chunk.js:68343:20)
    at entityLoadCallback (https://localhost:3000/static/js/4.chunk.js:68104:20)
    at emitLoaded (https://localhost:3000/static/js/4.chunk.js:69171:19)
    at processTicksAndRejections (internal/process/task_queues.js:89:5)
core:a-node:error Failure loading node:   TypeError: ctx.setGrContext is not a function
    at _onGl2DConstruct (/home/owner/workspace/client/exokit/src/native-bindings.js:436:9)
    at new CanvasRenderingContext2D (/home/owner/workspace/client/exokit/src/native-bindings.js:457:5)
    at HTMLCanvasElement.getContext (/home/owner/workspace/client/exokit/src/DOM.js:2557:23)
    at NewShader.init (https://localhost:3000/static/js/4.chunk.js:883:31)
    at NewComponent.updateShader (https://localhost:3000/static/js/4.chunk.js:62334:26)
    at NewComponent.update (https://localhost:3000/static/js/4.chunk.js:62258:18)
    at NewComponent.initComponent (https://localhost:3000/static/js/4.chunk.js:69884:16)
    at NewComponent.updateProperties (https://localhost:3000/static/js/4.chunk.js:69856:18)
    at HTMLElement.value (https://localhost:3000/static/js/4.chunk.js:68371:25)
    at HTMLElement.value (https://localhost:3000/static/js/4.chunk.js:68343:20)
    at entityLoadCallback (https://localhost:3000/static/js/4.chunk.js:68104:20)
    at emitLoaded (https://localhost:3000/static/js/4.chunk.js:69171:19)
    at processTicksAndRejections (internal/process/task_queues.js:89:5)
core:a-node:error Failure loading node:   TypeError: ctx.setGrContext is not a function
    at _onGl2DConstruct (/home/owner/workspace/client/exokit/src/native-bindings.js:436:9)
    at new CanvasRenderingContext2D (/home/owner/workspace/client/exokit/src/native-bindings.js:457:5)
    at HTMLCanvasElement.getContext (/home/owner/workspace/client/exokit/src/DOM.js:2557:23)
    at NewShader.init (https://localhost:3000/static/js/4.chunk.js:883:31)
    at NewComponent.updateShader (https://localhost:3000/static/js/4.chunk.js:62334:26)
    at NewComponent.update (https://localhost:3000/static/js/4.chunk.js:62258:18)
    at NewComponent.initComponent (https://localhost:3000/static/js/4.chunk.js:69884:16)
    at NewComponent.updateProperties (https://localhost:3000/static/js/4.chunk.js:69856:18)
    at HTMLElement.value (https://localhost:3000/static/js/4.chunk.js:68371:25)
    at HTMLElement.value (https://localhost:3000/static/js/4.chunk.js:68343:20)
    at entityLoadCallback (https://localhost:3000/static/js/4.chunk.js:68104:20)
    at emitLoaded (https://localhost:3000/static/js/4.chunk.js:69171:19)
    at processTicksAndRejections (internal/process/task_queues.js:89:5)
core:a-node:error Failure loading node:   TypeError: ctx.setGrContext is not a function
    at _onGl2DConstruct (/home/owner/workspace/client/exokit/src/native-bindings.js:436:9)
    at new CanvasRenderingContext2D (/home/owner/workspace/client/exokit/src/native-bindings.js:457:5)
    at HTMLCanvasElement.getContext (/home/owner/workspace/client/exokit/src/DOM.js:2557:23)
    at NewShader.init (https://localhost:3000/static/js/4.chunk.js:883:31)
    at NewComponent.updateShader (https://localhost:3000/static/js/4.chunk.js:62334:26)
    at NewComponent.update (https://localhost:3000/static/js/4.chunk.js:62258:18)
    at NewComponent.initComponent (https://localhost:3000/static/js/4.chunk.js:69884:16)
    at NewComponent.updateProperties (https://localhost:3000/static/js/4.chunk.js:69856:18)
    at HTMLElement.value (https://localhost:3000/static/js/4.chunk.js:68371:25)
    at HTMLElement.value (https://localhost:3000/static/js/4.chunk.js:68343:20)
    at entityLoadCallback (https://localhost:3000/static/js/4.chunk.js:68104:20)
    at emitLoaded (https://localhost:3000/static/js/4.chunk.js:69171:19)
    at processTicksAndRejections (internal/process/task_queues.js:89:5)
core:a-node:error Failure loading node:   TypeError: ctx.setGrContext is not a function
    at _onGl2DConstruct (/home/owner/workspace/client/exokit/src/native-bindings.js:436:9)
    at new CanvasRenderingContext2D (/home/owner/workspace/client/exokit/src/native-bindings.js:457:5)
    at HTMLCanvasElement.getContext (/home/owner/workspace/client/exokit/src/DOM.js:2557:23)
    at NewShader.init (https://localhost:3000/static/js/4.chunk.js:883:31)
    at NewComponent.updateShader (https://localhost:3000/static/js/4.chunk.js:62334:26)
    at NewComponent.update (https://localhost:3000/static/js/4.chunk.js:62258:18)
    at NewComponent.initComponent (https://localhost:3000/static/js/4.chunk.js:69884:16)
    at NewComponent.updateProperties (https://localhost:3000/static/js/4.chunk.js:69856:18)
    at HTMLElement.value (https://localhost:3000/static/js/4.chunk.js:68371:25)
    at HTMLElement.value (https://localhost:3000/static/js/4.chunk.js:68343:20)
    at entityLoadCallback (https://localhost:3000/static/js/4.chunk.js:68104:20)
    at emitLoaded (https://localhost:3000/static/js/4.chunk.js:69171:19)
    at processTicksAndRejections (internal/process/task_queues.js:89:5)
THREE.Box3: .getSize() target is now required
THREE.Box3: .getSize() target is now required
core:a-node:error Failure loading node:   TypeError: ctx.setGrContext is not a function
    at _onGl2DConstruct (/home/owner/workspace/client/exokit/src/native-bindings.js:436:9)
    at new CanvasRenderingContext2D (/home/owner/workspace/client/exokit/src/native-bindings.js:457:5)
    at HTMLCanvasElement.getContext (/home/owner/workspace/client/exokit/src/DOM.js:2557:23)
    at setup (https://localhost:3000/static/js/4.chunk.js:64257:36)
    at NewComponent.init (https://localhost:3000/static/js/4.chunk.js:64229:13)
    at NewComponent.initComponent (https://localhost:3000/static/js/4.chunk.js:69876:16)
    at NewComponent.updateProperties (https://localhost:3000/static/js/4.chunk.js:69856:18)
    at HTMLElement.value (https://localhost:3000/static/js/4.chunk.js:68371:25)
    at HTMLElement.value (https://localhost:3000/static/js/4.chunk.js:71553:49)
    at HTMLElement.value (https://localhost:3000/static/js/4.chunk.js:68343:20)
    at entityLoadCallback (https://localhost:3000/static/js/4.chunk.js:68104:20)
    at emitLoaded (https://localhost:3000/static/js/4.chunk.js:69171:19)

Switched back to master and everything is running fine. That websocket error only seems to happen intermitently.

Switched back to master and everything is running fine.

Which branch was being run before?

Was this one with the console.log? #1386 (comment)

The log I would have expected to see was the CanvasRenderingContext2D.

No it failed when it tried to console.log(ctx)