Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

app crash on browsing folder with a lot of photos #10338

Open
vladbejenaru opened this issue Jun 4, 2022 · 18 comments
Open

app crash on browsing folder with a lot of photos #10338

vladbejenaru opened this issue Jun 4, 2022 · 18 comments
Labels
approved bug feature: files feature: previews and thumbnails performance: general/non-specific lag, ANR, etc and rarer exceptions/errors that don't have their own labels

Comments

@vladbejenaru
Copy link

Cause of error

Exception in thread "main" java.util.concurrent.RejectedExecutionException: Task android.os.AsyncTask$3@fb5b3d8 rejected from java.util.concurrent.ThreadPoolExecutor@e399331[Running, pool size = 17, active threads = 17, queued tasks = 128, completed tasks = 26]
    at java.util.concurrent.ThreadPoolExecutor$AbortPolicy.rejectedExecution(ThreadPoolExecutor.java:2078)
    at java.util.concurrent.ThreadPoolExecutor.reject(ThreadPoolExecutor.java:843)
    at java.util.concurrent.ThreadPoolExecutor.execute(ThreadPoolExecutor.java:1389)
    at android.os.AsyncTask.executeOnExecutor(Unknown Source:34)
    at com.owncloud.android.utils.DisplayUtils.setThumbnail(DisplayUtils.java:952)
    at com.owncloud.android.ui.adapter.OCFileListDelegate.bindGridViewHolder(OCFileListDelegate.kt:92)
    at com.owncloud.android.ui.adapter.OCFileListAdapter.onBindViewHolder(OCFileListAdapter.java:366)
    at androidx.recyclerview.widget.RecyclerView$Adapter.onBindViewHolder(RecyclerView.java:7254)
    at androidx.recyclerview.widget.RecyclerView$Adapter.bindViewHolder(RecyclerView.java:7337)
    at androidx.recyclerview.widget.RecyclerView$Recycler.tryBindViewHolderByDeadline(RecyclerView.java:6194)
    at androidx.recyclerview.widget.RecyclerView$Recycler.tryGetViewHolderForPositionByDeadline(RecyclerView.java:6460)
    at androidx.recyclerview.widget.GapWorker.prefetchPositionWithDeadline(GapWorker.java:288)
    at androidx.recyclerview.widget.GapWorker.flushTaskWithDeadline(GapWorker.java:345)
    at androidx.recyclerview.widget.GapWorker.flushTasksWithDeadline(GapWorker.java:361)
    at androidx.recyclerview.widget.GapWorker.prefetch(GapWorker.java:368)
    at androidx.recyclerview.widget.GapWorker.run(GapWorker.java:399)
    at android.os.Handler.handleCallback(Unknown Source:2)
    at android.os.Handler.dispatchMessage(Unknown Source:4)
    at android.os.Looper.loop(Unknown Source:152)
    at android.app.ActivityThread.main(Unknown Source:65)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(Unknown Source:11)
    at com.android.internal.os.ZygoteInit.main(Unknown Source:338)

App information

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

Device information

  • Brand: Xiaomi
  • Device: clover
  • Model: MI PAD 4 PLUS
  • Id: OPM1.171019.019
  • Product: clover

Firmware

  • SDK: 27
  • Release: 8.1.0
  • Incremental: V10.3.1.0.ODJCNXM
@ezaquarii
Copy link
Collaborator

From https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/ThreadPoolExecutor.html:

New tasks submitted in method execute(Runnable) will be rejected when the Executor has been shut down, and also when the Executor uses finite bounds for both maximum threads and work queue capacity, and is saturated. In either case, the execute method invokes the RejectedExecutionHandler.rejectedExecution(Runnable, ThreadPoolExecutor) method of its RejectedExecutionHandler.

Exception in thread "main" java.util.concurrent.RejectedExecutionException: 
Task android.os.AsyncTask$3@fb5b3d8 rejected from java.util.concurrent.ThreadPoolExecutor@e399331[Running, pool size = 17, active threads = 17, queued tasks = 128, completed tasks = 26]

So it seems that the queue is full. This is Android limitation (look for MAXIMUM_POOL_SIZE = 128;) It seems that the app is doing a lot of async work in the background and similar errors will be popping up as time passes.

The solution is simple: stop using async tasks. AsyncTask is badly designed and deprecated in favour of generic concurrency primitives. I see little sense in tacking this specific crash - it require more comprehensive overhaul.

@AlvaroBrey @tobiasKaminsky FYI

@ezaquarii ezaquarii added the bug label Jun 4, 2022
@ezaquarii
Copy link
Collaborator

@vladbejenaru How often does it happen? Was it a one-off event?

@vladbejenaru
Copy link
Author

hi. It happened only once. Suggestion to post here came from the crash and I thought it may help you.

@ezaquarii
Copy link
Collaborator

ezaquarii commented Jun 5, 2022 via email

