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
A gif is playing very fast #540
Comments
Hey @rupinderjeet, @colinrtwhite |
@IljaKosynkin Thanks for investigating this! Do you know how tough it would be to pre-process the GIF as it's being read? I'd be open to a solution that uses |
@colinrtwhite I can't tell it from the top of my head regarding complexity and performance impact, to be honest, but I'm going to poke around to tell estimation, possibly with PR, if it is not too bad in my opinion. |
Also, on a side note, from my investigation it seems that all files in |
@IljaKosynkin Are you sure? They appear to be encoded as GIFs when I download them locally. Though, feel free to add more sample gifs to that file. |
@colinrtwhite oh ok, seems that it might be an issue with browser. Because it defaults to WEBP for me apparently, but I can manually change link to get GIF version of the same animation. As for the ForwardingSource, it seems that delay time can be found by searching for 21 F9 04 sequence in the byte buffer and changing uint16_t after first byte after that sequence. |
@IljaKosynkin I don't think we can use animated WebP in the sample since those only work on API 28+. Interesting! Do you know what |
@colinrtwhite It is not a magic number, well at least not sequence itself. |
@IljaKosynkin Yep, we definitely don't want to add native code and I don't think requesting a feature for the next platform release would help much. In terms of performance I'm not too worried about adding some pre-processing of the input data using Kotlin code. Glide's GIF parser is 100% Java and it's pretty quick. As long as we're not allocating class instances I think we should be good. Correct me if I'm wrong (not super familiar with the GIF technical specs), but maybe we could do something like this:
Is that something you're interested in working on? Else I'm happy to take it on. |
@colinrtwhite tbh I'm not sure how much overhead processing of binary files in pure Java/Kotlin would add compared to native languages, but I feel like it might be substantial. But we can try and profile code to see how bad it actually is.
|
@IljaKosynkin Sounds good. I'll probably have time to try to prototype this this weekend. |
Ok, so I guess I better pickup something else, right? @colinrtwhite |
@IljaKosynkin Sure, if you could investigate + fix #539 that would be awesome. |
Sure, gonna take a look @colinrtwhite |
Hi @colinrtwhite - Do you have any update or workaround on this issue? On some gifs I'm also noticing Edit: To add more context, I am migrating to Coil from Glide. On Glide, the gifs were all playing at the same speed. With Coil, I'm seeing this issues depending on the type of the decoder. |
@seankim-android Ah yep this is a longstanding issue, unfortunately due to how Since this is taking a while to fix using a full GIF parser, it probably makes sense to include this work-around in |
@colinrtwhite Thank you very much for looking into this 🙏. I'm new to GIF decoders and having that sample code will be super helpful. |
@colinrtwhite sorry for late response, got caught up in stuff. Yes, I'll do it, but can't promise any fast results. It is not exactly a one-line fix. Will check out Glide to see how they did it. |
@IljaKosynkin I ended up taking a stab at it this weekend here. It uses the less cumbersome solution, but I haven't seen any artifacts using it yet. @seankim-android If you want to use it asap in your project you can copy the class DelegateGifDecoder(private val delegate: Decoder): Decoder by delegate {
override suspend fun decode(
pool: BitmapPool,
source: BufferedSource,
size: Size,
options: Options
) = delegate.decode(pool, FrameDelayRewritingSource(source).buffer(), size, options)
} Though, keep in mind that it isn't fully tested and may have bugs! |
@colinrtwhite Thank you very much for the PR and the workaround. I'm trying out the |
@seankim-android Glad to hear. This fix will be included in the next release of the library in a few weeks (though disabled by default to let it incubate). |
|
Plays really fast than how it is shown in Android Gallery and Chrome. Issue occurs while using
ImageDecoderDecoder
. If onlyGifDecoder
is used, gif doesn't play at all.How do I load this gif? Checkout #539
This is how it looks when I load it:
record.mp4.zip
The text was updated successfully, but these errors were encountered: