WhoBuilt

The state of React Native

Sep 14, 2018· 25 min· 4.7K views·Watch on YouTube

Speaker

David Vacca, a software engineer on Facebook’s React Native team focused on Android, explains how Facebook uses React Native and outlines the framework’s performance work and planned architecture changes.

React Native across Facebook apps

Vacca says React Native is used in both new and existing apps. Examples include Ads Manager, Analytics, the Oculus companion app, Instagram screens, and Facebook features such as Crisis Response, blood donations, and privacy settings. Marketplace, a Facebook app tab with more than 800 million users and over 100 screens, is one of the framework’s most complex deployments.

Performance and time to interact

The team is working to make React Native screens load faster, with a focus on time to interact. Loading involves starting the JavaScript VM, loading the bundle, initializing managers and native modules, and fetching data. Vacca says the team will share performance improvements and better documentation so open source users can enable existing optimizations.

Why the current architecture is limiting

The current design uses a JavaScript thread, a shadow thread for the native view tree and layout, and the main thread to draw the UI. Communication between threads is asynchronous, which helps keep the UI thread from blocking but can make synchronous updates and layout difficult. When a native screen embeds React Native content sized to that content, delayed layout can cause a visible shift.

A refactored UI layer

The proposed architecture aims to allow synchronous rendering and layout when needed, including layout computation on the UI thread. The team is making the shadow tree immutable by creating a new tree version for updates, and rebuilding parts of the UI layer in C++. A new bridge is intended to support synchronous and asynchronous calls at different priorities, while a compatibility layer limits breaking changes for existing apps.

Rollout milestones and expected benefits

Vacca says the architecture should improve gestures, text input, touch interactions, scrolling, and integration with native platforms. The first milestone tested it on smaller Facebook app screens for iOS and Android without major performance or memory issues. The team was extending the refactor across the framework and integrating the C++ work into Android; new features would follow a full production rollout.

Takeaways

  • React Native was already used across Facebook products, including a Marketplace experience with more than 800 million users.
  • Screen startup depends on several stages, so measure time to interact across the full loading path.
  • Asynchronous work protects UI responsiveness, but some native integrations need synchronous layout or updates.
  • Immutable tree updates can support thread-safe work across multiple threads.
  • A staged rollout can validate performance and memory before extending an architecture change across a framework.

Mentioned in this talk

Search inside this talk

What was claimed 14

Show all 14 facts

Related talks