KieronQuinn / AmbientMusicMod

Port of Now Playing from Pixels to other Android devices
GNU General Public License v3.0
1.91k stars 41 forks source link

Error "android.os.TransactionToo LargeException" #169

Closed mjain234 closed 1 year ago

mjain234 commented 1 year ago

Suddenly Ambient Music mod get crash.

Here is the full log:

[Stack Trace]: java.lang.RuntimeException: android.os.TransactionTooLargeException: data parcel size 490044 bytes at android.appwidget.AppWidgetManager.updateAppWidget(AppWidgetManager.java:542) at android.appwidget.AppWidgetManager.updateAppWidget(AppWidgetManager.java:613) at com.kieronquinn.app.ambientmusicmod.repositories.WidgetRepositoryImpl.sendLayouts(WidgetRepository.kt:202) at com.kieronquinn.app.ambientmusicmod.repositories.WidgetRepositoryImpl.access$sendLayouts(WidgetRepository.kt:42) at com.kieronquinn.app.ambientmusicmod.repositories.WidgetRepositoryImpl$setupWidgets$1$3.emit(WidgetRepository.kt:183) at com.kieronquinn.app.ambientmusicmod.repositories.WidgetRepositoryImpl$setupWidgets$1$3.emit(WidgetRepository.kt:182) at kotlinx.coroutines.flow.FlowKtZipKt$combine$$inlined$combineUnsafe$FlowKtZipKt$1$2.invokeSuspend(Zip.kt:333) at kotlinx.coroutines.flow.FlowKtZipKt$combine$$inlined$combineUnsafe$FlowKtZipKt$1$2.invoke(Unknown Source:13) at kotlinx.coroutines.flow.FlowKtZipKt$combine$$inlined$combineUnsafe$FlowKtZipKt$1$2.invoke(Unknown Source:6) at kotlinx.coroutines.flow.internal.CombineKt$combineInternal$2.invokeSuspend(Combine.kt:79) at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33) at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106) at android.os.Handler.handleCallback(Handler.java:942) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loopOnce(Looper.java:227) at android.os.Looper.loop(Looper.java:327) at android.app.ActivityThread.main(ActivityThread.java:7951) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:942) Suppressed: kotlinx.coroutines.DiagnosticCoroutineContextException: [StandaloneCoroutine{Cancelling}@7a4d0c5, Dispatchers.Main] Caused by: android.os.TransactionTooLargeException: data parcel size 490044 bytes at android.os.BinderProxy.transactNative(Native Method) at android.os.BinderProxy.transact(BinderProxy.java:584) at com.android.internal.appwidget.IAppWidgetService$Stub$Proxy.updateAppWidgetIds(IAppWidgetService.java:819) at android.appwidget.AppWidgetManager.updateAppWidget(AppWidgetManager.java:540) ... 19 more

Screenshot_20230419-042207.png

KieronQuinn commented 1 year ago

Does this always happen or was it just once? There's nothing in the widget that would cause this, I suspect it might have been the system lagging behind on widget updates and causing it to reach the limit.

If it's happening often, I could probably add a catch to prevent the crash but then the widget would still not update. Crashing or killing the app is actually the only way to clear out binder transactions, so this would just break the widget entirely if it's always happening for you.

KieronQuinn commented 1 year ago

I ended up just suppressing it. If the system misbehaves, it's not really my problem.

mjain234 commented 1 year ago

Btw the app is still crashing whenever unlocking my phone. This is happening due to the widget I added on my homescreen?

KieronQuinn commented 1 year ago

Looks like the suppressing needs an even more vague catchall. Yes, it's due to the widget. It makes zero sense, I have no idea what is going on with your device - you might as well remove the widget because it won't update when 'fixed' anyway.

Terrance commented 6 months ago

Not sure if anything has changed here, but I've now started seeing a few of these logged over the last month or so:

FATAL EXCEPTION: main
Process: com.kieronquinn.app.ambientmusicmod, PID: 28752
java.lang.RuntimeException: android.os.TransactionTooLargeException: data parcel size 1461376 bytes
    at android.appwidget.AppWidgetManager.updateAppWidget(AppWidgetManager.java:542)
    at android.appwidget.AppWidgetManager.updateAppWidget(AppWidgetManager.java:613)
    at com.kieronquinn.app.ambientmusicmod.repositories.WidgetRepositoryImpl.sendLayouts(WidgetRepository.kt:204)
    at com.kieronquinn.app.ambientmusicmod.repositories.WidgetRepositoryImpl.access$sendLayouts(WidgetRepository.kt:43)
    at com.kieronquinn.app.ambientmusicmod.repositories.WidgetRepositoryImpl$setupWidgets$1$3.emit(WidgetRepository.kt:184)
    at com.kieronquinn.app.ambientmusicmod.repositories.WidgetRepositoryImpl$setupWidgets$1$3.emit(WidgetRepository.kt:183)
    at kotlinx.coroutines.flow.FlowKt__ZipKt$combine$$inlined$combineUnsafe$FlowKt__ZipKt$1$2.invokeSuspend(Zip.kt:262)
    at kotlinx.coroutines.flow.FlowKt__ZipKt$combine$$inlined$combineUnsafe$FlowKt__ZipKt$1$2.invoke(Unknown Source:13)
    at kotlinx.coroutines.flow.FlowKt__ZipKt$combine$$inlined$combineUnsafe$FlowKt__ZipKt$1$2.invoke(Unknown Source:6)
    at kotlinx.coroutines.flow.internal.CombineKt$combineInternal$2.invokeSuspend(Combine.kt:76)
    at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
    at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
    at android.os.Handler.handleCallback(Handler.java:942)
    at android.os.Handler.dispatchMessage(Handler.java:99)
    at android.os.Looper.loopOnce(Looper.java:240)
    at android.os.Looper.loop(Looper.java:351)
    at android.app.ActivityThread.main(ActivityThread.java:8377)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:584)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1013)
    Suppressed: kotlinx.coroutines.internal.DiagnosticCoroutineContextException: [StandaloneCoroutine{Cancelling}@3765499, Dispatchers.Main]
Caused by: android.os.TransactionTooLargeException: data parcel size 1461376 bytes
    at android.os.BinderProxy.transactNative(Native Method)
    at android.os.BinderProxy.transact(BinderProxy.java:672)
    at com.android.internal.appwidget.IAppWidgetService$Stub$Proxy.updateAppWidgetIds(IAppWidgetService.java:819)
    at android.appwidget.AppWidgetManager.updateAppWidget(AppWidgetManager.java:540)
    ... 19 more

I haven't noticed the widget misbehaving / unresponsive, but admittedly I don't use it that often, and I also haven't managed to investigate the crashes when they happened.

I assume the "vague catchall" is down to the exception being wrapped in a RuntimeException which isn't currently caught -- I don't know the specifics of Android process management, so is there any value in catching it here to prevent the process being terminated, even if the widget is then broken? Does control of the listener service etc. happen in the same process, and is also being shut down here?