Skip to content

[Bug]: OutOfMemoryError in GalleryFragment when closing 2048px WebP previews (Android 16) #16949

@Gdo23678

Description

@Gdo23678

⚠️ Before posting ⚠️

  • This is a bug, not a question or an enhancement.
  • I've searched for similar issues and didn't find a duplicate.
  • I've written a clear and descriptive title for this issue, not just "Bug" or "Crash".
  • I agree to follow Nextcloud's Code of Conduct.

Steps to reproduce

  1. Configure Nextcloud server with high-resolution previews: 'preview_max_x' => 2048, 'preview_max_y' => 2048 and 'preview_format' => 'webp'.
  2. Open the Nextcloud Android app (33.1.0) on an Android 16 device.
  3. Navigate to the "Media" (Gallery) tab.
  4. Scroll through the gallery to populate the app's cache and heap with thumbnails.
  5. Open a large original photo (e.g., a 12MP+ camera shot).
  6. Press the back button or the close button to return to the gallery overview.

Expected behaviour

While videos and highly compressed images (WhatsApp) close with a 2-3 second delay (heavy GC), large camera photos trigger an immediate crash because the heap limit (512MB) is reached during the transition back to the GalleryFragment.

Actual behaviour

The app freezes with a black screen.

For smaller images (e.g. WhatsApp): The screen stays black for 2-3 seconds (likely due to heavy Garbage Collection) before returning to the gallery.

For large camera photos: The app crashes immediately. The provided stacktrace shows an OutOfMemoryError (OOM) because the heap limit (512MB) is exceeded during the transition back to the GalleryFragment.

Android version

16 (SDK 36)

Device brand and model

Xiaomi 15 (24129PN74G / dada)

Stock or custom OS?

Stock

Nextcloud android app version

33.1.0 (gplay)

Nextcloud server version

33.0.3

Using a reverse proxy?

Yes

Android logs

Cause of error

Exception in thread "main" java.lang.OutOfMemoryError: Failed to allocate a 256 byte allocation with 1354320 free bytes and 1322KB until OOM, target footprint 536870912, growth limit 536870912; giving up on allocation because <1% of heap free after GC.
at com.owncloud.android.datamodel.FileDataStorageManager.createFileInstance(FileDataStorageManager.java:1341)
at com.owncloud.android.datamodel.FileDataStorageManager.getGalleryItems(FileDataStorageManager.java:2649)
at com.owncloud.android.datamodel.FileDataStorageManager.getAllGalleryItems(FileDataStorageManager.java:2638)
at com.owncloud.android.ui.adapter.GalleryAdapter.showAllGalleryItems(GalleryAdapter.kt:218)
at com.owncloud.android.ui.fragment.GalleryFragment.showAllGalleryItems(GalleryFragment.java:411)
at com.owncloud.android.ui.fragment.GalleryFragment.handleSearchEvent(GalleryFragment.java:256)
at com.owncloud.android.ui.fragment.GalleryFragment.onActivityCreated(GalleryFragment.java:175)
at androidx.fragment.app.Fragment.performActivityCreated(Fragment.java:3161)
at androidx.fragment.app.FragmentStateManager.activityCreated(FragmentStateManager.java:639)
at androidx.fragment.app.FragmentStateManager.moveToExpectedState(FragmentStateManager.java:289)
at androidx.fragment.app.FragmentManager.executeOpsTogether(FragmentManager.java:2214)
at androidx.fragment.app.FragmentManager.removeRedundantOperationsAndExecute(FragmentManager.java:2109)
at androidx.fragment.app.FragmentManager.execPendingActions(FragmentManager.java:2052)
at androidx.fragment.app.FragmentController.execPendingActions(FragmentController.java:496)
at androidx.fragment.app.FragmentActivity.onResume(FragmentActivity.java:311)
at com.owncloud.android.ui.activity.BaseActivity.onResume(BaseActivity.java:106)
at com.owncloud.android.ui.activity.FileActivity.onResume(FileActivity.java:286)
at com.owncloud.android.ui.activity.FileDisplayActivity.onResume(FileDisplayActivity.kt:1360)
at android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1733)
at android.app.Activity.performResume(Activity.java:9611)
at android.app.ActivityThread.performResumeActivity(ActivityThread.java:6122)
at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:6170)
at android.app.servertransaction.ResumeActivityItem.execute(ResumeActivityItem.java:73)
at android.app.servertransaction.ActivityTransactionItem.execute(ActivityTransactionItem.java:63)
at android.app.servertransaction.TransactionExecutor.executeLifecycleItem(TransactionExecutor.java:172)
at android.app.servertransaction.TransactionExecutor.executeTransactionItems(TransactionExecutor.java:104)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:83)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:3103)
at android.os.Handler.dispatchMessage(Handler.java:114)
at android.os.Looper.loopOnce(Looper.java:274)
at android.os.Looper.loop(Looper.java:369)
at android.app.ActivityThread.main(ActivityThread.java:10090)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:616)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1137)

App information

  • ID: com.nextcloud.client
  • Version: 330010090
  • Build flavor: gplay

Device information

  • Brand: Xiaomi
  • Device: dada
  • Model: 24129PN74G
  • Id: BP2A.250605.031.A3
  • Product: dada_eea

Firmware

  • SDK: 36
  • Release: 16
  • Incremental: OS3.0.301.0.WOCEUXM

Server error logs

Additional information

No response

Metadata

Metadata

Assignees

Labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions