What to do on TransactionTooLargeException

前端 未结 30 3391
盖世英雄少女心
盖世英雄少女心 2020-11-22 03:08

I got a TransactionTooLargeException. Not reproducible. In the docs it says

The Binder transaction failed because it was too large.

D

30条回答
  •  后悔当初
    2020-11-22 03:26

    I encountered this issue, and I found that when there huge amount of data getting exchanged between a service and an application,(This involves transferring lots of thumbnails). Actually data size was around 500kb, and the IPC transaction buffer size is set to 1024KB. I am not sure why it exceeded the transaction buffer.

    This also can occur, when you pass lot of data through intent extras

    When you get this exception in your application, please analyze your code.

    1. Are you exchanging lot of data between your services and application?
    2. Using intents to share huge data, (for example, the user selects huge number of files from gallery share press share, the URIs of the selected files will be transferred using intents)
    3. receiving bitmap files from service
    4. waiting for android to respond back with huge data (for example, getInstalledApplications() when the user installed lot of applications)
    5. using applyBatch() with lot of operations pending

    How to handle when you get this exception

    If possible, split the big operation in to small chunks, for example, instead of calling applyBatch() with 1000 operations, call it with 100 each.

    Do not exchange huge data (>1MB) between services and application

    I dont know how to do this, but, Do not query android, which can return huge data :-)

提交回复
热议问题