adolfintel / OpenPods

The Free and Open Source app for monitoring your AirPods on Android
https://fdossena.com/?p=openPods/index.frag
GNU General Public License v3.0
938 stars 161 forks source link

android.os.TransactionTooLargeException: data parcel size 1040360 bytes #64

Closed nickrbogdanov closed 4 years ago

nickrbogdanov commented 4 years ago

I see these pretty regularly on AOSP QQ2A.200405.005 on a Google Pixel 3:

04-26 17:28:50.883 32372 32393 E AndroidRuntime: FATAL EXCEPTION: Thread-2
04-26 17:28:50.883 32372 32393 E AndroidRuntime: Process: com.dosse.airpods, PID: 32372
04-26 17:28:50.883 32372 32393 E AndroidRuntime: java.lang.RuntimeException: android.os.TransactionTooLargeException: data parcel size 1040360 bytes
04-26 17:28:50.883 32372 32393 E AndroidRuntime:        at android.app.NotificationManager.notifyAsUser(NotificationManager.java:497)
04-26 17:28:50.883 32372 32393 E AndroidRuntime:        at android.app.NotificationManager.notify(NotificationManager.java:444)
04-26 17:28:50.883 32372 32393 E AndroidRuntime:        at android.app.NotificationManager.notify(NotificationManager.java:420)
04-26 17:28:50.883 32372 32393 E AndroidRuntime:        at com.dosse.airpods.PodsService$NotificationThread.run(PodsService.java:332)
04-26 17:28:50.883 32372 32393 E AndroidRuntime: Caused by: android.os.TransactionTooLargeException: data parcel size 1040360 bytes
04-26 17:28:50.883 32372 32393 E AndroidRuntime:        at android.os.BinderProxy.transactNative(Native Method)
04-26 17:28:50.883 32372 32393 E AndroidRuntime:        at android.os.BinderProxy.transact(BinderProxy.java:511)
04-26 17:28:50.883 32372 32393 E AndroidRuntime:        at android.app.INotificationManager$Stub$Proxy.enqueueNotificationWithTag(INotificationManager.jav
a:2791)
04-26 17:28:50.883 32372 32393 E AndroidRuntime:        at android.app.NotificationManager.notifyAsUser(NotificationManager.java:494)
04-26 17:28:50.883 32372 32393 E AndroidRuntime:        ... 3 more

Leaving the phone running idle for a few hours with logcat streaming to disk, I see:

04-25 21:00:47.305  3715  3749 E AndroidRuntime: Process: com.dosse.airpods, PID: 3715
04-26 15:40:43.276 18743 18764 E AndroidRuntime: Process: com.dosse.airpods, PID: 18743
04-26 16:01:16.537 29185 29206 E AndroidRuntime: Process: com.dosse.airpods, PID: 29185
04-26 16:19:36.458 30000 30021 E AndroidRuntime: Process: com.dosse.airpods, PID: 30000
04-26 16:40:07.503 30816 30837 E AndroidRuntime: Process: com.dosse.airpods, PID: 30816
04-26 16:56:25.907 31963 31984 E AndroidRuntime: Process: com.dosse.airpods, PID: 31963
04-26 17:12:45.710 32039 32060 E AndroidRuntime: Process: com.dosse.airpods, PID: 32039
04-26 17:28:50.883 32372 32393 E AndroidRuntime: Process: com.dosse.airpods, PID: 32372
04-26 17:44:49.790 32683 32704 E AndroidRuntime: Process: com.dosse.airpods, PID: 32683
04-26 18:00:50.762  1036  1071 E AndroidRuntime: Process: com.dosse.airpods, PID: 1036
04-26 18:16:45.472  1172  1212 E AndroidRuntime: Process: com.dosse.airpods, PID: 1172
04-26 18:34:13.700  1662  1701 E AndroidRuntime: Process: com.dosse.airpods, PID: 1662
04-26 18:55:49.690  2021  2063 E AndroidRuntime: Process: com.dosse.airpods, PID: 2021
04-26 20:14:16.450  2516  2541 E AndroidRuntime: Process: com.dosse.airpods, PID: 2516
04-26 20:56:19.701  4138  4159 E AndroidRuntime: Process: com.dosse.airpods, PID: 4138

I don't think my AirPods were even removed from the case when these errors occurred.

I believe I was running OpenPods 1.3 (13) from F-Droid. Not positive because I uninstalled it.

The crash signature looks similar to #47 but in my case, the parcel size is on the order of 1MB instead of 3MB.

adolfintel commented 4 years ago

I don't know what to tell you, I was never able to replicate the issue, I don't know what's causing it on your device. It's clear that the app crashed and was restarted a few times while it was running in background. The exception points to line 332 of PodsService.java, which runs when the notification becomes visible. There is no reason for it to fail as far as I know, and I'm certainly not passing 1MB of data to it. Ideas?

Domi04151309 commented 4 years ago

It seems that it has something to do with the notification view. Somehow a lot of data stacks up which causes the TransactionTooLargeException.

Domi04151309 commented 4 years ago

A solution I've found is to use try catch and rebuild the notification when the notify function fails as discussed at mapbox/mapbox-navigation-android#1691

adolfintel commented 4 years ago

I guess it's worth a try. I'll implement this "fix" later today and send you a test APK

adolfintel commented 4 years ago

@Domi04151309 @nickrbogdanov Please test this APK and let me know if the problem still occurs: app-debug.zip

adolfintel commented 4 years ago

Closing as fixed by #65

Domi04151309 commented 4 years ago

This does still happen with the newest version

adolfintel commented 4 years ago

@Electric1447 ideas?

Electric1447 commented 4 years ago

I have no idea

Electric1447 commented 4 years ago

@adolfintel according to https://stackoverflow.com/questions/11451393/what-to-do-on-transactiontoolargeexception we should split the transmission, however I don't know if it is possible

Electric1447 commented 4 years ago

And it could be a possible memory leak with the notification thread, I know people who have encountered problems like that before.

adolfintel commented 4 years ago

We could destroy the current notification and recreate one with a new ID when the exception is thrown

Electric1447 commented 4 years ago

We could destroy the current notification and recreate one with a new ID when the exception is thrown

It is possible however further testing by @Domi04151309 would be required because I cannot recreate this issue

adolfintel commented 4 years ago

Me neither, I wonder what kind of crazy bug in the notification code causes it

Electric1447 commented 4 years ago

@Domi04151309 which device and os are you running?

Edit: from #47 I see you have a Oneplus 6T running Android 10 which makes this really confusing as I am also using a OnePlus 6T with Android 10.

Electric1447 commented 4 years ago

@Domi04151309 which device and os are you running?

Edit: from #47 I see you have a Oneplus 6T running Android 10 which makes this really confusing as I am also using a OnePlus 6T with Android 10.

Google is really high rn

SebiderSushi commented 4 years ago

To maybe add one data point here: On my Redmi 4X i only experienced these crashes while running an Oreo ROM, namely LineageOS 15.1 or various builds (official and unofficial) of ResurrectionRemix 6.*.*

As opposed to this, i never experienced the crash while running ResurrectionRemix 7.0.2 (Pie).