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

WebPDecoder.into_frames() always returns an error at the end of the file instead of ending iteration normally #2226

Closed
awused opened this issue May 4, 2024 · 1 comment · Fixed by #2228

Comments

@awused
Copy link
Contributor

awused commented May 4, 2024

Broken in 0.25.x and git head, unsure about when it started since I was hoping to replace the webp-animation crate with this, but it's probably been unused and broken for a while.

Expected

Frames iterator returns None after the last frame.

Actual behaviour

Returns either a DecodingError { format: Exact(WebP), underlying: Some(NoMoreFrames) } or an IO Error from a BufReader as it tries to read past the end of the file.

Reproduction steps

Call into_frames on an WebPDecoder for an animated image. Here's a test that runs on your own test data.

#[test]
fn webp_decode() {
    let decoder = WebPDecoder::new(std::io::Cursor::new(
        std::fs::read("tests/images/webp/extended_images/anim.webp").unwrap(),
    ))
    .unwrap();
    let frames = decoder.into_frames();
    for result in frames {
        result.unwrap();
    }
}
thread 'webp_decode' panicked at tests/limits_anim.rs:20:16:
called `Result::unwrap()` on an `Err` value: Decoding(DecodingError { format: Exact(WebP), underlying: Some(NoMoreFrames) })
@fintelia
Copy link
Contributor

fintelia commented May 4, 2024

Probably happened in the switch to using image-webp. The fix should be to call num_frames at the start and then return None once that many frames have been decoded. Or maybe once num_frames * loop_count many frames have been decoded

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants