Skeelo Pedro Munhoz Neto Jul 11, 2023

Enhancing User Experience: Reducing ANR Rates with DataStore in Skeelo Android App

Article Summary

Skeelo's Android app was freezing on users. The culprit? SharedPreferences blocking the main thread and triggering ANR errors.

The Skeelo engineering team migrated from SharedPreferences to Jetpack DataStore to eliminate Application Not Responding (ANR) errors. They took a phased approach, prioritizing the most critical functions causing crashes using Firebase Crashlytics and Sentry data.

Key Takeaways

Critical Insight

Migrating from SharedPreferences to DataStore dramatically reduced ANR rates and improved app stability through asynchronous, non-blocking data operations.

The team shares specific lessons learned about planning gradual migrations while maintaining continuous product delivery.

About This Article

Problem

SharedPreferences had concurrency issues that corrupted data when multiple threads accessed it at the same time. This caused extra latency and ANR errors whenever operations took longer than 5 seconds on the main thread.

Solution

Skeelo Engineering switched to Preferences DataStore with Kotlin coroutines and Flow. They migrated the codebase function by function, using Firebase Crashlytics and Sentry crash data to prioritize which parts to update first.

Impact

DataStore's asynchronous approach removed blocking I/O operations from the main thread. ANR rates dropped significantly, and users experienced fewer freezes and crashes. The app became noticeably more stable overall.