Search code examples
androidperformancecold-startperfetto

Too many Binder Transaction operation during app cold startup


I am currently working on improving the performance of our app's cold startup. I am using Android Studio Profiler and the MacroBenchmark library to capture system traces, and then analyzing them using Perfetto. The system traces indicate that a significant amount of time is being spent in bindApplication for binder transactions. I have tried Call Stack Sampling and also ran a system trace in Debug mode, but the "jump to code source" feature in Android Studio's Profiler doesn't work and Call Stack Java/Kotlin doesn't provide any information regarding those binderTransaction. A screenshot from Perfetto for your reference.enter image description here


Solution

  • Binder Transactions: it represents calls between the client and server, in this case, the app (client) calls the Android system (server) with a binder transaction, and the server responds with a binder reply. Make sure that the app doesn't make unnecessary binder transactions during startup, since they increase the risk of CPU contention. If you can, defer work that involves binder calls to after the app startup period. If you have to make binder transactions, ensure they don't take longer than your device's Vsync refresh rate.

    For more details please refer to this document written by Google Android Developers.