infragram icon indicating copy to clipboard operation
infragram copied to clipboard

Image files are unable to load after camera stream.

Open Forchapeatl opened this issue 3 years ago • 2 comments

Image files are unable to load after camera stream.

@jywarren , please i can't seem to diagnose the source of this unexpected behavior. Could you help me please?

https://user-images.githubusercontent.com/24577149/181921156-3801abe2-c445-4903-855a-f1611257ceef.mp4

Originally posted by @Forchapeatl in https://github.com/publiclab/infragram/pull/439#discussion_r933833059

Forchapeatl avatar Aug 04 '22 18:08 Forchapeatl

OK, so i think when we start video mode, we begin a loop to fetch images from the video element. When we try to go back to upload mode, we need to find and halt that loop. Let me look...

Yes, we do it in this function:

https://github.com/publiclab/infragram/blob/f15add6ae6057bd99b4b1b930449f75ca974270e/src/Infragram.js#L34-L45

And that function is called from here:

https://github.com/publiclab/infragram/blob/577ff122edd6918891a84ea9d9df221585fdc901/src/ui/interface.js#L89-L97

So we have to save the setInterval object and stop it with clearInterval(). Intervals are a little weird but they are just repeated timers. You can read how they work here! https://developer.mozilla.org/en-US/docs/Web/API/setInterval#return_value There are good examples lower on that page that you can model to use here. But, I think we could also solve this in a separate PR - i don't think it's your code that's causing it, it's already the case in the main branch!

And, solving it may be a little more complex, we have to think carefully about where we store the interval return value so that we can make a stopVideo() function, probably? I can help you figure that out too but we might as well move this whole comment thread to its own issue, what do you think?

jywarren avatar Aug 05 '22 22:08 jywarren

HI @Forchapeatl I would like to try ...if no one else is

ojninja16 avatar Sep 12 '22 13:09 ojninja16