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

Blurry animations without feature1_2 #20

Open
walles opened this issue Jun 29, 2023 · 1 comment
Open

Blurry animations without feature1_2 #20

walles opened this issue Jun 29, 2023 · 1 comment

Comments

@walles
Copy link

walles commented Jun 29, 2023

Animation with feature 1_2

screenshot-1_2

Animation with feature 0_5

screenshot-0_5

Description

Both files were generated using this exact code, just clone it and cargo run --bin=screenshot:
https://github.com/walles/loadviz/blob/b19b25e91687b274db487cb4f9daeee9ce82b580/libloadviz/src/bin/screenshot.rs

If you change the required feature from 1_2 to 0_5 without any changes to the Rust code, you'll get the blurry screenshot when running the program.

Expectations

I expected enabling features would give me things like "now you can encode animations!". And it does, this is good.

I did not expect enabling features heavily affecting the quality of the output. But it does, I think this was bad.

Also, I think this behavior is really un-obvious, so maybe 0_5 should be removed? Or fixed if there's something wrong with it messing up the quality?

Notes

Since GitHub doesn't support uploading WEBP images (please vote for it!) I used this trick for that. They are really WEBPs, no matter what the file extensions say.

@qnighy
Copy link
Owner

qnighy commented Jun 29, 2023

Yeah it's strange.

libwebp-sys2-rs is designed to be a handwritten translation of libwebp(C)'s public headers, and these public headers evolve between versions. The version-numbered features, such as 0_5, 0_6, and 1_2 are just meant to switch header versions. Therefore there are three possibilities for the behavioral inconsistency:

  1. libwebp(C) behaves differently based on the difference in its header versions.
  2. libwebp-sys2-rs does not correctly translate libwebp(C)'s public headers.
  3. Some sort of Rube Goldberg machine, possibly involving undefined behaviors.

And technically, libwebp-sys2-rs defines slightly different interfaces based on its version-numbered features because the original headers do so. Especially,

  1. Some of the structs, including WebPConfig, often have different fields of different sizes. I expect libwebp(C) to be designed so that the changes are backwards-compatible, but I'm not 100% sure.
  2. It declares different ABI versions, which are passed to the library during initialization. libwebp(C) may be using it to switch behaviors, though I think this is fairly unlikely.

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

No branches or pull requests

2 participants