perf(tabs): release stale image and tab state
Pixel 10 APK / build (push) Successful in 37m12s

This commit is contained in:
Codex
2026-08-10 17:59:50 +02:00
parent 03227320f4
commit aab2bc0cee
10 changed files with 203 additions and 8 deletions
@@ -42,6 +42,7 @@ Future<EquatableImage?> tryDecodeImage(
int? targetWidth,
int? targetHeight,
bool allowUpscaling = true,
bool cacheResult = true,
}) async {
// The decode options are part of the identity of the result, not just of the
// request: the same bytes decoded at a thumbnail's target width and at an
@@ -55,11 +56,13 @@ Future<EquatableImage?> tryDecodeImage(
allowUpscaling: allowUpscaling,
);
final cached = _cache.get(identity);
if (cached?.value != null) {
return cached;
} else if (cached != null) {
_cache.remove(identity);
if (cacheResult) {
final cached = _cache.get(identity);
if (cached?.value != null) {
return cached;
} else if (cached != null) {
_cache.remove(identity);
}
}
try {
@@ -74,7 +77,9 @@ Future<EquatableImage?> tryDecodeImage(
final image = EquatableImage(frameInfo.image, identity: identity);
if (image.value != null && image.value!.width > 0) {
_cache.set(identity, image);
if (cacheResult) {
_cache.set(identity, image);
}
return image;
}
} catch (e, s) {
@@ -87,7 +92,9 @@ Future<EquatableImage?> tryDecodeImage(
targetHeight: targetHeight,
);
if (svgImage != null) {
_cache.set(identity, svgImage);
if (cacheResult) {
_cache.set(identity, svgImage);
}
return svgImage;
}
} catch (svgError, svgStackTrace) {