Millions of users rely on Flipkart’s mobile app to make purchases. Especially in the crowded e-commerce sector, fast app startup time is essential to business success. Slow mobile apps hurt revenue, receive poor rankings in application stores and are frequently abandoned by users
NimbleDroid, a HeadSpin company, helped Flipkart detect and fix performance bottlenecks in their code base and prevented two serious performance regressions from going live to millions of users. Using NimbleDroid, Flipkart’s app startup time was reduced by 45%. These insights have positioned Flipkart for continued leadership in the e-commerce sector.
Flipkart used GSON extensively to parse JSON responses into model objects — which was done using reflection to determine the type of variable or field at runtime.
Reflection is relatively slow on Android devices and Flipkart’s JSON response is nested and complex — so NimbleDroid was able to show developers that their app was taking more time than expected to parse JSON network responses.
~4.0s Cold Startup
~1.3s of this time taken up by GSON
To reduce cold startup time, Flipkart developers needed to find a a way to mitigate reflection.
GSON uses a concept called Type Adapters, which manually map JSON fields to the model object. Using Type Adapters improves performance — as it does not use reflection. But writing Type Adapters for each of the ~350 model classes would have been labor intensive and prone to bugs.
NimbleDroid recommended that Flipkart developers leverage Vimeo’s Stag Library, which uses annotation processing to automatically generate Ureflection-less Type Adapters for model objects. NimbleDroid also helped developers avoid reflection in non-GSON code
When Flipkart developers moved from Volley to Retrofit (done on initialization on the UI thread), app startup time increased — from 2.8 to 3.0 seconds. During code review, developers could not determine what was causing this slowdown. Using NimbleDroid, they were able to identify the issue and resolve it before the change went live. NimbleDroid also identified lazy initialization of data that was not needed for app startup, helping save additional time.
Nimble Droid also benchmarked Flipkart's app performance against leading competitors.