In a major engineering collaboration between Meta and Google, the teams behind Instagram Direct and Jetpack Compose have detailed how a massive architectural overhaul transformed one of the world’s most heavily used messaging platforms. By migrating Instagram Direct from a legacy Android View system to Jetpack Compose, the engineering teams did more than simply modernize the user interface. They built an AI-native codebase that dramatically reduced code volume, cut token costs, and improved execution times while setting a new standard for performance in large-scale mobile applications. Instagram Direct handles billions of messages daily, serving as a core surface of the Instagram application. Over years of iterative development, the engineering team had squeezed every possible micro-optimization out of the legacy Android View system. However, maintaining and expanding a heavily optimized legacy architecture creates significant technical debt and ongoing engineering overhead. This challenge is magnified as modern development teams increasingly adopt declarative UI paradigms and AI coding assistants. Read Also: Google Enhances Android Development Ecosystem with New CLI Capabilities and Expanded AI Agent Skills Google Announces Major Updates to Android CLI and AI Agent Tooling Featuring Remote Device Streaming and Wear OS Skills The decision to adopt Jetpack Compose for Instagram Direct evolved far beyond a typical UI modernization project. By rethinking the codebase from the ground up to be AI-native, the team achieved a UI codebase that is fifty percent smaller than the original implementation. Furthermore, the migration yielded a thirty-five percent reduction in AI agent execution time, thirty-two percent fewer engineer-agent exchanges, and a thirty-three percent reduction in token costs. Through this close partnership, Meta and Google optimized Jetpack Compose not only to benefit Instagram, but to enhance the broader Android developer ecosystem as well. Modernizing the Codebase at Massive Scale Artificial intelligence has rapidly transformed into a daily companion for software engineers across the tech industry, and applying AI to large-scale codebases already yields measurable productivity gains. Yet, the Instagram Direct team set a far more ambitious goal. Rather than simply deploying AI tools against existing legacy code, the team redesigned the codebase and its underlying architecture to be inherently AI-native, thereby multiplying the impact of AI far beyond what retrofitting could ever achieve. Jetpack Compose was selected as a cornerstone for this new architecture. Its declarative nature ensures that code remains concise, predictable, and structurally easier for AI models to reason about. Declarative code inherently features fewer side effects, less implicit state, and much clearer component boundaries. Executing this migration across a platform utilized by hundreds of millions of people required meticulous planning. The transition had to be gradual and seamless, ensuring zero disruption to the user experience while engineers re-architected the foundation underneath. To put the scale of the challenge into perspective, individual UI components within Instagram Direct can render in over one hundred and sixty distinct state permutations, while a single conversation screen manages more than two hundred distinct message types. When migrating a codebase of this magnitude, developers often face the temptation to take a shortcut by embedding Compose UI components directly inside the existing View hierarchy. While such an approach can serve as an acceptable stepping stone during a transitional phase, it introduces long-term architectural friction. AI coding tools frequently select the path of least resistance. When imperative and declarative UI paradigms are mixed, AI agents often blend them incorrectly, inadvertently introducing subtle bugs, technical debt, and performance regressions. Building an AI-Native UI Architecture At the immense scale of Instagram, architectural abstractions are essential for long-term maintainability. A common pattern in traditional Android development involves modeling every list item type as a descendant of a custom base class that exposes standard lifecycle hooks such as onBind. However, mixing imperative view logic with declarative Compose lambdas inside these abstractions can cause variables and state flags to survive recycling and re-binding across rows, leading to hard-to-reproduce bugs. To make the codebase truly AI-friendly, the Instagram Direct team established strict architectural rules. List items could still maintain their own abstractions, but all Compose code had to be restricted to the constructor level. This restriction strips the UI code of direct access to mutable class members or external state, ensuring its only inputs arrive cleanly through the constructor. As a result, these components function similarly to plain composable functions while still conforming to the existing application architecture. Migrating hundreds of UI components required running multiple AI agents simultaneously against a shared knowledge base of reusable skills and conventions established during the migration. This shared repository ensured that workflows and best practices remained synchronized across the entire engineering team. By splitting the migration of each screen into distinct stages, individual engineers could rapidly settle architectural decisions and tricky edge cases up front. Once that groundwork was laid, other team members could step in to finalize the UI without needing to resolve foundational design questions, keeping the overall migration velocity exceptionally high. The quantitative results of the migration validated the approach. For migrated Instagram Direct surfaces, Jetpack Compose enabled a fifty percent reduction in total UI code. Internal data analyses comparing AI agent sessions working on Compose UI against identical tasks executed using Android Views revealed significant efficiency gains. The data demonstrated that files implemented with Android Views suffered a thirty percent drop in agent resource efficiency when their accumulated risk score doubled. In contrast, files implemented with Jetpack Compose experienced only a nine percent reduction in resource efficiency under the same circumstances. Performance Optimizations and the LazyColumn Core Because Instagram Direct is central to the user experience, maintaining high performance and responsiveness was non-negotiable. Adopting Jetpack Compose required matching or exceeding the rigorous performance standards established by years of optimization on the legacy View-based implementation. The engineering team tracked numerous runtime production metrics to evaluate the migration through rigorous A/B testing. Early insights highlighted a common pitfall in UI migrations: small-scale experiments involving only a handful of components often fail to reveal the true performance picture. The more extensively a surface is migrated end-to-end without bridging interruptions, the clearer and more positive the performance outcomes become. The core screens of Instagram Direct rely heavily on long lists of varied item types, historically implemented using RecyclerView. While the team initially migrated hundreds of individual list items to Compose while retaining the underlying RecyclerView architecture, a natural next step involved replacing the RecyclerView core entirely with the Compose-native equivalent, LazyColumn. To facilitate seamless A/B testing and production rollouts, the team engineered a flexible abstraction layer. New Compose items were designed to be natively compatible with LazyColumn while also supporting an interop API that allowed them to be slotted into a RecyclerView. This dual compatibility enabled engineers to test the LazyColumn architecture side-by-side with RecyclerView using identical Compose items, allowing for extensive performance polishing without disrupting ongoing feature development. Collaboration with Google on Advanced Compose Features The scale, complexity, and performance sensitivity of Instagram presented unique challenges that pushed Jetpack Compose into new territory. Addressing these demands required a hands-on, iterative partnership between Google and Meta engineers. Together, the teams analyzed runtime metrics to design and implement new Compose capabilities that matched or exceeded legacy benchmarks. One major result of this collaboration was the introduction of pausable composition, which allows expensive lazy-list items to be composed incrementally across multiple frames to eliminate visual stutter, or jank. When paired with the LazyLayoutCacheWindow API, this combination significantly improves scroll smoothness. Internal testing at Meta revealed that combining pausable composition with a one-viewport cache window reduced large frame drops per minute by approximately thirteen percent compared to standard Compose implementations. The cache window mechanism prepares and retains off-screen items within a pixel-based band around the viewport, facilitating rapid flings and seamless scrolling. Another critical outcome of the technical partnership was the development of the onVisibilityChanged API. This feature provides large-scale Jetpack Compose surfaces with a standardized, reliable method to detect when a composable element is actively visible on screen, replacing the custom, hand-rolled visibility tracking solutions used previously. These visibility signals power product quality metrics across hundreds of files within Instagram Direct. Startup performance was similarly enhanced. While the Jetpack Compose runtime carries a one-time warmup cost, the high-traffic nature of messaging meant that early session usage in Instagram Direct warmed up Compose for other app surfaces, leading to noticeable performance gains across the entire application. Furthermore, the team leveraged Baseline Profiles to pre-compile hot code paths at install time, ensuring that Compose renders rapidly from the very first launch. The successful migration of Instagram Direct demonstrates how integrating Jetpack Compose with a focus on AI-readiness can fundamentally improve developer productivity, reduce codebase complexity, and elevate application performance at global scale. Post navigation Google Expands Android Developer Tooling with Enhanced CLI Capabilities and AI-Powered Wear OS Integration