nextcloud / android

📱 Nextcloud Android app
https://play.google.com/store/apps/details?id=com.nextcloud.client
GNU General Public License v2.0
4.18k stars 1.75k forks source link

Folders with large number of files causes scroll to freeze and navigation to lag and causes ANR at times #10624

Open DistortedBit opened 2 years ago

DistortedBit commented 2 years ago

⚠️ Before posting ⚠️

Steps to reproduce

Preparation:

We will need a directory with 500 images at least. More images will make this bug even more obvious.

Case 1: Loading of the folder causes scroll to freeze

  1. Browse to mobile app and then photos directory under all files menu.
  2. Click LargeDir
  3. Initiate a fling scroll immediately as the list of files appears on large dir.
  4. You will see the scroll halts and resumes intermittently as the directory loads with the loader sign visible. It's worse if view is set to Grid instead of row.
  5. After loading is completed, it no longer freezes during scroll.

Case 2: Going back and forth in between directories causes very delayed transitions from one directory to another

Case 3: Moving pictures out of the directory causes freezing and ANR

  1. Navigate to our LargeDir and wait for it to complete loading.
  2. Select 50 pictures RANDOMLY in that directory. Attempt to move them to a different directory.
  3. After choosing the destination directory, the loading icon on the LargeDir list will appear and at this point the list will freeze randomly just like in case 1. It'll keep freezing scroll until all files have been moved

These 3 bugs are making overall usability of the app very difficult. I hope I was able to give you proper reproduction steps. If you still need help to reproduce it, I can post videos of the issues.

Expected behaviour

In none of the above cases it should freeze the UI to prevent user from interacting

Actual behaviour

UI freezes and prevents users from interacting.

Android version

12

Device brand and model

Google Pixel 6

Stock or custom OS?

Custom (explain in "additional information")

Nextcloud android app version

3.21.0

Nextcloud server version

I don't know, whatever try.nextcloud.com was running on Aug 13 2022. I no longer have access to the account.

Using a reverse proxy?

I don't know

Android logs

No response

Server error logs

No response

Additional information

It seems that during loading, a lot of updates are being pushed to the RecyclerView. Due to which it freezes the UI. I have experienced this with different apps that I've worked on in the past. I can run some profiling and debug this if there's nobody available to work on it.

The laggy navigation transition is most likely due to

  1. A lot of clean up code on main thread in fragment onDetach or onDestroy
  2. RecyclerView ViewHolders are not optimized so on layout inflate it's spending a lot of time inflating a large number of ViewHolders. Easiest solution to this is to use a shared pool of ViewHolders amongst all File List fragments. This way they'll only inflate the first time and will be re used regardless of the number of times fragments are swapped.
witchcraftsman commented 2 years ago

I'm also having this issue. Happening on upload screen with 1000+ uploads/

Here's the error log:

Cause of error

Exception in thread "Thread-9" java.lang.OutOfMemoryError: Failed to allocate a 48 byte allocation with 4633480 free bytes and 4524KB until OOM, target footprint 536870912, growth limit 536870912; giving up on allocation because <1% of heap free after GC.
    at java.io.ByteArrayOutputStream.<init>(ByteArrayOutputStream.java:79)
    at java.io.ByteArrayOutputStream.<init>(ByteArrayOutputStream.java:64)
    at sun.security.util.DerOutputStream.<init>(DerOutputStream.java:66)
    at sun.security.util.DerValue.toByteArray(DerValue.java:859)
    at sun.security.x509.RDN.<init>(RDN.java:241)
    at sun.security.x509.X500Name.parseDER(X500Name.java:803)
    at sun.security.x509.X500Name.<init>(X500Name.java:317)
    at javax.security.auth.x500.X500Principal.<init>(X500Principal.java:226)
    at com.android.org.conscrypt.OpenSSLX509Certificate.getSubjectX500Principal(OpenSSLX509Certificate.java:502)
    at okhttp3.internal.tls.BasicTrustRootIndex.<init>(BasicTrustRootIndex.kt:28)
    at okhttp3.internal.platform.Platform.buildTrustRootIndex(Platform.kt:163)
    at okhttp3.internal.platform.Platform.buildCertificateChainCleaner(Platform.kt:160)
    at okhttp3.internal.platform.Android10Platform.buildCertificateChainCleaner(Android10Platform.kt:82)
    at okhttp3.internal.tls.CertificateChainCleaner$Companion.get(CertificateChainCleaner.kt:42)
    at okhttp3.OkHttpClient$Builder.sslSocketFactory(OkHttpClient.kt:870)
    at com.nextcloud.common.PlainClient$Companion.createDefaultClient(PlainClient.kt:62)
    at com.nextcloud.common.PlainClient$Companion.access$createDefaultClient(PlainClient.kt:47)
    at com.nextcloud.common.PlainClient.<init>(PlainClient.kt:45)
    at com.nextcloud.client.network.ClientFactoryImpl.createPlainClient(ClientFactoryImpl.java:94)
    at com.nextcloud.client.network.ConnectivityServiceImpl.isInternetWalled(ConnectivityServiceImpl.java:79)
    at com.owncloud.android.files.services.FileUploader.retryFailedUploads(FileUploader.java:1093)
    at com.owncloud.android.utils.FilesSyncHelper.lambda$restartJobsIfNeeded$0(FilesSyncHelper.java:240)
    at com.owncloud.android.utils.FilesSyncHelper$$ExternalSyntheticLambda0.run(Unknown Source:10)
    at java.lang.Thread.run(Thread.java:1012)

App information

Device information

Firmware

AndyXheli commented 2 years ago

Same issue here I open the photos app says loading and nothing loads if I clear the app cache works for a little then same issue

RikkiBC commented 1 year ago

Same issue here.

Use case: migrating photos from Google Photos to NextCloud.

Moving directories of old albums to new locations via NextCloud app downloaded from f-droid.

Temporary freezing of scrolling and unresponsive app but managed to move the folders with patience. However, on going to the new folder location and opening a couple to test, encountered app error as per below.

Device: Samsung S22 Ultra with 12GB RAM, so shouldn't be a phone issue.

Stack trace being very helpful. Can't throw out of memory error because it encountered an out of memory error 😁

Cause of error

Exception in thread "Thread-37" java.lang.OutOfMemoryError: OutOfMemoryError thrown while trying to throw OutOfMemoryError; no stack trace available

App information

Device information

Firmware

brianjmurrell commented 1 year ago

I also see lots of ANRs with large directories while trying to resolve [non*]conflicts.

* 99.9% of these conflicts are not in fact conflicts but are simply duplicates. Everything about the local and remote files is identical. Those should not trigger conflict resolution but should just be treated as "already there, nothing to do with this one".

invario commented 1 year ago

It's been YEARS of this bug and it hasn't been resolved. I myself personally had submitted a bug report for this and linked numerous other reports. I've stopped using this app except to check maybe every month to see if it's been fixed. I've since started using a different app to vote my NextCloud photos. Search it in Play Store (it's Android only). It has an actual timeline on the scrollbar like Google Photos and it's FAST.

meichthys commented 7 months ago

I also regularly see this in my Photos directory on Android. I have ~20k photos in the directory and anytime i navigate to the directory the UI slows to a crawl and produces ANRs consistently.