Skip to content

Conversation

@danesfeder
Copy link
Contributor

Closes #1188

Unfortunately #1441 and #1455 didn't address the TransactionTooLargeException.

If the data is being built-up in the RemoteView, then it may make sense to rebuild the views on each update? I'm concerned about performance here, as this could be costly to do every second. Should we be smarter about it? Maybe only do this after a certain amount of time has passed?

I guess first we should test that it fixes it at all and then worry about performance implications.

cc @akitchen @taraniduncan

Copy link
Contributor

@Guardiola31337 Guardiola31337 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One minor comment.

PendingIntent pendingCloseIntent = createPendingCloseIntent(applicationContext);
expandedNotificationRemoteViews.setOnClickPendingIntent(R.id.endNavigationBtn, pendingCloseIntent);
pendingCloseIntent = createPendingCloseIntent(applicationContext);
buildRemoteViews();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We're building the remote views on every notification update. Should this call be removed from here?

@danesfeder
Copy link
Contributor Author

@Guardiola31337 good catch, this is updated

Copy link
Contributor

@Guardiola31337 Guardiola31337 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's test if this workarounds the TransactionTooLargeException!

Thanks @danesfeder

@danesfeder danesfeder merged commit f793097 into master Oct 30, 2018
@danesfeder danesfeder deleted the dan-remote-view branch October 30, 2018 19:35
@Guardiola31337
Copy link
Contributor

I've tested OP and now I'm seeing

Fatal Exception: java.lang.RuntimeException: android.os.DeadSystemException
       at android.app.servertransaction.PendingTransactionActions$StopInfo.run(PendingTransactionActions.java:160)
       at android.os.Handler.handleCallback(Handler.java:873)
       at android.os.Handler.dispatchMessage(Handler.java:99)
       at android.os.Looper.loop(Looper.java:193)
       at android.app.ActivityThread.main(ActivityThread.java:6669)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)

when running a long session in a Pixel XL - Android 9 and ANRs + E/JavaBinder: !!! FAILED BINDER TRANSACTION !!! (parcel size = 4400756) logs in a Nexus 5 - Android 6.0

After some digging 👀 https://stackoverflow.com/questions/11451393/what-to-do-on-transactiontoolargeexception and https://stackoverflow.com/questions/39098590/android-os-transactiontoolargeexception-on-nougat it seems the problem is not in the notification per se and could be caused somewhere else because of the amount of data that we store in onSaveInstanceState, see TransactionTooLargeException.

I want to note that this exact same behavior was documented in the release notes for Nougat 👀

Many platform APIs have now started checking for large payloads being sent across Binder transactions, and the system now rethrows TransactionTooLargeExceptions as RuntimeExceptions, instead of silently logging or suppressing them. One common example is storing too much data in Activity.onSaveInstanceState(), which causes ActivityThread.StopInfo to throw a RuntimeException when your app targets Android 7.0.

We need to keep 🕵️ so I'm going to reopen #1188 again 😥

cc @danesfeder

@danesfeder
Copy link
Contributor Author

danesfeder commented Oct 31, 2018

From https://developer.android.com/reference/android/os/DeadSystemException.html

The core Android system has died and is going through a runtime restart. All running apps will be promptly killed.

Are we sure that's related to these changes?

After some digging 👀 https://stackoverflow.com/questions/11451393/what-to-do-on-transactiontoolargeexception and https://stackoverflow.com/questions/39098590/android-os-transactiontoolargeexception-on-nougat it seems the problem is not in the notification per se and could be caused somewhere else because of the amount of data that we store in onSaveInstanceState, see TransactionTooLargeException.

@Guardiola31337 for these sessions you're running, are you rotating the screen a lot?

@Guardiola31337
Copy link
Contributor

Are we sure that's related to these changes?

Yeah, could be definitely related, I've seen weird logs including DeadSystemException followed by TransactionTooLargeException before (with previous implementations) 👇

