Problem
Across the application (in connections panels, driver icons, and stats views), material.Image.asset and material.Image.file are used to render icons and graphics at small logical sizes (e.g., 24x24 or 32x32). However, these images are loaded without specifying cacheWidth or cacheHeight.
Flutter's image decoder will decode the full original resolution of the asset or file into RAM by default. If a user installs an extension with a 1024x1024 PNG icon, the application will hold the entire ~4MB raw bitmap in memory, even though it's only displayed at 24x24 pixels on screen. This can lead to excessive memory bloat and eventual OOM (Out Of Memory) crashes if many extensions or database types are loaded.
Proposed Solution
Supply cacheWidth and cacheHeight parameters to Image.asset and Image.file when the target display size is known. The dimensions should be scaled by the device's pixel ratio to keep crisp rendering on high DPI screens.
Trade-offs
- Pros: Massive reduction in application memory footprint (RAM usage). Faster image decode times since the decoder downsamples during reading.
- Cons: If the same image needs to be displayed at a much larger size elsewhere, Flutter will have to cache and decode a second copy of it at the larger size. (In our case, driver icons are mostly small, so this is fine). Requires careful pixel ratio calculation.
Impact
- Risk: Low. Worst case is slight blurriness if the
cacheWidth is calculated too small for a high-DPI screen.
- Affected Files:
lib/features/connections/driver_icon.dart
lib/features/connections/connections_panel_*.dart
lib/features/postgresql/postgres_stats_view.dart
lib/features/mysql/mysql_stats_view.dart
Problem
Across the application (in connections panels, driver icons, and stats views),
material.Image.assetandmaterial.Image.fileare used to render icons and graphics at small logical sizes (e.g., 24x24 or 32x32). However, these images are loaded without specifyingcacheWidthorcacheHeight.Flutter's image decoder will decode the full original resolution of the asset or file into RAM by default. If a user installs an extension with a 1024x1024 PNG icon, the application will hold the entire ~4MB raw bitmap in memory, even though it's only displayed at 24x24 pixels on screen. This can lead to excessive memory bloat and eventual OOM (Out Of Memory) crashes if many extensions or database types are loaded.
Proposed Solution
Supply
cacheWidthandcacheHeightparameters toImage.assetandImage.filewhen the target display size is known. The dimensions should be scaled by the device's pixel ratio to keep crisp rendering on high DPI screens.Trade-offs
Impact
cacheWidthis calculated too small for a high-DPI screen.lib/features/connections/driver_icon.dartlib/features/connections/connections_panel_*.dartlib/features/postgresql/postgres_stats_view.dartlib/features/mysql/mysql_stats_view.dart