Mobile Development 10 min read

Optimizing Xianyu Android App Cold Start: Cutting Launch Time by Half

By establishing measurable standards, profiling the launch flow, and applying task‑governance techniques—delaying, shrinking and splitting blocking tasks—plus home‑page shortcuts like ad pre‑fetch, background view creation and SharedPreferences caching, Xianyu’s Android cold‑start on low‑end phones dropped from about ten seconds to under five, with the first screen in ~1.3 seconds and full launch in 4.5 seconds.

Xianyu Technology
Xianyu Technology
Xianyu Technology
Optimizing Xianyu Android App Cold Start: Cutting Launch Time by Half

With the continuous addition of new features to the Xianyu app, its cold‑start time on Android devices has become increasingly slow, harming user experience. Internal tests have reduced the cold‑start duration on low‑end phones from about 10 seconds to under 5 seconds.

The improvement follows three steps: 建立标准, 分析现状, and 抓大放小.

Establishing Standards – A measurable standard was built using a video‑key‑frame method that records the interval from tapping the app icon to the first screen rendering, aligning with user perception.

Current Situation – Log‑based profiling showed that the common and interactive phases dominate the pre‑render stage, while network requests and view layout dominate after the home page appears.

Based on this analysis, the focus shifted to “startup task governance” and “home‑page rendering acceleration”.

Startup Task Optimization – Since 2016 Xianyu uses a DAG‑based launcher that runs tasks concurrently on multiple cores. Among 77 startup tasks, 61 are blocking ( 阻塞型任务), causing the total launch time to exceed 8 seconds on the target low‑end device (y67).

Three fast‑track optimizations were applied:

Delay execution of non‑essential tasks.

Reduce the execution time of remaining tasks.

Split large tasks into smaller, parallelizable units.

Task splitting relies on dependency analysis: tasks without downstream dependencies can be delayed safely.

Non‑Blocking Task Timing – Non‑blocking tasks were triggered after the home page’s first queueIdle callback. An additional 6‑second delayed runnable acts as a backup to ensure the callback fires even under heavy message‑queue load.

When a user accesses a heavy SDK (weex, web, mini‑program) before the non‑blocking phase, the system checks whether the required modules are initialized; if not, it either waits for the non‑blocking tasks or forces immediate initialization.

Task Cost Governance – Fine‑grained method trace profiling identified hot spots. General improvements include caching IO results, using apply instead of commit for SharedPreferences, and ensuring callbacks on the main thread finish quickly.

Home‑Page Startup Optimization – Three areas were tackled:

Ad page: pre‑fetch resources and replace the launching Activity with a full‑screen Dialog to avoid unnecessary IPC.

Data pre‑loading: fetch cold‑start and hot‑start API data during app initialization, saving roughly 1 second.

View pre‑creation: create and layout views on a background thread, reducing view on‑screen time from ~1400 ms to ~600 ms.

Overall, the cold‑start time dropped from 2.5 seconds to 1.3 seconds, total task time fell from 8 seconds to 3 seconds, and the full launch cycle is now around 4.5 seconds.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

Mobile DevelopmentPerformance OptimizationAndroidtask schedulingcold start
Xianyu Technology
Written by

Xianyu Technology

Official account of the Xianyu technology team

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.