Skip to content

fix(ui): stop requesting image thumbnails larger than the original - #2984

Merged
xsahil03x merged 2 commits into
v9from
fix/v9-thumbnail-no-upscale
Sep 22, 2026
Merged

xsahil03x merged 2 commits into
v9from
fix/v9-thumbnail-no-upscale

Conversation

@xsahil03x

@xsahil03x xsahil03x commented Sep 21, 2026

Copy link
Copy Markdown
Member

ThumbnailSizeCalculator sized a thumbnail request as the layout box fitted to the image's aspect ratio, multiplied by the device pixel ratio. originalSize was read only for that ratio and never used as a ceiling, so the request was min(originalPixels, boxLogical) × devicePixelRatio with 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-ladder changes the same tail of calculate(); 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 test on thumbnail_size_calculator_test.dart (22 passing), flutter analyze --fatal-infos and dart format clean 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

@coderabbitai

coderabbitai Bot commented Sep 21, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Advanced

Run ID: 854949a6-6dda-40c2-a6c9-4197d2712d9b

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@xsahil03x
xsahil03x force-pushed the fix/v9-thumbnail-no-upscale branch 3 times, most recently from 14da5f3 to da9f645 Compare September 21, 2026 23:57
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>
@xsahil03x
xsahil03x force-pushed the fix/v9-thumbnail-no-upscale branch from da9f645 to e596e51 Compare September 21, 2026 23:58
@codecov

codecov Bot commented Sep 22, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
⚠️ Please upload report for BASE (v9@e57f7c4). Learn more about missing BASE report.

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@xsahil03x
xsahil03x enabled auto-merge (squash) September 22, 2026 08:52
@xsahil03x
xsahil03x merged commit 094a326 into v9 Sep 22, 2026
18 checks passed
@xsahil03x
xsahil03x deleted the fix/v9-thumbnail-no-upscale branch September 22, 2026 08:59
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