Repository navigation
fix(rune-image): enforce AVIF pixel budget in rav1d and add per-load ImageLimits - #2641
Merged
Merged
Conversation
…ImageLimits Replace the `avif-decode` wrapper with direct `avif-parse`, pure-Rust `rav1d`, and `yuv` decoding inside `crates/rune-image/src/avif/`, so `Dav1dSettings::frame_size_limit` rejects oversized primary and alpha frames inside `rav1d` (`ERANGE`) before frame-plane allocation and converts decoded planes straight into a checked, `try_reserve_exact`-allocated RGBA8 buffer with no intermediate full-frame RGB/RGBA16 allocation. Add `ImageLimits` (`max_side`, `max_pixels`, `max_alloc`, clamped to Rune's global cap) with `ImageCache::load_with_limits` and `ImageCache::load_scaled_with_limits` (re-exported as `rune::ImageLimits`) so callers with smaller preview surfaces can tighten per-load pixel budgets across native AVIF, raster, animated, SVG, and web header preflight paths. Fixes #1719
pascalandr
added a commit
to NeuralNomadsAI/rune
that referenced
this pull request
Nov 27, 2026
Upstream merged the first Android slice (anomalyco#2662, closing anomalyco#2647): the winit activity feature, the getloadavg gate and an android workflow. Taken from upstream: runq.rs, the Android target section of rune's Cargo.toml (the fork's JNI, NDK and AccessKit dependencies now sit in it), android.yml and the changelog entry; the fork's own S0 entry goes. Also from upstream since the last merge: - Cx::touch_controls and hover_none read the host's primary pointer (anomalyco#2638). The fork's cfg(android) constants go; the Android LayerHost calls set_touch_controls(true), as the iOS one does. - rune-text's prewarm_system_fonts (anomalyco#2660): Android's backend answers it with nothing to build ahead. - rav1d without assembly (anomalyco#2641): an x86_64 library with avif links without -Wl,-Bsymbolic, so ANDROID.md's note about it goes. Kept over upstream in android.yml: the android/** push trigger and the apk job, which builds the Kotlin host with the example. Checked: clippy for both Android targets (let_underscore_must_use allowed, as rune-core fails it upstream), an x86_64 cdylib with avif links, check-wasm, cargo check, file-size, rune lib tests 4087 passed with the 4 failures upstream dev has on Windows (and one more that passes alone).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
rav1dpixel budget: Replaced theavif-decode3.0.0 wrapper (which leftDav1dSettings::frame_size_limit = 0and allocated unchecked intermediate RGB/RGBA16 buffers) with a directavif-parse+ pure-Rustrav1d+yuvdecoder incrates/rune-image/src/avif/codec.rs.Dav1dSettings::frame_size_limitto the caller's effective pixel budget (rejecting zero-pixel budgets before openingrav1d, since0disables the limit inrav1d) so oversized primary and alpha frames fail withERANGEbefore frame-plane allocation.Vec::try_reserve_exact, converting 8/10/12-bit YUV, GBR, YCgCo, monochrome, and alpha planes straight into the final RGBA8 buffer with no intermediate full-frame allocation.crates/rune-image/src/avif.rsintocrates/rune-image/src/avif/{mod,limits,codec,tests}.rsand removes unused transitivelodepng/quick-errordependencies as well as the NASM build requirement on x86_64.ImageLimits(with_max_side,with_max_pixels,with_max_alloc, clamped to Rune's global8192 px / 67,108,864 px / 256 MiBcap) andImageCache::load_with_limits/ImageCache::load_scaled_with_limits(re-exported asrune::ImageLimits).ImageLimitsshares cache keys withload/load_scaled; tighter limits use distinct cache keys so a rejected preview load never poisons a full-budget load.rav1d, post-decode conversion), still rasters, animated GIF/WebP/APNG, SVG, and webheader::check_with_limits+ post-createImageBitmapchecks.Verification
cargo test -p rune-image --features avif(106 passed, 2 ignored; 12 doc-tests passed), including directrav1dframe_size_limitrejection tests (bypassing preflight) onwww/public/img/hello-320.avif, real AV1 alpha-plane decode tests, andImageCache::load_with_limits/load_scaled_with_limitscache-key isolation tests.cargo test -p rune-image(102 passed, 2 ignored; 12 doc-tests passed) andcargo check -p rune-image --no-default-features.cargo check -p rune --features avif.cargo check -p rune-image --target wasm32-unknown-unknown(default and--no-default-features).bash scripts/file-size.sh(0 errors, 0 folder-shape issues).Fixes #1719