Skip to content
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

Animated WebP's cannot actually be loaded #2263

Closed
SludgePhD opened this issue Jun 21, 2024 · 3 comments · Fixed by #2278
Closed

Animated WebP's cannot actually be loaded #2263

SludgePhD opened this issue Jun 21, 2024 · 3 comments · Fixed by #2278

Comments

@SludgePhD
Copy link
Contributor

WebPDecoder fails to decode WebP animations.

Expected

It should probably work?

Actual behaviour

Reproduction steps

WebPDecoder::new(BufReader::new(File::open(path)?))?.into_frames().collect_frames()?

piston.zip

@porkbrain
Copy link
Contributor

I believe this to be a regression introduced in 0.25.

My code using 0.24 plays the image fine (also tested using this repo's tests/images/webp/extended_images/anim.webp), albeit the has_animation method returns false.

After update to 0.25 (wrapping the bytes in Cursor instead of passing them as &[u8]) I cannot play my test webp nor the one I mentioned above. As mentioned in the issue description, collect_frames runs into

Format error decoding WebP: No more frames

Although ironically, after the update, the has_animation method now returns correctly true.

@porkbrain
Copy link
Contributor

porkbrain commented Jul 5, 2024

This commit breaks the webp animation loader.

EDIT: That's impossible, probably some caching issue when I was bisecting the culprit commit. Going to try again

@porkbrain
Copy link
Contributor

This issue is actually quite straightforward. The iterator now returns an error if there are no more frames instead of None.

decoder
            .into_frames()
            .take_while(|frame| frame.is_ok())
            .collect()

Collecting the frames manually this way works. I will send an MR with a suggested fix as I believe NoMoreFrames should be caught in the iterator and converted to None.

as-cii added a commit to zed-industries/zed that referenced this issue Jul 27, 2024
This PR adds support for animated images. The image requires a id for it
to actually animate across frames.

Currently it only has support for `GIF`, I tried adding decoding a
animated `WebP` into frames but it seems to error. This issue in the
image crate seems to document this
image-rs/image#2263.

Not sure if this is the best way or the desired way for animated images
to work in GPUI but I would really like support for animated images.
Open to feedback.

Example Video:


https://github.com/zed-industries/zed/assets/76515905/011f790f-d070-499b-96c9-bbff141fb002



Closes #9993

Release Notes:

- N/A

---------

Co-authored-by: Antonio Scandurra <me@as-cii.com>
Co-authored-by: Nathan <nathan@zed.dev>
kevmo314 pushed a commit to kevmo314/zed that referenced this issue Jul 29, 2024
This PR adds support for animated images. The image requires a id for it
to actually animate across frames.

Currently it only has support for `GIF`, I tried adding decoding a
animated `WebP` into frames but it seems to error. This issue in the
image crate seems to document this
image-rs/image#2263.

Not sure if this is the best way or the desired way for animated images
to work in GPUI but I would really like support for animated images.
Open to feedback.

Example Video:


https://github.com/zed-industries/zed/assets/76515905/011f790f-d070-499b-96c9-bbff141fb002



Closes zed-industries#9993

Release Notes:

- N/A

---------

Co-authored-by: Antonio Scandurra <me@as-cii.com>
Co-authored-by: Nathan <nathan@zed.dev>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants