mastodon / mastodon-android

Official Android app for Mastodon
https://app.joinmastodon.org/android
GNU General Public License v3.0
1.68k stars 262 forks source link

GIF avatar playing too fast #554

Open cassidyjames opened 1 year ago

cassidyjames commented 1 year ago

The GIF avatar at https://hachyderm.io/@bazzargh plays extraordinarily fast in the Android app, to the point where it was making me nauseous. On the web, it plays at the expected framerate.

918b80fed4f1422d.gif

I'm on a Pixel 7 with a 90 Hz display if that's relevant.

Here’s a video, but unfortunately it doesn’t show quite how fast it actually looks on my screen thanks to YouTube’s re-encoding: https://youtube.com/shorts/9WQhSpWTTBY

Direct link: https://cassidyjames.com/videos/mastodon-android-gif.mp4

grishka commented 1 year ago

The app delegates the playback of gifs to the system — in particular the new ImageDecoder API and whatever kind of drawable it uses internally on modern system versions. I will look into it but I'm almost sure that this particular gif file is to blame for breaking the format spec in some way.

Do other gifs play at the right speed for you?

grishka commented 1 year ago

It is also very fast on my Pixel 4a, which only does 60 Hz

grishka commented 1 year ago

That's some strange gif file. Frame delays are set to 0: image This is what a correctly-timed animation looks like (hi Sam): image The "delay time" field in the offending gif is set to 0 for all frames, which matches what Photoshop shows: image

The GIF format specification says:

vii) Delay Time - If not 0, this field specifies the number of hundredths (1/100) of a second to wait before continuing with the processing of the Data Stream. The clock starts ticking immediately after the graphic is rendered. This field may be used in conjunction with the User Input Flag field.

I interpret this as "if it is 0, then the behavior is not defined". Some implementations (browsers and iOS) use some default delay value. Some interpret it as "literally no delay, show the next frame as quickly as possible".

I could hack something into my image loader to patch such gifs to have some sane frame delay value before handing them over to rest of the app, but that feels like too much of a workaround for something that happens so rarely and isn't even specified anywhere.

cassidyjames commented 1 year ago

Here is another example of a headache-inducing GIF in the app that plays as expected in the browser: https://norden.social/@dirksen 7966c284ddbc4f6c.gif

Interestingly, it plays at the same speed in the native GitHub Android app and the native Google Photos Android app as in the browser.