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

Improve animated webp detection #1510

Merged
merged 3 commits into from
Dec 17, 2024
Merged

Improve animated webp detection #1510

merged 3 commits into from
Dec 17, 2024

Conversation

EricBAndrews
Copy link
Member

Checklist

  • I have read CONTRIBUTING.md
  • I have described what this PR contains
  • If this PR alters the UI, I have attached pictures/videos
  • This PR addresses one or more open issues that were assigned to me:
    - Hopefully deals with Static webp sometimes laggy #1509

Pull Request Information

This PR improves how webp images are handled. Previously, every webp would go through the NukeWebpBridgeDecoder, which would both decode the image and, if the image was animated, populate the animated field. This had multiple problems:

  • The BridgeDecoder was scanning the entire data to find the ANMF header
  • The BridgeDecoder was therefore very slow, even for static images, and because the check was so slow it couldn't defer to the standard Nuke decoder for static images
  • The BridgeDecoder was poorly optimized for static images, since it was built to handle animated images
  • The BridgeDecoder could throw a false positive if ANMF happened to appear in the body of the image's data

This PR implements a much more efficient method of checking whether a webp is animated; it now scans only the critical bytes, rather than the whole data. This allows the NukeWebpBridgeDecoder to check at init whether a webp is animated and defer to the more efficient Nuke default decoder for static images.

Hopefully using Nuke for the static webps fixes the lagginess, which I believe may have been caused by the custom decoding. It may just be good luck, but I haven't encountered lag on this branch.

@EricBAndrews EricBAndrews requested a review from a team as a code owner December 17, 2024 01:07
@EricBAndrews EricBAndrews requested review from WestonHanners, mormaer and Sjmarf and removed request for a team December 17, 2024 01:07
Copy link
Contributor

@Sjmarf Sjmarf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! 💯

@EricBAndrews EricBAndrews enabled auto-merge (squash) December 17, 2024 18:01
@EricBAndrews EricBAndrews merged commit f8f06b5 into dev Dec 17, 2024
2 checks passed
@EricBAndrews EricBAndrews deleted the eric/webp-lag branch December 17, 2024 18:03
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.

2 participants