How Grammarly Built a Native Keyboard for Android
Article Summary
Tushar Janefalkar reveals how Grammarly's Android keyboard processes every keypress through multiple AI pipelines in just 20 milliseconds. The average user taps it 70+ times daily, making performance optimization absolutely critical.
Building a keyboard app isn't like building a normal Android app. Grammarly's team had to architect a system that runs on-device ML models, communicates with backend services, manages complex UI state transitions, and handles gesture recognition—all while maintaining sub-20ms response times. This deep dive explores the unique technical challenges of building an InputMethodService that serves as both a smart writing assistant and a lightning-fast IME.
Key Takeaways
- Multiple concurrent threads handle autocorrect, predictions, synonyms, and backend analysis per keypress
- State-driven architecture manages constantly switching views within severely constrained screen space
- Cache coherence challenges arise when backend suggestions conflict with real-time text modifications
- Standard UI testing frameworks don't work for IMEs, requiring custom UI Automator solutions
- Cold starts require careful optimization as OS controls when keyboard process restarts
Grammarly's keyboard orchestrates on-device ML models and backend services across multiple threads to deliver writing suggestions in under 20 milliseconds per keypress.
Continue reading
This page summarizes “How Grammarly Built a Native Keyboard for Android” by Grammarly, published Nov 29, 2020. All credit for the original work goes to the authors.