简体   繁体   中英

Android IPC maximum transaction size?

I'm making small Android applications which communicate with each other using Binder.

As I know, Android Binder has a maximum transaction size (1MB). For example, TransactionTooLargeException is thrown when applications try to send bigger than 1MB messages using Binder transaction.

I cannot understand why this is limited. Is there any reason to limit the maximum transaction size? Linux SOCK_STREAM is also IPC, but it does not have a limit.

Is there any reasonable reason for that limit? It seems Android documents do not explain why they limit transaction size to 1MB.('The Binder transaction buffer has a limited fixed size' then why do they limit buffer?).

And are there any critical case if framework did not limit IPC size? As I know Linux works well even without a limit on maximum IPC size.

The limit is there to discourage the use of Binder for transferring large amounts of data. Especially on older devices, doing so could affect other apps and, more importantly, the proper functioning of the system itself. Many system components, such as the user interface, Services, etc., depend quite heavily on Binder.

Although other forms of IPC may be designed for transferring large amounts of data, this is not true of Binder. Instead, Android offers other ways of accomplishing this, such as sending a capability to the data through Binder (eg, file descriptor, URI).

The official docs say 1MB. For large data prefer using as Paul suggested: Binder with file descriptors, shared memory, or a different IPC (eg sockets).

https://developer.android.com/reference/android/os/TransactionTooLargeException

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM