nextcloud / talk-android

šŸ“±šŸ˜€ Video & audio calls through Nextcloud on Android
Other
564 stars 249 forks source link

RuntimeException for cancelExistingNotificationsForRoom #2078

Closed mahibi closed 2 years ago

mahibi commented 2 years ago

from gplay console:

java.lang.RuntimeException: 
  at android.app.NotificationManager.getActiveNotifications (NotificationManager.java:2288)
  at com.nextcloud.talk.utils.NotificationUtils.cancelExistingNotificationsForRoom (NotificationUtils.kt:267)
  at com.nextcloud.talk.controllers.ChatController.cancelNotificationsForCurrentConversation (ChatController.kt:1603)
  at com.nextcloud.talk.controllers.ChatController.onAttach (ChatController.kt:1586)
  at com.bluelinelabs.conductor.Controller.attach (Controller.java:974)
  at com.bluelinelabs.conductor.Controller$7.onAttached (Controller.java:1108)
  at com.bluelinelabs.conductor.internal.ViewAttachHandler.reportAttached (ViewAttachHandler.java:87)
  at com.bluelinelabs.conductor.internal.ViewAttachHandler$1.onAttached (ViewAttachHandler.java:47)
  at com.bluelinelabs.conductor.internal.ViewAttachHandler$2.onViewAttachedToWindow (ViewAttachHandler.java:126)
  at android.view.View.dispatchAttachedToWindow (View.java:20749)
  at android.view.ViewGroup.dispatchAttachedToWindow (ViewGroup.java:3573)
  at android.view.ViewGroup.dispatchAttachedToWindow (ViewGroup.java:3573)
  at android.view.ViewGroup.dispatchAttachedToWindow (ViewGroup.java:3573)
  at android.view.ViewGroup.dispatchAttachedToWindow (ViewGroup.java:3573)
  at android.view.ViewGroup.dispatchAttachedToWindow (ViewGroup.java:3573)
  at android.view.ViewGroup.dispatchAttachedToWindow (ViewGroup.java:3573)
  at android.view.ViewGroup.dispatchAttachedToWindow (ViewGroup.java:3573)
  at android.view.ViewGroup.dispatchAttachedToWindow (ViewGroup.java:3573)
  at android.view.ViewGroup.dispatchAttachedToWindow (ViewGroup.java:3573)
  at android.view.ViewGroup.dispatchAttachedToWindow (ViewGroup.java:3573)
  at android.view.ViewGroup.dispatchAttachedToWindow (ViewGroup.java:3573)
  at android.view.ViewRootImpl.performTraversals (ViewRootImpl.java:2607)
  at android.view.ViewRootImpl.doTraversal (ViewRootImpl.java:2135)
  at android.view.ViewRootImpl$TraversalRunnable.run (ViewRootImpl.java:8624)
  at android.view.Choreographer$CallbackRecord.run (Choreographer.java:975)
  at android.view.Choreographer.doCallbacks (Choreographer.java:799)
  at android.view.Choreographer.doFrame (Choreographer.java:734)
  at android.view.Choreographer$FrameDisplayEventReceiver.run (Choreographer.java:960)
  at android.os.Handler.handleCallback (Handler.java:938)
  at android.os.Handler.dispatchMessage (Handler.java:99)
  at android.os.Looper.loop (Looper.java:236)
  at android.app.ActivityThread.main (ActivityThread.java:8057)
  at java.lang.reflect.Method.invoke (Native Method)
  at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:620)
  at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1011)
starypatyk commented 2 years ago

Hi @mahibi!

This is the area where I made changes recently, so I am curious what is happening. :stuck_out_tongue_winking_eye:

Is this a common issue in gplay console? Any more details - e.g. Android version/device? By looking at the line numbers in the stack trace I suspect Android 11. https://android.googlesource.com/platform/frameworks/base/+/refs/heads/android11-release/core/java/android/app/NotificationManager.java#2288

The error looks quite strange. It might even be a bug in Android - quite hard for me to imagine how to cause such error from the application code (except for maybe a race condition).

Maybe we should just catch this exception - see similar (but much older) case in Signal.

mahibi commented 2 years ago

Hi @starypatyk

Total occurrences 192 Impacted users 92

happens on different phones and different android versions:

grafik

i guess just catching is all one can do.

Would you like to do this or should i?

starypatyk commented 2 years ago

Hi @mahibi,

