fix(desktop): GIF decode memory budget must include logical compositing buffers#15
Draft
cursor[bot] wants to merge 1 commit into
Draft
fix(desktop): GIF decode memory budget must include logical compositing buffers#15cursor[bot] wants to merge 1 commit into
cursor[bot] wants to merge 1 commit into
Conversation
decodeGifForCompose composes on two full logical-screen BufferedImages. The existing guard only counted output-frame bytes, so a large logical size with a small on-card target passed the check while allocating tens of megabytes in working buffers, risking OOM. Reject early when logical working memory plus retained frames exceeds MaxDecodedGifBytes. Co-authored-by: Fab <CreepsoOff@users.noreply.github.com>
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
Fixes a memory-limit bypass in desktop GIF decoding: the decode budget previously counted only output-frame pixels, while compositing allocates two full logical-screen
BufferedImages. Large logical dimensions with a small on-card target could pass the check and still allocate very large working buffers (risk of OOM / process kill).PR type
Why
Regression risk from commit
7bb656d3(fix(desktop): sharpen posters and stabilize GIF render), which composes GIF frames in logical space before scaling. The guardapproxBytes > MaxDecodedGifBytesno longer reflected peak decode memory becauselogicalCanvasandpreviousLogicalCanvasarebaseW × baseHeach.Concrete scenario: GIF with logical screen 3000×3000 (within
MaxLogicalGifPixels), shown in a small collection card socanvasW/canvasHare ~200×200 andframeCount × output bytesstays under 64 MiB, but2 × 3000 × 3000 × 4≈ 68 MiB is allocated before counting frame bitmaps—exceeding the intended cap and risking OOM. The app then falls back to static Coil only if decode completes without exhausting memory; the failure mode is worse under memory pressure.Policy check
Testing
./gradlew :composeApp:compileKotlinDesktopwas attempted; build failed in this environment due to unresolved dependencyorg.openani.mediamp:mediamp-mpv:0.1.0-dev-1(classpath), not due to this change.read_lintson the edited file: no issues.Screenshots / Video (UI changes only)
N/A
Breaking changes
None. Some very large logical-dimension GIFs that previously attempted decode may now bail earlier and use the existing static Coil fallback (same as other decode failures).
Linked issues
N/A (automation / critical bug sweep).