Skip to content

[Bug] OOM crash when scrolling "On Device" photos full-resolution bitmaps loaded without downsamplingΒ #9416

@dhgatjeye

Description

@dhgatjeye

Description

Environment

  • Device RAM: 4 GB
  • Android 14 / One UI 6.1
  • Tab: "On Device" (local gallery)
  • Reproducible with: any smartphone camera in the 50 MP range

What happens

When browsing local photos in the "On Device" tab, the app crashes hard after swiping through a handful of images. The Android home screen flickers and reloads after the crash a classic sign of the process being killed by the OS. Before the crash, photos stay blurry for several seconds while swiping and the UI freezes noticeably.

Traced to zoomable_image.dart

I dug into the source and found the likely lines responsible.

In apps/photos/lib/ui/viewer/file/zoomable_image.dart, line 75:

bool get isTooLargeImage => _photo.width * _photo.height > 100000000; // 100 MP

And around lines 398–418, inside _onFileLoaded:

if (isTooLargeImage) {
  // limits image to ~50 MP β€” fine
} else {
  // anything under 100 MP is loaded AS-IS, no cacheWidth / cacheHeight
  imageProvider = Image.file(
    file,
    gaplessPlayback: true,
  ).image;
}
if (mounted) {
  precacheImage(imageProvider, context, ...); // decoded fully into RAM
}

The threshold is 100 MP, so every photo taken by a normal smartphone (12 MP – 50 MP) falls below it and gets decoded into RAM at full resolution with no cacheWidth or cacheHeight constraint.

On top of that, detail_page.dart (around lines 328 and 395) uses PageView.builder with a _preloadFiles mechanism that pre-loads the previous and next photos while you view the current one. During a fast swipe the app can be holding 3–4 fully decoded bitmaps simultaneously, pushing through RAM and android kills the process at that point, which is why the home screen reloads rather than the app exiting cleanly. The blur-then-freeze pattern follows from the same cause: the image stays in its low-quality thumbnail state while the full decode queues up on the CPU/GPU, a process that can take several too much seconds for a 50 MP file.

Version

v1.3.16

What product are you using?

Ente Photos

What platform are you using?

Mobile - Android

Metadata

Metadata

Assignees

No one assigned

    Labels

    - photosRelates to Ente Photos--mobilePlatform is mobile

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions