Grab Cuts ANRs by 32% with R8 and Profiles
Grab successfully tackled performance hurdles in its decade-old superapp codebase by implementing advanced R8 optimization strategies, Baseline Profiles, and Startup Profiles.

Tackling Legacy Codebase Challenges at Scale
As Southeast Asia's leading superapp, Grab delivers mobility, financial services, and deliveries to millions of users across eight countries through a single unified platform. Maintaining this expansive ecosystem involves managing a 10-year-old codebase containing over 10 million lines of code built on a hybrid Bazel and Gradle setup. Over time, the engineering team faced mounting performance challenges, including high Application Not Responding (ANR) rates, an expanding app download size, and a startup time that steadily increased year over year.
Prior to upgrading its optimization pipeline, Grab experienced frequent cold start delays and post-release ANR spikes immediately following weekly app updates. These issues were largely driven by the high overhead of reading numerous DEX files during initial app launch. While standard deployment processes relied on Google Play's Cloud Profiles, those configurations did not fully cover complex initialization pathways like Dagger dependency graphs required during critical user journeys.

Implementing Baseline and Startup Profiles
To address initialization bottlenecks, Grab integrated custom Baseline Profiles to ensure essential user paths were compiled directly into machine code at installation. This approach expanded optimization coverage beyond default distributions. For further insights into how these performance mechanisms operate, developers can reference official documentation on JIT compilation.
The combination of profile guided optimization and runtime compilation tools proved transformative. Nguyen Van Minh, Lead Software Engineer on Grab's Passenger App Core team, noted that the application consistently experienced ANR spikes with every weekly release before these changes were deployed. Implementing the custom configurations successfully eliminated post-release spikes and accelerated overall app startup times.

Phase 1: Transitioning to R8 Compat Mode
Grab executed its overarching performance overhaul across multiple strategic phases. In the first phase shipped in 2025, the team moved away from the legacy default Proguard file and adopted proguard-android-optimize.txt to enable the R8 optimizer. Because the application relied on extensive reflection across its massive codebase, preparing the environment required addressing various legacy configurations.
By pairing this initial optimization push with tailored Baseline Profiles and Startup Profiles, Grab achieved an immediate 25% reduction in user-perceived ANR rates, a 16% drop in app download size, and a 27% improvement in cold start performance.

Phase 2: Unlocking R8 Full Mode
Nine months after the initial rollout, Grab advanced to R8 Full Mode to extract deeper optimizations from the compiler. While libraries like Retrofit, Firebase, and Jetpack Compose integrated smoothly, migrating the wider codebase required careful management of reflection-heavy paths, such as Java dynamic proxies which dynamically generate interface implementations at runtime.
To prevent compilation crashes caused by stripped or renamed classes during aggressive code shrinking, the engineering team avoided broad exemptions that would inflate app size. Instead, they adopted consumer keep rules from the latest Gson release and implemented highly targeted keep rules for specific reflection-reliant classes. For further details on refining rules and library configurations, developers can consult guidelines on consumer keep rules from the latest Gson.

Long-Term Codebase Health and Governance
In the final stage of its optimization lifecycle, Grab focused on establishing long-term codebase health, continuous performance monitoring, and strict compilation governance. To systematically measure rule hygiene and prevent configuration regressions, the engineering group integrated the R8 Configuration Analyzer into their evaluation workflow. This tool provided deep visibility into optimization performance, tracking key metrics such as shrinking, obfuscation, and R8 Optimization scores.
Through ongoing refinement of keep rules, Grab boosted its optimization score from 72% to 78.2%, raised its shrinking score from 73% to 79.1%, and improved its obfuscation score from 79.6% to 81.7%. These diagnostic improvements delivered an additional ~3.6% reduction in app download size while providing objective data to enforce automated pre-merge CI guardrails protecting future releases.
Sources
- Android DevelopersGrab Reduces ANRs by 32% and improves startup time by 35% with R8 and Profile guided optimization
Continue chronologically





