Analyzing the Cold Startup Process of Alipay on Android: From Input Event to First Frame
This article dissects the Android cold‑start sequence of the Alipay app, detailing each stage from the initial input event through process forking, activity initialization, splash screen rendering, and final frame display, while providing timing data and optimization insights.
Last week the author observed that Alipay's launch speed lagged behind a comparison device and spent time documenting the entire process. The article assumes familiarity with input event handling, process forking, UI layout and rendering, and the interaction between the rendering thread, SurfaceFlinger, and HWC.
Test steps : Use the user build, connect to a strong Wi‑Fi network, clear background apps, launch Alipay several times, then force‑stop. After a five‑minute cool‑down, record a Systrace while cold‑starting the app with a high‑speed camera, repeating five cycles.
The longest recorded launch took 925 ms, measured from the moment the finger contacts the icon (input event) to the complete loading of the Alipay home page.
Input event flow : The inputReader fetches the event from EventHub, passes it to inputDispatcher, which queues it in “iq”. The dispatcher then routes the event to the Launcher via the “oq” queue, and after consumption moves it to the “wq” queue. If the app does not acknowledge the event within the ANR timeout (5 s default, 8 s in the author's project), an ANR is triggered.
Process creation : Fork starts at 5.652 s (6 ms duration). Android R introduces a USAP mechanism that pre‑forks empty processes to reduce this latency, though it may not benefit low‑memory devices.
Launcher pause : At 5.665 s the Launcher receives a pause signal, starts its launch animation, and begins the hand‑off to the Alipay process.
Application initialization (from ZygoteInit → ActivityThreadMain → BindApplication → StartActivity → onResume → doFrame → display ): The earliest controllable point for developers is BindApplication (5.676 ms, 112 ms duration). Detailed CPU usage and timing breakdowns are provided via screenshots.
activityStart : Creates the Activity context, reflects the Activity class, attaches a PhoneWindow, and runs onCreate where the DecorView is built.
activityResume : Executes onResume, adds the view to WindowManager, creates ViewRootImpl, and calls setView to start UI rendering.
SplashActivity first frame : The splash screen appears at 5.893 s (37 ms duration) and finishes drawing at 5.931 s. The finish‑draw log appears only when mDrawsNeededToReport reaches zero.
Home frame : The first home frame completes at 6.554 s, with detailed CPU and buffer‑queue timing shown. The buffer queue consumption in SurfaceFlinger marks the final cold‑start point.
Overall, the cold‑start process from the initial up event (5.617 s) to the home frame completion (6.554 s) took 937 ms, closely matching the high‑speed camera measurement of 925 ms.
In conclusion, the author emphasizes that a deep, hands‑on analysis is required to truly understand Android app startup, and promises future articles comparing Alipay with competitor devices.
Coolpad Technology Team
Committed to advancing technology and supporting innovators. The Coolpad Technology Team regularly shares forward‑looking insights, product updates, and tech news. Tech experts are welcome to join; everyone is invited to follow us.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.