1

I have an application that is using IPC.

My main application is receiving one-way callbacks from a remote service. Upon receiving those callbacks I'm doing some timely work (1-20s). If I understand correctly - this work is done on a binder Thread on which the onTransact() method was called.

received on: Thread[Binder:12019_2,5,main]

Sometimes the callbacks are sent by the service faster then the work from the previous callback is done. (The remote service is also controlled by me so I know the exact timing).

The problem is I don't receive the callback in my main application immediately on a different binder Thread - the callback is waiting for the previous onTransact() to return and only then the main application receives the callback on the same Thread as the previous one.

so again:

received on: Thread[Binder:12019_2,5,main]

I think that my understanding of Binder stuff is insufficient.

From documentation:

The system maintains a pool of transaction threads in each process that it runs in. These threads are used to dispatch all IPCs coming in from other processes. For example, when an IPC is made from process A to process B, the calling thread in A blocks in transact() as it sends the transaction to process B. The next available pool thread in B receives the incoming transaction, calls Binder.onTransact() on the target object, and replies with the result Parcel.

In my case process A (remote service) is calling transact() with FLAG_ONEWAY and process B (my app) should receive the incoming transaction on the 'next available pool thread'.

So why is it receiving it on the same as the one that is currently running?

Can I make the onTransact() non-blocking?

Jason Aller
  • 3,541
  • 28
  • 38
  • 38

0 Answers0