maplibre / maplibre-navigation-android

Maplibre Navigation SDK for Android
MIT License
86 stars 44 forks source link

Crash while updating the Notification Views #94

Open iboalali opened 10 months ago

iboalali commented 10 months ago

Android: 7 - 13 Android API: 24 - 33 Maplibre Navigation SDK version: 2.0.0

Stacktrace

java.lang.RuntimeException: android.os.TransactionTooLargeException: data parcel size 671536 bytes
  at android.app.NotificationManager.notifyAsUser(NotificationManager.java:700)
  at android.app.NotificationManager.notify(NotificationManager.java:632)
  at android.app.NotificationManager.notify(NotificationManager.java:608)
  at com.mapbox.services.android.navigation.v5.navigation.MapboxNavigationNotification.updateNotificationViews(MapboxNavigationNotification.java:173)
  at com.mapbox.services.android.navigation.v5.navigation.MapboxNavigationNotification.updateNotification(MapboxNavigationNotification.java:79)
  at com.mapbox.services.android.navigation.v5.navigation.NavigationNotificationProvider.updateNavigationNotification(NavigationNotificationProvider.java:23)
  at com.mapbox.services.android.navigation.v5.navigation.RouteProcessorThreadListener.onNewRouteProgress(RouteProcessorThreadListener.java:33)
  at com.mapbox.services.android.navigation.v5.navigation.RouteProcessorHandlerCallback$1.run(RouteProcessorHandlerCallback.java:97)
  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:8741)
  at java.lang.reflect.Method.invoke(Method.java:-2)
  at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:571)
  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1067)
  Caused by: android.os.TransactionTooLargeException: data parcel size 671536 bytes
    at android.os.BinderProxy.transactNative(BinderProxy.java:-2)
    at android.os.BinderProxy.transact(BinderProxy.java:653)
    at android.app.INotificationManager$Stub$Proxy.enqueueNotificationWithTag(INotificationManager.java:4011)
    at android.app.NotificationManager.notifyAsUser(NotificationManager.java:697)
    at android.app.NotificationManager.notify(NotificationManager.java:632)
    at android.app.NotificationManager.notify(NotificationManager.java:608)
    at com.mapbox.services.android.navigation.v5.navigation.MapboxNavigationNotification.updateNotificationViews(MapboxNavigationNotification.java:173)
    at com.mapbox.services.android.navigation.v5.navigation.MapboxNavigationNotification.updateNotification(MapboxNavigationNotification.java:79)
    at com.mapbox.services.android.navigation.v5.navigation.NavigationNotificationProvider.updateNavigationNotification(NavigationNotificationProvider.java:23)
    at com.mapbox.services.android.navigation.v5.navigation.RouteProcessorThreadListener.onNewRouteProgress(RouteProcessorThreadListener.java:33)
    at com.mapbox.services.android.navigation.v5.navigation.RouteProcessorHandlerCallback$1.run(RouteProcessorHandlerCallback.java:97)
    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:8741)
    at java.lang.reflect.Method.invoke(Method.java:-2)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:571)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1067)

Steps to trigger behavior

  1. Start Navigation
  2. Navigate through the route
  3. Crash

Expected behavior

Updating notification without crash

Actual behavior

Crashing while updating notification

Fabi755 commented 10 months ago

Thank's for your report!

Does this happen every time or only sometimes?

We will have a look at in the near future.

iboalali commented 10 months ago

Only sometimes for now (a few dozens). Because we just release the new version widely this number will increase.

It did not occur while testing internally, only now with our customers

Fabi755 commented 6 months ago

I see this same error on our app too. There exists a lot of Mapbox issues about this topic. The most mentioned cause is that the navigation view is growing with every update. So long time navigations are crashing with this error, while the notification is too big after (for example) 100 updates.

But I'm still working on a solution on this. But it's very hard to test and reproduce. Feel free to provide a solution to everyone.

iboalali commented 6 months ago

I just reduced the complexity of the notification with a custom implementation. It helped a lot, but didn't prevent the crashes. My latest attempt is to wrap it with a try-catch for now, until we find a solution.

try {
    notificationManager.notify(NavigationConstants.NAVIGATION_NOTIFICATION_ID, notificationBuilder!!.build())
} catch (e: RuntimeException) {
    // to catch two different exceptions, TransactionTooLargeException and
    // DeadSystemException (API 24+) re-thrown as Runtime exception
    Timber.e(e)
}