mangayomi-mirror/lib/modules/widgets
Mehakdeep Singh 861ee65113 perf(library): decode covers at thumbnail resolution to cut image-cache RAM
Refs #609 (high RAM with stutters).

Manga / anime covers from sources are typically 720x1080 or larger
(~3 MB decoded RGBA per cover). The library grid, library list and
generic browse / search card widgets render those covers at roughly
150x220 logical pixels, but every cover decoded to its full source
resolution and that decoded bitmap landed in Flutter's `imageCache`.
With 30-50 covers in flight during a normal scroll, the default
100 MB cache filled and the engine started evicting + re-decoding
aggressively — exactly the symptom in #609 (stutters + high RAM).

Mangayomi already had `ExtendedResizeImage` available via the
`extended_image_library` package and used it in one place
(`cachedCompressedNetworkImage`, called only from the History
screen). This commit generalises that pattern.

Add a `coverProvider()` helper in `lib/utils/cached_network.dart`
that wraps `CustomExtendedNetworkImageProvider` in
`ExtendedResizeImage` with a 200 KB encoded budget — sharp at
typical thumbnail size on high-DPR screens, ~3.6x smaller decoded
than a full-resolution cover. Pass through the same `cache` /
`cacheMaxAge` knobs the underlying provider exposes so existing
disk-cache behaviour is preserved.

Swap the three high-traffic thumbnail call sites to use it:

* `lib/modules/library/widgets/library_gridview_widget.dart`
* `lib/modules/library/widgets/library_listview_widget.dart`
* `lib/modules/widgets/manga_image_card_widget.dart`
  (both `MangaImageCardWidget` and `MangaImageCardListTileWidget`,
  used by browse and search results)

Deliberately not changed:

* The manga / anime detail page hero cover — large display, full
  resolution is appropriate.
* Reader pages — already memory-managed by `ChapterPreloadManager`
  and need full resolution for actual reading.
* `cachedNetworkImage()` and other lower-traffic thumbnail surfaces
  (tracker results, calendar, recommendation grid). Easy to extend
  in a follow-up if anyone asks; kept narrow here so review is
  manageable.

Verified

* `flutter analyze` clean on every touched file
* `flutter build macos --release` succeeds
* Smoke-tested on macOS with the local-all-fixes build: library
  grid, library list and browse card all render identical-looking
  covers at typical thumbnail sizes; no visible quality regression
  at the displayed scale
2026-05-09 23:37:44 -07:00
..
base_library_tab_screen.dart Group related functions using an extension 2025-12-29 23:19:31 +01:00
bottom_select_bar.dart Extract reusable Select Bar and Button widgets 2025-07-28 16:29:30 +02:00
bottom_text_widget.dart dart format 2025-05-30 17:43:42 +01:00
category_selection_dialog.dart Refactor an fix 2025-11-09 01:15:27 +01:00
cover_view_widget.dart performance+ 2026-04-12 23:03:07 +02:00
custom_draggable_tabbar.dart fix animation 2025-07-16 14:02:59 +02:00
custom_extended_image_provider.dart Move cacheDir creation to storage_provider 2025-12-17 20:55:41 +01:00
custom_sliver_grouped_list_view.dart Refactor and update dependencies for Isar and Riverpod 2025-10-29 13:08:42 +01:00
error_text.dart dart format 2025-02-23 15:31:49 +01:00
gridview_widget.dart dart format 2025-05-30 17:43:42 +01:00
listview_widget.dart refactor: replace ListView with SuperListView across multiple widgets 2025-03-09 12:02:38 +01:00
loading_icon.dart some fixes 2024-05-14 13:06:46 +01:00
manga_image_card_widget.dart perf(library): decode covers at thumbnail resolution to cut image-cache RAM 2026-05-09 23:37:44 -07:00
progress_center.dart dart format 2025-02-23 15:31:49 +01:00