@svenb1234
Copy link

Is #10284 a dup?

@svenb1234
Copy link

#10203 as well?

@ezaquarii
Copy link
Collaborator

ezaquarii commented Jun 7, 2022

@svenb1234
Yes, this is the same problem.

We can try moving those tasks to a dedicated thread pool. That does not solve the fundamental issue of launching so many tasks that are not interruptible. If we make the queue deeper, we can cause some performance degradation when user scrolls down large list. If the task involves network I/O, this can get serious.

Alternatively, we could just catch this exception and do not show a miniature. That would cause slight visual degradation, but won't cause excessive CPU load with large amount of bg tasks.

@AlvaroBrey @tobiasKaminsky comments?

This was referenced Jun 7, 2022
@AlvaroBrey
Copy link
Member

I can't figure out how to trigger this, I get the following when trying to scroll fast enough to reach 128 tasks:

2022-06-08 13:11:29.884 8801-8801/com.nextcloud.client V/ThumbnailsCacheManager: Cancelled generation of thumbnail for a reused imageView

It looks like this cancellation might be failing in some cases?

@meldarionqeusse
Copy link

meldarionqeusse commented Jun 10, 2022

I have been getting this issue for the past month dismissed it at first cause I couldn't find a similar issue happening to someone else and because it happened once. But now it's happening everytime.

What's more I am thinking that it's bricking my raspberry pi after a few minutes that the bug occurs. Forcing me to restart.

This is the error log generated

Cause of error

Exception in thread "main" java.util.concurrent.RejectedExecutionException: Task android.os.AsyncTask$3@10790db rejected from java.util.concurrent.ThreadPoolExecutor@2bd9778[Running, pool size = 17, active threads = 17, queued tasks = 128, completed tasks = 224]
    at java.util.concurrent.ThreadPoolExecutor$AbortPolicy.rejectedExecution(ThreadPoolExecutor.java:2085)
    at java.util.concurrent.ThreadPoolExecutor.reject(ThreadPoolExecutor.java:848)
    at java.util.concurrent.ThreadPoolExecutor.execute(ThreadPoolExecutor.java:1394)
    at android.os.AsyncTask.executeOnExecutor(AsyncTask.java:651)
    at com.owncloud.android.utils.DisplayUtils.setThumbnail(DisplayUtils.java:952)
    at com.owncloud.android.ui.adapter.OCFileListDelegate.bindGridViewHolder(OCFileListDelegate.kt:92)
    at com.owncloud.android.ui.adapter.OCFileListAdapter.onBindViewHolder(OCFileListAdapter.java:366)
    at androidx.recyclerview.widget.RecyclerView$Adapter.onBindViewHolder(RecyclerView.java:7254)
    at androidx.recyclerview.widget.RecyclerView$Adapter.bindViewHolder(RecyclerView.java:7337)
    at androidx.recyclerview.widget.RecyclerView$Recycler.tryBindViewHolderByDeadline(RecyclerView.java:6194)
    at androidx.recyclerview.widget.RecyclerView$Recycler.tryGetViewHolderForPositionByDeadline(RecyclerView.java:6460)
    at androidx.recyclerview.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:6300)
    at androidx.recyclerview.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:6296)
    at androidx.recyclerview.widget.LinearLayoutManager$LayoutState.next(LinearLayoutManager.java:2330)
    at androidx.recyclerview.widget.GridLayoutManager.layoutChunk(GridLayoutManager.java:572)
    at androidx.recyclerview.widget.LinearLayoutManager.fill(LinearLayoutManager.java:1591)
    at androidx.recyclerview.widget.LinearLayoutManager.scrollBy(LinearLayoutManager.java:1395)
    at androidx.recyclerview.widget.LinearLayoutManager.scrollVerticallyBy(LinearLayoutManager.java:1136)
    at androidx.recyclerview.widget.GridLayoutManager.scrollVerticallyBy(GridLayoutManager.java:386)
    at androidx.recyclerview.widget.RecyclerView.scrollStep(RecyclerView.java:1972)
    at androidx.recyclerview.widget.RecyclerView$ViewFlinger.run(RecyclerView.java:5476)
    at android.view.Choreographer$CallbackRecord.run(Choreographer.java:1004)
    at android.view.Choreographer.doCallbacks(Choreographer.java:816)
    at android.view.Choreographer.doFrame(Choreographer.java:748)
    at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:990)
    at android.os.Handler.handleCallback(Handler.java:873)
    at android.os.Handler.dispatchMessage(Handler.java:99)
    at android.os.Looper.loop(Looper.java:280)
    at android.app.ActivityThread.main(ActivityThread.java:6706)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)

App information

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

Device information

  • Brand: Sony
  • Device: G8441
  • Model: G8441
  • Id: 47.2.A.11.228
  • Product: G8441

