gpt4 book ai didi

android - 我如何找出导致 android.os.TransactionTooLargeException 的原因

转载 作者:搜寻专家 更新时间:2023-11-01 08:27:19 26 4
gpt4 key购买 nike

我有一个异常(exception),它在 Android 7 上经常发生,而在低于该版本的版本上很少发生。我不知道如何重现它,我只看过有关 crashlytics 的报告。

我并没有真正在 Activity 之间或服务之间传递数据。我确实在我的一项 Activity 的 onSaveInstanceState 方法上保存了一些 WebView 的状态,但我多年来一直这样做,我不确定为什么它会突然导致问题。

有什么想法吗?

这是异常(exception)情况:

Fatal Exception: java.lang.RuntimeException: android.os.TransactionTooLargeException: data parcel size 1405624 bytes
at android.app.ActivityThread$StopInfo.run(ActivityThread.java:4156)
at android.os.Handler.handleCallback(Handler.java:751)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6682)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1520)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1410)
Caused by android.os.TransactionTooLargeException: data parcel size 1405624 bytes
at android.os.BinderProxy.transactNative(Binder.java)
at android.os.BinderProxy.transact(Binder.java:628)
at android.app.ActivityManagerProxy.activityStopped(ActivityManagerNative.java:4149)
at android.app.ActivityThread$StopInfo.run(ActivityThread.java:4148)
at android.os.Handler.handleCallback(Handler.java:751)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6682)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1520)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1410)

谢谢。

最佳答案

是的!从 Android 7.0 (Nougat) 开始the system will crash if the data in onSaveInstanceState is too large .

你必须想出另一种方法来保存和恢复状态。

http://blog.sqisland.com/2016/09/transactiontoolargeexception-crashes-nougat.html

请注意 Dianne Hackborn 的评论:

Dianne Hackborn September 18, 2016 at 10:52 AM

It is more complicated than a fixed size limit. Each process has a fixed buffer for receiving incoming transactions, whose size is 1MB. So technically you could say the maximum size is 1MB, but that assumes there are no other IPCs happening. In practice, you should never have a size anywhere close to that, or you run the risk of occasionally failing when there are a number of other concurrent IPCs in progress.

For the specific case of saved state, you also want to keep this small because whatever you provide here is data the system needs to hold on to in the system process for as long as the user can ever navigate back to that activity (even if the activity's process is killed).

So I would recommend keeping the saved state well less than 100K, and really less than 50K, and in most cases much less than even that.

关于android - 我如何找出导致 android.os.TransactionTooLargeException 的原因,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43551825/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com