Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using webcam on Windows crashes regl #24

Closed
echophon opened this issue Aug 28, 2018 · 7 comments
Closed

Using webcam on Windows crashes regl #24

echophon opened this issue Aug 28, 2018 · 7 comments
Labels

Comments

@echophon
Copy link
Contributor

Hi!

When I try to run the webcam example on the latest build at: https://hydra-editor-v1.glitch.me

ie
s0.initCam()
src(s0).out()

The output loads for a few seconds and crashes to a black screen a few moments later. The console then starts loading the following error over & over.

regl.js:47 Uncaught Error: (regl) context lost
at Function.raise (regl.js:47)
at Object.REGLCommand [as draw] (regl.js:9396)
at passes.forEach (output.js:196)
at Array.forEach ()
at Output.tick (output.js:196)
at HydraSynth.tick (index.js:293)
at Engine. (index.js:52)
at emitOne (events.js:106)
at Engine.emit (events.js:184)
at Engine.tick (index.js:42)

Initial Test - Reproduced on Win10 desktop, Chrome 68, GTX1070, dual 2560x1440 144Hz resolution monitors (one rotated to portrait) and this model of webcam https://www.amazon.com/ELP-2-8-12mm-Varifocal-1-3megapixel-Android/dp/B01N8YH5VY

The error can be cleared by refreshing but fails again a few seconds after initCam()

Test 2 - cannot repro with same webcam attached to older MBP with Nvidia card. also on Chrome 68. This should rule out the camera as cause.

Test 3 - 144Hz is only supported over displayport, & one of my screens is connected via HDMI and runs instead at 60Hz. Unable to repro on the screen that runs at 60Hz. So it appears that it is the increased frequency at 144Hz that is the culprit.

I think the cam only support 24 or 30 fps, so I suspect some sort of timing discrepancy as the root cause.

@ojack
Copy link
Member

ojack commented Aug 28, 2018

@echophon how interesting. What is the very first error that appears before all the regl errors?

Do both of these examples work with your camera+screen configuration?: https://webrtc.github.io/samples/src/content/getusermedia/gum/ https://webrtc.github.io/samples/src/content/getusermedia/canvas/

@ojack ojack added the bug label Aug 28, 2018
@echophon
Copy link
Contributor Author

I only see a warning once, then all these errors. The warning is:

WebGL: CONTEXT_LOST_WEBGL: loseContext: context lost

If I reevaluate the code once this occurs I see this in the canvas error handling area:

Failed to execute 'shaderSource' on 'WebGLRenderingContext': parameter 1 is not of type 'WebGLShader'.

I was able to reproduce this on the 60Hz screen, so it might not be screen related after all.

I can run both of those WebRTC samples and others (great resource) for extended periods at a time. I can also run them at the same time as Hydra and they keep working if in seperate windows. They do however blank to white when this crash occurs, but as soon as I give their window focus again they start working again. Hmmm....

@ojack
Copy link
Member

ojack commented Nov 2, 2018

@echophon any updates on this?

@echophon
Copy link
Contributor Author

echophon commented Nov 3, 2018

@ojack Applied the latest graphic drivers from NVIDIA, but still running into this. Additionally, I tried in atom-hydra & with a different webcam. In both cases, I was able to capture a bit more of the crash data into the console. Looks like a memory leak, but I found this reference on regl regl-project/regl#430 which points to buffer allocation.

Webcam 1
WebGL: CONTEXT_LOST_WEBGL: loseContext: context lost
index.html:1 [.Offscreen-For-WebGL-0000020DD7806550]GL ERROR :GL_OUT_OF_MEMORY : BackFramebuffer::Destroy: <- error from previous GL command
C:\Users\echophon.atom\packages\atom-hydra\node_modules\regl\dist\regl.js:48 Error: (regl) context lost
at Function.raise (C:\Users\echophon.atom\packages\atom-hydra\node_modules\regl\dist\regl.js:47)
at Object.REGLCommand [as draw] (C:\Users\echophon.atom\packages\atom-hydra\node_modules\regl\dist\regl.js:9403)
at passes.forEach (C:\Users\echophon.atom\packages\atom-hydra\node_modules\hydra-synth\src\output.js:158)
at Array.forEach ()
at Output.tick (C:\Users\echophon.atom\packages\atom-hydra\node_modules\hydra-synth\src\output.js:158)
at HydraSynth.tick (C:\Users\echophon.atom\packages\atom-hydra\node_modules\hydra-synth\index.js:301)
at Engine. (main.js:216)
at emitOne (events.js:116)
at Engine.emit (events.js:211)
at Engine.tick (C:\Users\echophon.atom\packages\atom-hydra\node_modules\raf-loop\index.js:42)

Webcam 2
[.Offscreen-For-WebGL-0000021B339D9170]GL ERROR :GL_OUT_OF_MEMORY : glFramebufferTexture2D: <- error from previous GL command
index.html:1 [.Offscreen-For-WebGL-0000021B339D9170]GL ERROR :GL_OUT_OF_MEMORY : glFramebufferTexture2D:
index.html:1 WebGL: CONTEXT_LOST_WEBGL: loseContext: context lost
index.html:1 [.Offscreen-For-WebGL-0000021B339D9170]GL ERROR :GL_OUT_OF_MEMORY : BackFramebuffer::Destroy: <- error from previous GL command
C:\Users\echophon.atom\packages\atom-hydra\node_modules\regl\dist\regl.js:48 Error: (regl) context lost
at Function.raise (C:\Users\echophon.atom\packages\atom-hydra\node_modules\regl\dist\regl.js:47)
at Object.REGLCommand [as draw] (C:\Users\echophon.atom\packages\atom-hydra\node_modules\regl\dist\regl.js:9403)
at passes.forEach (C:\Users\echophon.atom\packages\atom-hydra\node_modules\hydra-synth\src\output.js:158)
at Array.forEach ()
at Output.tick (C:\Users\echophon.atom\packages\atom-hydra\node_modules\hydra-synth\src\output.js:158)
at HydraSynth.tick (C:\Users\echophon.atom\packages\atom-hydra\node_modules\hydra-synth\index.js:301)
at Engine. (main.js:216)
at emitOne (events.js:116)
at Engine.emit (events.js:211)
at Engine.tick (C:\Users\echophon.atom\packages\atom-hydra\node_modules\raf-loop\index.js:42)

@echophon echophon changed the title Using webcam with 144 Hz monitor crashes regl Using webcam on Windows crashes regl Nov 3, 2018
@ojack
Copy link
Member

ojack commented Nov 4, 2018

@echophon i found an error and updated hydra-synth, the browser, and atom verion....any difference?

@echophon
Copy link
Contributor Author

echophon commented Nov 5, 2018

I think this is fixed! My initial results at hydra-editor-v1.glitch.me are looking good. I can connect multiple USB webcams, record & playback a video (vidRecorder was also crashing for me previously), and unplug webcams without an error. In this last case, they just display the last buffer received. I'll try with atom next.

I did notice that one of the example sketches (Will's Lines) throws an error "o0.scale" is not a function, so there may be a slight backwards compatibility issue. Simple enough to fix it by updating to "src(o0).scale"

@ojack
Copy link
Member

ojack commented Nov 5, 2018

yay! i am going to close the issue then!

thats interesting because i dont think o0.scale would have ever worked ... or maybe im forgetting something

@ojack ojack closed this as completed Nov 5, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants