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

Fix image_loader for animated image types #5688

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

BSteffaniak
Copy link

Hi, after upgrading to 0.31.0 all of my beautiful static webp images started failing to load. I use the image_loader to load those via the image crate.

I noticed that with 0.31.0 there are additions to how animated image types are handled with frames and such. And with those changes the frame index is attached to the uri at the end. This was problematic for the image_loader, because it wasn't updated to handle that frame tag at the end of the uri, so when looking up the bytes, it would fail to match the uri in the bytes cache (the bytes were being saved without the frame index, but attempting to be fetched with the frame index).

This fixes the image_loader for me with webp & gif. They don't load the animations, but I think that is because I don't have the custom image_loader set up so I'm not worried about that for myself. I'm not sure if that part is problematic in general, or if its just the way I have my features set up.

You can recreate the issue on master by swapping out the dependency features in the images example like this:

# egui_extras = { workspace = true, features = ["default", "all_loaders"] }
# env_logger = { version = "0.10", default-features = false, features = [
#   "auto-color",
#   "humantime",
# ] }
# image = { workspace = true, features = ["jpeg", "png"] }
egui_extras = { workspace = true, features = ["image", "svg"] }
env_logger = { version = "0.10", default-features = false, features = [
  "auto-color",
  "humantime",
] }
image = { workspace = true, features = ["jpeg", "png", "webp", "gif"] }
  • I have followed the instructions in the PR template

@BSteffaniak
Copy link
Author

Side note: I think an even better way to handle this would be to not treat static webp/gif images as "animated". The webp spec has an "ANIM" chunk at a specific position in the headers if it is animated, which you could use to determine in addition to searching for the RIFF WEBP header.

I'd be happy to help out with that if you'd like. Otherwise I thought I'd just bring it to your attention in case you haven't thought about that.

@BSteffaniak
Copy link
Author

@emilk Do you have any concerns with this approach? Without this, my images don't work with the custom image_loader.

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

Successfully merging this pull request may close these issues.

1 participant