After reading more of the Android source code, I suspect that the error might be related to some kind of general failure in the Android notification manager. Most likely it comes from this method: https://android.googlesource.com/platform/frameworks/base/+/refs/heads/android11-release/core/java/android/os/RemoteException.java#69

I have no idea how the app is going to behave when we catch the error and let it continue.

So a good question is at what level we should add the error handler. I would rather avoid adding it in low-level code like NotificationUtils since this might mask other, genuine errors in our code and make debugging more difficult.

Do you know if all the errors reported in gplay console have the same stack trace? Does is always come from ChatController.onAttach? If this is the case, I would suggest to handle the exception in the onAttach method.

Thoughts?

mahibi commented 2 years ago

it always comes from ChatController.onAttach

either the stack trace is like the one already posted, or it is:

java.lang.RuntimeException: 
  at android.app.NotificationManager.getActiveNotifications (NotificationManager.java:2285)
  at com.nextcloud.talk.utils.NotificationUtils.cancelExistingNotificationsForRoom (NotificationUtils.kt:267)
  at com.nextcloud.talk.controllers.ChatController.cancelNotificationsForCurrentConversation (ChatController.kt:1603)
  at com.nextcloud.talk.controllers.ChatController.onAttach (ChatController.kt:1586)
  at com.bluelinelabs.conductor.Controller.attach (Controller.java:974)
  at com.bluelinelabs.conductor.Controller$7.onAttached (Controller.java:1108)
  at com.bluelinelabs.conductor.internal.ViewAttachHandler.reportAttached (ViewAttachHandler.java:87)
  at com.bluelinelabs.conductor.internal.ViewAttachHandler$1.onAttached (ViewAttachHandler.java:47)
  at com.bluelinelabs.conductor.internal.ViewAttachHandler$2.onViewAttachedToWindow (ViewAttachHandler.java:126)
  at android.view.View.dispatchAttachedToWindow (View.java:20494)
  at android.view.ViewGroup.dispatchAttachedToWindow (ViewGroup.java:3496)
  at android.view.ViewGroup.dispatchAttachedToWindow (ViewGroup.java:3496)
  at android.view.ViewGroup.dispatchAttachedToWindow (ViewGroup.java:3496)
  at android.view.ViewGroup.dispatchAttachedToWindow (ViewGroup.java:3496)
  at android.view.ViewGroup.addViewInner (ViewGroup.java:5278)
  at android.view.ViewGroup.addView (ViewGroup.java:5064)
  at android.view.ViewGroup.addView (ViewGroup.java:5004)
  at android.view.ViewGroup.addView (ViewGroup.java:4976)
  at com.bluelinelabs.conductor.changehandler.AnimatorChangeHandler.performChange (AnimatorChangeHandler.java:126)
  at com.bluelinelabs.conductor.ControllerChangeHandler.executeChange (ControllerChangeHandler.java:209)
  at com.bluelinelabs.conductor.ControllerChangeHandler.executeChange (ControllerChangeHandler.java:159)
  at com.bluelinelabs.conductor.Router.performControllerChange (Router.java:871)
  at com.bluelinelabs.conductor.Router.performControllerChange (Router.java:831)
  at com.bluelinelabs.conductor.Router.performControllerChange (Router.java:809)
  at com.bluelinelabs.conductor.Router.pushController (Router.java:184)
  at com.nextcloud.talk.utils.ConductorRemapping.remapChatController (ConductorRemapping.kt:83)
  at com.nextcloud.talk.utils.ConductorRemapping.remapChatController (ConductorRemapping.kt:40)
  at com.nextcloud.talk.controllers.ConversationsListController.openConversation (ConversationsListController.java:1069)
  at com.nextcloud.talk.controllers.ConversationsListController.openConversation (ConversationsListController.java:1058)
  at com.nextcloud.talk.controllers.ConversationsListController.onItemClick (ConversationsListController.java:882)
  at eu.davidea.viewholders.FlexibleViewHolder.onClick (FlexibleViewHolder.java:122)
  at android.view.View.performClick (View.java:7448)
  at android.view.View.performClickInternal (View.java:7425)
  at android.view.View.access$3600 (View.java:810)
  at android.view.View$PerformClick.run (View.java:28309)
  at android.os.Handler.handleCallback (Handler.java:938)
  at android.os.Handler.dispatchMessage (Handler.java:99)
  at android.os.Looper.loop (Looper.java:223)
  at android.app.ActivityThread.main (ActivityThread.java:7715)
  at java.lang.reflect.Method.invoke (Native Method)
  at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:592)
  at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:952)

i will have a closer look in the afternoon.