uploaded gifs fail to loop in chat on firefox

(#676) Bug Fixed media

Summary

when viewing an uploaded .gif file on firefox, the gif will not loop, only playing once before disappearing. this doesnt happen in the image viewer, when you click on the gif

Steps to reproduce

  1. upload any (?) .gif file
  2. look at it in chat using firefox

Environment

OS: Windows 11 Browser: Firefox Developer Edition 153.0b4

Logs or screenshots

613325110-e4b2c190-efcb-4b46-96a5-be33604d95e2.mp4
613325110-e4b2c190-efcb-4b46-96a5-be33604d95e2.mp4 | 820 kB

6 comments

Sign in with Fluxer to comment and vote.
Comment by @Solly-Bird
RexSystem 1 vote originally by @Solly-Bird on GitHub
i'm trying to reproduce this. it's working on my system though. can you upload the gif here so that i can try it with your gif? the GIF itself can determine how its looping behavior works, i wonder if your GIF is just set to not loop for reference, it's working with this one when I try: image
Comment by @Solly-Bird
RexSystem 1 vote originally by @Solly-Bird on GitHub
i'm able to reproduce it in firefox, and it doesn't happen on chrome. i opened up the GIF metadata and it's supposed to loop infinitely 🤔
Comment by @Solly-Bird
RexSystem 1 vote originally by @Solly-Bird on GitHub
I think I've narrowed it down to fluxer_app/src/features/app/hooks/useAnimatedImageDecoder.ts. It seems that anything that exceeds maxCachedFrames has this problem (default of 24 frames). Not sure why that happens in Firefox but not Chrome though. If I set maxedCachedFrames to 5, then this problem occurs with the GIF i uploaded too (since it has 12 frames). If I set it to 512, then your gif plays without issue
Comment by @Solly-Bird
RexSystem 1 vote originally by @Solly-Bird on GitHub
It has to do with the image.close() line here. It calls .close() on the VideoFrame object after each loop through the GIF, so by the time it passes through the second time, there's nothing to render. Commenting out that image.close() line solves the issue on Firefox. I'm not sure why this happens on Firefox but not Chrome. I'm also not sure of the memory usage implications for this change, so I'll leave it to someone that knows frontend JS better than I do
Deleted comment
Removed by moderator Rex: Removed a general status note that was posted on many GitHub threads. It no longer applies here.
Comment by Hampus
HampusStaff 1 vote originally by @hampus-fluxer on GitHub
This should be fixed as of the latest version. Please open up a new issue if the issue persists, and I'll look into it!