fix(avatar): freeze APNG and animated WebP avatars, not just GIF#772
Merged
Conversation
The freeze decided "is this animated?" from the declared MIME type (blob.type === 'image/gif'). That misses the common real-world cases: many animated avatars are APNG or animated WebP, and the SDK occupant-avatar path stores avatars as image/png regardless of the real format (Profile.ts), so even a GIF can arrive mistyped. Those avatars were never frozen and played continuously (kuyuhi in #XSF is an animated PNG). Detect animation from the actual image bytes instead: GIF header, APNG acTL control chunk, or animated-WebP ANIM chunk. The canvas first-frame extraction already handles any decodable raster format, so the freeze now covers all three. Static JPEG/PNG/WebP are untouched (no signature match).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Follow-up to #770. Animated avatars are meant to show a frozen first frame and play only on hover. #770 fixed the freeze-frame cache for virtualized scrolling, but the freeze still only ever applied to literal GIFs.
The decision "is this animated?" was made from the declared MIME type (
blob.type === 'image/gif'). That misses the common real-world cases:<img>.image/pngregardless of the real format (Profile.tshardcodes it for PEP avatars and defaults to it for vCard avatars with no<TYPE>), so even a GIF can arrive mistyped.So these avatars were never frozen and animated continuously (observed: kuyuhi in #XSF, an animated PNG).
This detects animation from the actual image bytes instead of the declared type: GIF header, APNG
acTLcontrol chunk, or animated-WebPANIMchunk. The existing canvas first-frame extraction already handles any decodable raster format, so the freeze now covers all three. Static JPEG/PNG/WebP are left untouched (no signature match), so there is no extra work for the common case.Known gap
Animated AVIF/HEIF are not detected (rare as avatars, and WebKit animation support for them is limited). They would keep animating.