fix(ui): stop requesting image thumbnails larger than the original - #2984
Conversation
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Advanced Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
14da5f3 to
da9f645
Compare
The thumbnail size was the layout box fitted to the image's aspect ratio and multiplied by the device pixel ratio. The original size was read only for that ratio and never used as a ceiling, so any image smaller than the box times the pixel ratio was requested at more pixels than it holds. Cap the calculated size at the original. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
da9f645 to
e596e51
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## v9 #2984 +/- ##
=====================================
Coverage ? 67.42%
=====================================
Files ? 431
Lines ? 27449
Branches ? 0
=====================================
Hits ? 18508
Misses ? 8941
Partials ? 0 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
ThumbnailSizeCalculatorsized a thumbnail request as the layout box fitted to the image's aspect ratio, multiplied by the device pixel ratio.originalSizewas read only for that ratio and never used as a ceiling, so the request wasmin(originalPixels, boxLogical) × devicePixelRatiowith no upper bound — any image smaller than the box times the pixel ratio was asked for at more pixels than it holds. On a 3x phone with a ~300pt bubble that is every image narrower than ~900px: screenshots, stickers, and anything already downscaled on upload.Those extra pixels do not exist in the source, so they are interpolated. The requested size also reaches the CDN cache key and
memCacheWidth/memCacheHeight, so each device that overshoots by a different amount downloads its own oversized rendition and decodes it into the image cache at that size.The calculated size is now capped at the original.
feat/v9-image-size-ladderchanges the same tail ofcalculate(); when it restacks, the cap must land after the snap (min(snap(w), original)) so the ladder cannot round a capped size back above the source.Verification
flutter testonthumbnail_size_calculator_test.dart(22 passing),flutter analyze --fatal-infosanddart formatclean on the changed files. The four previously-upscaling cases are now covered by tests that assert the original size is returned.FLU-807
🤖 Generated with Claude Code