Merge pull request #727 from mrandhawa14/fix/image-cache-cap

perf(images): cap decoded image cache by platform (refs #609)
This commit is contained in:
Moustapha Kodjo Amadou 2026-05-11 08:36:33 +01:00 committed by GitHub
commit e345c68d83
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -63,6 +63,14 @@ void main(List<String> args) async {
WidgetsFlutterBinding.ensureInitialized();
if (Platform.isLinux && runWebViewTitleBarWidget(args)) return;
// Cap the decoded image cache so a large library grid can't fill the
// default 100 MB ceiling with full-resolution covers and OOM constrained
// mobile heaps. Mobile gets a tight 64 MB; desktop keeps 256 MB. The
// encoded-bytes LRU in CustomExtendedNetworkImageProvider (50 MB) is a
// separate cache and is not affected by this setting.
PaintingBinding.instance.imageCache.maximumSizeBytes =
isMobile ? 64 << 20 : 256 << 20;
// Widget-layer errors (build / layout / paint)
FlutterError.onError = (FlutterErrorDetails details) {
FlutterError.presentError(details); // keep default red-screen in debug