fix(images): scale artwork budgets to the physical display

Every artwork budget in the image pipeline was tuned for 1080p surfaces:
the transcode request clamp (1920x1080), the per-type decode caps
(poster 720x1080, thumb 960x540, heroLogo 1000x500, ...) and the TV
image-cache bytes. Those numbers are exact on phones and on the many TV
boxes that composite the app at 1080p, but a TV compositing at 4K
renders every capped image below its slot and GPU-upscales the result:
hero backdrops by 2x, hero logos by ~1.8x, wide episode thumbs by ~1.3x,
shelf posters by ~1.13x - the softness reported against the official
Plex client in #1697, and the class #860's min-2x-DPR fix could not
reach.

DevicePerformance now latches a display budget factor - the display's
shortest physical axis over 1080, capped at 2x - whenever the image
cache budget is applied (startup, post-mount, effects-setting changes).
The transcode clamp, the full-tier decode caps and the TV cache bytes
all scale by it, so a 4K surface fetches and decodes 4K backdrops and
proportionally larger cards. The reduced tier stays pinned to 1.0, and
sub-2.5GiB hardware holds the factor at 1.5 so full-budget 4K art
(~33MB per decode) cannot starve mid-RAM boxes; latching once per
session keeps transcode URLs - and with them the disk cache keys -
stable across rotation and rebuilds.

Whether a given TV composites at 1080p or 4K decides whether any of
this can help, and logs never recorded it: the startup banner and the
log-upload header now carry a display line (physical, logical, DPR,
latched budget) so uploaded logs answer that question directly.

The two pre-existing Windows-host test failures (automotive auto-PiP
gate, backdrop temp-dir teardown lock) reproduce unchanged on the base
commit.
This commit is contained in:
edde746
2026-07-30 01:40:24 +02:00
parent 1bf7aac75b
commit f13f5af6e2
6 changed files with 229 additions and 13 deletions
+55
View File
@@ -174,6 +174,61 @@ void main() {
});
});
group('MediaImageHelper display budget scaling (#1697)', () {
tearDown(DevicePerformance.debugReset);
void latch4kBudget() {
DevicePerformance.debugReset(autoReduced: false, override: VisualEffectsSetting.auto);
DevicePerformance.debugDisplayShortestSideOverride = 2160;
DevicePerformance.debugDetectDisplayBudget();
}
test('a 4K display doubles the full-tier decode caps', () {
latch4kBudget();
expect(
MediaImageHelper.getMemCacheDimensions(displayWidth: 4000, displayHeight: 4000, imageType: ImageType.poster),
(1440, 2160),
);
expect(
MediaImageHelper.getMemCacheDimensions(displayWidth: 4000, displayHeight: 4000, imageType: ImageType.thumb),
(1920, 1080),
);
expect(
MediaImageHelper.getMemCacheDimensions(displayWidth: 4000, displayHeight: 4000, imageType: ImageType.art),
(3840, 2160),
);
expect(
MediaImageHelper.getMemCacheDimensions(displayWidth: 4000, displayHeight: 4000, imageType: ImageType.heroLogo),
(2000, 1000),
);
});
test('a 4K display raises the transcode clamp to the panel size', () {
latch4kBudget();
// A full-screen 4K backdrop request no longer clamps to 1080p...
expect(MediaImageHelper.roundDimensions(3840, 2160), (3840, 2160));
// ...while sub-cap requests keep their exact buckets.
expect(MediaImageHelper.roundDimensions(400, 600), (400, 600));
});
test('a 4K display leaves the reduced tier untouched', () {
DevicePerformance.debugReset(autoReduced: true, override: VisualEffectsSetting.auto);
DevicePerformance.debugDisplayShortestSideOverride = 2160;
DevicePerformance.debugDetectDisplayBudget();
expect(
MediaImageHelper.getMemCacheDimensions(displayWidth: 4000, displayHeight: 4000, imageType: ImageType.poster),
(480, 720),
);
expect(MediaImageHelper.roundDimensions(3840, 2160), (1920, 1080));
});
test('without a latch the 1080p clamps still apply', () {
DevicePerformance.debugReset(autoReduced: false, override: VisualEffectsSetting.auto);
expect(MediaImageHelper.roundDimensions(3840, 2160), (1920, 1080));
});
});
group('MediaImageHelper image type budgets', () {
tearDown(DevicePerformance.debugReset);