alemart / speedy-vision

GPU-accelerated Computer Vision for JavaScript.
Apache License 2.0
172 stars 28 forks source link

Getting an error upon webgl context creation #34

Closed periman2 closed 2 years ago

periman2 commented 2 years ago

Greetings, first of all I'd like to congratulate you for the amazing package you've made. The error I'm getting has to do with webgl creation (I think) as it says in the console. It does not happen always and it seems to happen when the video (it's an hls stream) that I'm trying to load hasn 't been loaded fully or 'enough' during some metric I can't really know though, I do not know exactly when it happens though. Here's what I'm doing: First I'm seeking to a video stream (hls VOID stream), waiting for it to seek and then on the 'onseeked' event of the video element I draw on canvas. This canvas element is the Media source for speedy vision, and then I perform feature matching between it and a different video frame (different canvas Media element, but having seeked and took picture from the same video element just like before).

These are the error logs:

 GLError: WebGL error. 

---------- ERROR ----------

---------- SOURCE CODE ----------

  1. #version 300 es
  2. precision highp float;
  3. precision highp int;
  4. 
  5. layout (location=0) in vec2 a_position;
  6. layout (location=1) in vec2 a_texCoord;
  7. out highp vec2 texCoord;
  8. uniform highp vec2 texSize;
  9. 
 10. #define vsinit() gl_Position = vec4(a_position, 0.0f, 1.0f); texCoord = a_texCoord;
 11. 
 12. 
 13. #define vsmain() ;
 14. 
 15. void main() { vsinit(); vsmain(); }
 16. 

-> [speedy-vision.js]
    at Function._compile (speedy-vision.js:18091:1)
    at SpeedyProgram._init (speedy-vision.js:17750:1)
    at new SpeedyProgram (speedy-vision.js:17721:1)
    at SpeedyProgramGroupKeypoints._createProgram (speedy-vision.js:17617:1)
    at SpeedyProgramGroupKeypoints.Object.defineProperty.get (speedy-vision.js:17581:1)
    at SpeedyPipelineNodeMatchedKeypointSink._allocateExtra (speedy-vision.js:6346:1)
    at SpeedyPipelineNodeMatchedKeypointSink._run (speedy-vision.js:6501:1)
    at SpeedyPipelineNodeMatchedKeypointSink.execute (speedy-vision.js:8561:1)
    at Function._runSequence (speedy-vision.js:9615:1)
    at SpeedyPipeline.run (speedy-vision.js:9572:1)

And then I get:

[speedy-vision] Creating a default WebGL2 rendering context...
speedy-vision.js:16403 Uncaught NotSupportedError: Unsupported operation. Can't create a WebGL2 Rendering Context. Try a different browser!
-> [speedy-vision.js]
    at SpeedyGL._createContext (speedy-vision.js:16403:1)
    at SpeedyGL._reinitialize

The error about my browser not supporting webgl is of cousre missleading as the whole process works fine sometimes, honestly randomly from what I can tell so far.

Any ideas on what I could try in order to find what's causing this? During the weekend I will try creating a reproduction repo but currently I don't have time to do so.

One hint is that whenever I get this error, I get it first time I'll try the process, and then it won't ever work during the same session. If I refresh the tab and do it successfully the first time though, I can't seem to be able to get the error during the session at all and it works perfectly well.

alemart commented 2 years ago

Hi @periman2! Thank you for using Speedy Vision.

I believe that you are getting a WebGL2 Context Loss before the error you have pointed out. Is that the case? This information should be in the log.

Since you're using a canvas as a media source, in theory it should not matter that the data comes from a HLS stream. Speedy lets you load a <canvas> and also a <video> directly.

From the information that has been shared so far, I can't say for sure if the error is related to Speedy Vision, to your app, or even to your browser / driver. Have you tried your app in a different machine? In a different browser?

Any ideas on what I could try in order to find what's causing this? During the weekend I will try creating a reproduction repo but currently I don't have time to do so.

I can gladly take a look at your app (or a part of your app) as a consulting service. If you provide me with your contact information, I will be able to provide you with the details.

Greetings, first of all I'd like to congratulate you for the amazing package you've made.

Thank you very much for your kind words.

alemart commented 2 years ago

Feel free to open a new issue if the problem persists.