10-26 06:53:18.035   918   918 W Looper  : Slow dispatch took 155ms main h=com.android.server.notification.NotificationManagerService$WorkerHandler c=com.android.server.notification.NotificationManagerService$PostNotificationRunnable@fbe05a6 m=0
10-26 06:53:18.850   918   918 W Looper  : Slow dispatch took 144ms main h=com.android.server.notification.NotificationManagerService$WorkerHandler c=com.android.server.notification.NotificationManagerService$EnqueueNotificationRunnable@cb4d632 m=0
10-26 06:53:19.105   918   918 W Looper  : Slow dispatch took 154ms main h=com.android.server.notification.NotificationManagerService$WorkerHandler c=com.android.server.notification.NotificationManagerService$PostNotificationRunnable@eee9f83 m=0
10-26 06:53:19.988   918   918 W Looper  : Slow dispatch took 170ms main h=com.android.server.notification.NotificationManagerService$WorkerHandler c=com.android.server.notification.NotificationManagerService$EnqueueNotificationRunnable@6965139 m=0
// Hundreds of logs like above
// ...
10-26 06:57:08.008  1495  1495 E AndroidRuntime: FATAL EXCEPTION: main
10-26 06:57:08.008  1495  1495 E AndroidRuntime: Process: com.android.systemui, PID: 1495
10-26 06:57:08.008  1495  1495 E AndroidRuntime: DeadSystemException: The system died; earlier logs will point to the root cause
// More logs
// ...
// and eventually
10-26 06:58:13.392 27563 27563 E AndroidRuntime: java.lang.RuntimeException: android.os.TransactionTooLargeException: data parcel size 1040252 bytes
10-26 06:58:13.392 27563 27563 E AndroidRuntime: 	at android.app.NotificationManager.notifyAsUser(NotificationManager.java:408)
10-26 06:58:13.392 27563 27563 E AndroidRuntime: 	at android.app.NotificationManager.notify(NotificationManager.java:370)
10-26 06:58:13.392 27563 27563 E AndroidRuntime: 	at android.app.NotificationManager.notify(NotificationManager.java:346)
10-26 06:58:13.392 27563 27563 E AndroidRuntime: 	at com.mapbox.services.android.navigation.v5.navigation.MapboxNavigationNotification.updateNotificationViews(MapboxNavigationNotification.java:169)
10-26 06:58:13.392 27563 27563 E AndroidRuntime: 	at com.mapbox.services.android.navigation.v5.navigation.MapboxNavigationNotification.updateNotification(MapboxNavigationNotification.java:77)
10-26 06:58:13.392 27563 27563 E AndroidRuntime: 	at com.mapbox.services.android.navigation.v5.navigation.NavigationNotificationProvider.updateNavigationNotification(NavigationNotificationProvider.java:23)
10-26 06:58:13.392 27563 27563 E AndroidRuntime: 	at com.mapbox.services.android.navigation.v5.navigation.RouteProcessorThreadListener.onNewRouteProgress(RouteProcessorThreadListener.java:33)
10-26 06:58:13.392 27563 27563 E AndroidRuntime: 	at com.mapbox.services.android.navigation.v5.navigation.RouteProcessorRunnable$1.run(RouteProcessorRunnable.java:119)
10-26 06:58:13.392 27563 27563 E AndroidRuntime: 	at android.os.Handler.handleCallback(Handler.java:873)
10-26 06:58:13.392 27563 27563 E AndroidRuntime: 	at android.os.Handler.dispatchMessage(Handler.java:99)
10-26 06:58:13.392 27563 27563 E AndroidRuntime: 	at android.os.Looper.loop(Looper.java:193)
10-26 06:58:13.392 27563 27563 E AndroidRuntime: 	at android.app.ActivityThread.main(ActivityThread.java:6669)
10-26 06:58:13.392 27563 27563 E AndroidRuntime: 	at java.lang.reflect.Method.invoke(Native Method)
10-26 06:58:13.392 27563 27563 E AndroidRuntime: 	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
10-26 06:58:13.392 27563 27563 E AndroidRuntime: 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
10-26 06:58:13.392 27563 27563 E AndroidRuntime: Caused by: android.os.TransactionTooLargeException: data parcel size 1040252 bytes
10-26 06:58:13.392 27563 27563 E AndroidRuntime: 	at android.os.BinderProxy.transactNative(Native Method)
10-26 06:58:13.392 27563 27563 E AndroidRuntime: 	at android.os.BinderProxy.transact(Binder.java:1127)
10-26 06:58:13.392 27563 27563 E AndroidRuntime: 	at android.app.INotificationManager$Stub$Proxy.enqueueNotificationWithTag(INotificationManager.java:1558)
10-26 06:58:13.392 27563 27563 E AndroidRuntime: 	at android.app.NotificationManager.notifyAsUser(NotificationManager.java:405)
10-26 06:58:13.392 27563 27563 E AndroidRuntime: 	... 14 more

for these sessions you're running, are you rotating the screen a lot?

Nah, actually the opposite. I've launched a navigation session and left the device stuck at the dock for hours. No rotations, stuck at the same position / location all the time, no config changes. What are you thinking on?

@Guardiola31337
Copy link
Contributor

Forgot to mentioned that the device is plugged in, the Activity running the navigation session in the foreground and the screen on all the time.

@danesfeder danesfeder mentioned this pull request Nov 7, 2018
12 tasks
@Guardiola31337 Guardiola31337 mentioned this pull request Mar 29, 2020
10 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Defect to be fixed.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

MapboxNavigationNotification#updateNotificationViews TransactionTooLargeException

2 participants