nextcloud / nextcloud/android

java.lang.OutOfMemoryError due to attempting to preload all thumbnails

Open
#16,698 5 comments 0 reactions 0 assignees View on GitHub
0. Needs triage bug hotspot: larger folder handling performance: OOM :brain:
Dominant language
Kotlin
Stars
5.6k
Forks
2k
Avg merge
2d 18h
Merged PRs (30d)
92

Description

### ⚠️ Before posting ⚠️

- [x] This is a **bug**, not a question or an enhancement.
- [x] I've [searched for similar issues](https://github.com/nextcloud/android/issues) and didn't find a duplicate.
- [x] I've written a clear and descriptive title for this issue, not just "Bug" or "Crash".
- [x] I agree to follow Nextcloud's [Code of Conduct](https://nextcloud.com/contribute/code-of-conduct/).

### Steps to reproduce

1. Create a directory with quite a lot of images and videos.
2. Open the directory on mobile.
3. Crash (sometimes).

### Expected behaviour

Only thumbnails for what is currently visible should be loaded.

### Actual behaviour

Thumbnails for all items are loaded resulting in an out of memory error.

### Android version

16

### Device brand and model

Samsung S26 Ultra 512GB/12GB

### Stock or custom OS?

Stock

### Nextcloud android app version

330000090

### Nextcloud server version

33.0.0

### Using a reverse proxy?

Yes

### Android logs

### Cause of error
```java
Exception in thread "Thread-29" java.lang.OutOfMemoryError: Failed to allocate a 16 byte allocation with 25680 free bytes and 25KB until OOM, target footprint 536870912, growth limit 536870912; giving up on allocation because <1% of heap free after GC.
at java.util.Arrays.copyOf(Arrays.java:3785)
at java.io.ByteArrayOutputStream.toByteArray(ByteArrayOutputStream.java:211)
at org.apache.commons.httpclient.ChunkedInputStream.getChunkSizeFromInputStream(ChunkedInputStream.java:296)
at org.apache.commons.httpclient.ChunkedInputStream.nextChunk(ChunkedInputStream.java:221)
at org.apache.commons.httpclient.ChunkedInputStream.read(ChunkedInputStream.java:176)
at org.apache.commons.httpclient.ChunkedInputStream.read(ChunkedInputStream.java:196)
at org.apache.commons.httpclient.ChunkedInputStream.exhaustInputStream(ChunkedInputStream.java:369)
at org.apache.commons.httpclient.ChunkedInputStream.close(ChunkedInputStream.java:346)
at java.io.FilterInputStream.close(FilterInputStream.java:180)
at org.apache.commons.httpclient.AutoCloseInputStream.notifyWatcher(AutoCloseInputStream.java:194)
at org.apache.commons.httpclient.AutoCloseInputStream.close(AutoCloseInputStream.java:158)
at sun.nio.cs.StreamDecoder.implClose(StreamDecoder.java:441)
at sun.nio.cs.StreamDecoder.close(StreamDecoder.java:203)
at java.io.InputStreamReader.close(InputStreamReader.java:192)
at com.android.org.kxml2.io.KXmlParser.close(KXmlParser.java:1757)
at libcore.io.IoUtils$$ExternalSyntheticAutoCloseableDispatcher0.m(D8$$SyntheticClass:0)
at libcore.io.IoUtils.closeQuietly(IoUtils.java:195)
at org.apache.harmony.xml.parsers.DocumentBuilderImpl.parse(DocumentBuilderImpl.java:155)
at javax.xml.parsers.DocumentBuilder.parse(DocumentBuilder.java:107)
at org.apache.jackrabbit.webdav.xml.DomUtil.parseDocument(DomUtil.java:104)
at org.apache.jackrabbit.webdav.client.methods.DavMethodBase.getResponseBodyAsDocument(DavMethodBase.java:113)
at org.apache.jackrabbit.webdav.client.methods.DavMethodBase.getRootElement(DavMethodBase.java:137)
at org.apache.jackrabbit.webdav.client.methods.DavMethodBase.processResponseBody(DavMethodBase.java:282)
at org.apache.commons.httpclient.HttpMethodBase.readResponse(HttpMethodBase.java:1749)
at org.apache.commons.httpclient.HttpMethodBase.execute(HttpMethodBase.java:1098)
at org.apache.commons.httpclient.HttpMethodDirector.executeWithRetry(HttpMethodDirector.java:398)
at org.apache.commons.httpclient.HttpMethodDirector.executeMethod(HttpMethodDirector.java:171)
at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:397)
at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:323)
at com.owncloud.android.lib.common.OwnCloudClient.executeMethod(OwnCloudClient.java:192)
at com.owncloud.android.lib.resources.files.ReadFolderRemoteOperation.run(ReadFolderRemoteOperation.java:62)
at com.owncloud.android.lib.common.operations.RemoteOperation.execute(RemoteOperation.java:193)
at com.owncloud.android.operations.RefreshFolderOperation.fetchAndSyncRemoteFolder(RefreshFolderOperation.java:460)
at com.owncloud.android.operations.RefreshFolderOperation.run(RefreshFolderOperation.java:275)
at com.owncloud.android.lib.common.operations.RemoteOperation.run(RemoteOperation.java:387)
at java.lang.Thread.run(Thread.java:1563)

```

### App information
* ID: `com.nextcloud.client`
* Version: `330000090`
* Build flavor: `gplay`

### Device information
* Brand: `samsung`
* Device: `m3q`
* Model: `SM-S948B`
* Id: `BP4A.251205.006`
* Product: `m3qxeea`

### Firmware
* SDK: `36`
* Release: `16`
* Incremental: `S948BXXS1AZC7`

### Server error logs

```bash

```

### Additional information

1. Maybe a duplicate of https://github.com/nextcloud/android/issues/14932. Trace is identical to the one shown there, but this one occurs on the files tab.
2. Reverse Proxy is only in use for external access as I only have one IPv4 address.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.