【问题标题】:Android Widgets allowed to exceed Binder transaction limit somehow?Android Widgets 允许以某种方式超过 Binder 事务限制?
【发布时间】:2014-07-09 07:23:58
【问题描述】:

AppWidgetManager 的 Android 文档中说

The total Bitmap memory used by the RemoteViews object cannot exceed that required 
to fill the screen 1.5 times, ie. (screen width x screen height x 4 x 1.5) bytes.

但是TransactionTooLargeException 的文档说:

The Binder transaction buffer has a limited fixed size, currently 1Mb, which is 
shared by all transactions in progress for the process.

市场上几乎所有 Android 设备的屏幕尺寸都足够大,以至于填充它的位图会超过 1Mb(例如 800 x 600 x 4 = 1,920,000 字节)。我查看了Android平台源代码,它似乎没有使用带有管道或任何深奥的ashmem,只是一个normal AIDL file,并且在RemoteViews中,位图对象可以正常方式Parcelable(它does drop down to native code,但它似乎写所有位图像素到一个常规 Parcel)。

那么,Android 怎么可能超出 Binder 事务限制呢? oneway 是否允许发送更大的数据?

【问题讨论】:

  • 自从我看到人们使用应用小部件进行活页夹交易失败的 SO 问题,我质疑 AppWidgetManager 文档在这一点上的准确性。
  • 谢谢,文档好像有问题。

标签: android android-binder


【解决方案1】:

Bitmaps 被特别处理。它们位于本机内存中,并且只有引用在包中传递。尝试序列化byte[] 中的位图,我敢打赌它会崩溃。

【讨论】:

    【解决方案2】:

    CommonsWare 在评论中回答了这个问题,答案是否定的,文档有误。

    另外在您的aidl 中使用oneway 可能会使您的代码更有可能命中事务太大,因为RPC 将在通过binder 发送的数据被消耗之前立即返回,从而允许您将更多数据推送到binder并让您接近或超过极限。

    【讨论】:

      猜你喜欢
      • 2018-12-11
      • 1970-01-01
      • 1970-01-01
      • 2017-08-24
      • 2019-02-05
      • 2018-12-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多