Coupang Ju Cai May 6, 2022

Evolution of Android Message Passing Mechanism

Article Summary

Ju Cai from Coupang reveals how their Android app went from Stone Age message passing to a custom LiveData-based event bus that cut development time in half. The journey through three architectural eras offers a masterclass in scaling mobile architecture.

As Coupang's e-commerce business exploded in the late 2010s, their Android app became a tangled mess of dependencies where simple changes required full regression testing. The engineering team evolved through three distinct phases of message passing architecture, ultimately building ElegantLiveDataBus to decouple modules and enable parallel development at scale.

Key Takeaways

Critical Insight

Coupang's custom LiveData-based message bus reduced cross-activity development time by 50% and codebase size by 60% while solving lifecycle and memory leak issues.

The article includes detailed code showing how they prevented data loss in postValue() and implemented hierarchical event processing across multiple activities.

About This Article

Problem

Coupang's Iron Age ViewEventManager event bus made debugging difficult. Tracking message responders meant manually examining all registered events, which hurt development efficiency.

Solution

ElegantLiveDataBus uses dynamic proxy technology to bind each message to isolated channels through interface definitions. This enables compile-time type checking and removes the ambiguities that come with string-based messages.

Impact

The implementation cut cross-activity interaction development time in half and reduced the codebase by 60%. It also eliminated memory leaks and added lifecycle awareness.