Firmware

  • SDK: 28
  • Release: 9
  • Incremental: 3311891731

@meldarionqeusse

This comment was marked as off-topic.

@AlvaroBrey

This comment was marked as off-topic.

@AlvaroBrey
Copy link
Member

Can any of the affected users give clear reproduction steps? Is it browsing in the normal files browser, or in the gallery/media screen? Also, does it happen immediately on opening the folder, or after some scrolling?

@ezaquarii
Copy link
Collaborator

Try putting a sleep into the thumbnail async task to slow it down a bit. I think async taks are not cancelled so they should easily accumulate triggering the condition.

@meldarionqeusse
Copy link

@AlvaroBrey no I am not using the media just browsing the folder normally. The issue does not happen with the media folder. I am not sure if videos play here but I tried to caputre it here
https://user-images.githubusercontent.com/21668964/173192301-512e5d3a-9436-4abb-8474-4e3dbf9653b1.mp4

@godfuture
Copy link

godfuture commented Dec 5, 2022

Same issue here with Android 3.22.1 from PlayStore.
Folder with many fotos. Thumbnails are missing. Thumbnails start to pop up, but the NC app gets a bit sluggish. It starts to hang from time to time. Scrolling is stuttering. Still, close to none network traffic, even in LAN environment. Sooner or later the app crashes with the stack seen above.

@yanakis71
Copy link

For this issue/reason I gave up on Nextcloud (Docker install). I wanted to replace Onedrive but Android app is crashing every time on my 4000+ pics folder. Additionally, thumbnails display is painfully slow

@joshtrichards joshtrichards added the performance: general/non-specific lag, ANR, etc and rarer exceptions/errors that don't have their own labels label Oct 12, 2023
@pgorgita
Copy link

I have the same problem, always when trying to explore a Folder with all my Fotos and Videos:

Cause of error

Exception in thread "main" java.lang.OutOfMemoryError: Failed to allocate a 16 byte allocation with 977488 free bytes and 954KB until OOM, target footprint 536870912, growth limit 536870912; giving up on allocation because <1% of heap free after GC.
    at java.lang.Float.valueOf(Float.java:467)
    at android.animation.PropertyValuesHolder$FloatPropertyValuesHolder.getAnimatedValue(PropertyValuesHolder.java:1359)
    at android.animation.ValueAnimator.getAnimatedValue(ValueAnimator.java:948)
    at com.elyeproj.loaderviewlibrary.LoaderController.onAnimationUpdate(LoaderController.java:136)
    at android.animation.ValueAnimator.animateValue(ValueAnimator.java:1653)
    at android.animation.ValueAnimator.animateBasedOnTime(ValueAnimator.java:1440)
    at android.animation.ValueAnimator.doAnimationFrame(ValueAnimator.java:1572)
    at android.animation.AnimationHandler.doAnimationFrame(AnimationHandler.java:307)
    at android.animation.AnimationHandler.-$$Nest$mdoAnimationFrame(Unknown Source:0)
    at android.animation.AnimationHandler$1.doFrame(AnimationHandler.java:86)
    at android.view.Choreographer$CallbackRecord.run(Choreographer.java:1299)
    at android.view.Choreographer$CallbackRecord.run(Choreographer.java:1309)
    at android.view.Choreographer.doCallbacks(Choreographer.java:923)
    at android.view.Choreographer.doFrame(Choreographer.java:847)
    at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:1283)
    at android.os.Handler.handleCallback(Handler.java:942)
    at android.os.Handler.dispatchMessage(Handler.java:99)
    at android.os.Looper.loopOnce(Looper.java:226)
    at android.os.Looper.loop(Looper.java:313)
    at android.app.ActivityThread.main(ActivityThread.java:8762)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:604)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1067)

App information

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

Device information

  • Brand: samsung
  • Device: y2s
  • Model: SM-G986B
  • Id: TP1A.220624.014
  • Product: y2sxxx

Firmware

  • SDK: 33
  • Release: 13
  • Incremental: G986BXXSKHXEA

@godfuture
Copy link

For this issue/reason I gave up on Nextcloud (Docker install). I wanted to replace Onedrive but Android app is crashing every time on my 4000+ pics folder. Additionally, thumbnails display is painfully slow

You are not the only one. The nextcloud app is still half baked. I wonder, and I guess you do as well, that nextcloud is already a really big project, but still the mobile app is behaving beta....sometimes even alpha. Missing thumbnails, crashing, slow, hanging, strange implementation of android notifications, some features just dont work yet. In short - unrealiable at best.

For realiable file upload, I am using FolderSync (https://play.google.com/store/apps/details?id=dk.tacit.android.foldersync.lite&pcampaignid=web_share).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved bug feature: files feature: previews and thumbnails performance: general/non-specific lag, ANR, etc and rarer exceptions/errors that don't have their own labels
Projects
None yet
Development

No branches or pull requests

9 participants