VirtuoWorks / CanvasCameraPlugin

Cordova/PhoneGap CanvasCamera Plugin
MIT License
38 stars 30 forks source link

Failed to load resource error #29

Open djipco opened 4 years ago

djipco commented 4 years ago

I have a project that uses the CanvasCameraPlugin. With a vast majority of frames, it works fine. But, I keep getting this error randomly in the console:

[Error] Failed to load resource: The requested URL was not found on this server. (f2-canvascamera.jpg, line 0)

In fact, it's not so random. It happens shortly after I start the camera (after 1 or 2 frames), then it happens randomly and then one last time when I stop the camera (each time). But, as I said, most frames are loaded normally (I can see them in the Resources tab of the Safari Inspector):

image

These are my options:

{fps: 2, use: "file", cameraFacing: "front"}

I'm not using onCapture, onBeforeDraw or onAfterDraw.

It's as though the images are being prematurely deleted from the device. Perhaps it's something else but I'm running out of ideas. Do you think this can be a bug with the library? Or maybe you would know what I could check to try and solve this?

Thanks a lot!

Sami-Radi commented 4 years ago

Hello,

The plugin keeps as many images as the fps in cache. So I guess that with 2 fps, there might be a lag between the time when the app renders the frame and the currently processed frames by the native part which could explain that some frames are missing after being rendered.

I'll check that out. However, with 2 fps you could use the use: "data" option to use the image base64 data, it's more cpu/ram consuming but you shouldn't feel any différence with 2 fps and you shouldn't have any rendering problems.

Best Regards

djipco commented 4 years ago

The plugin keeps as many images as the fps in cache. So I guess that with 2 fps, there might be a lag between the time when the app renders the frame and the currently processed frames by the native part which could explain that some frames are missing after being rendered.

This is very insightful. I didn't know this is how it worked. Knowing that, I'm pretty sure this is the source of the issue. I'm running this code on old iPhone 5s devices which are not particularly fast...

However, with 2 fps you could use the use: "data" option to use the image base64 data

This is actually what I started with. The problem is that the application crashes after an hour or so when I use this option. It's not clear if the problem is from CanvasCamera or my own code, though. The use: "file" option has been very stable for me and I'd rather stick with it.

Would it be possible for CanvasCamera to keep a minimum number of files (e.g. 10) even if the frame rate is lower than that? It would probably be safer this way... This is just a suggestion. I'm out of my league here. Anyway, thank for your help.