Hermes moves toward becoming React Native's default JS engine
The React Native team has published an update on Hermes, its JavaScript engine, stating that the goal is to make Hermes the default engine for React Native across all platforms. The post reviews progress made since Hermes was announced in 2019 and notes growing adoption, including experimental Hermes support from Expo and alpha support from Realm.
Performance work
Hermes compiles JavaScript ahead of time, so apps ship precompiled bytecode rather than plain source. According to the team, measurements from Facebook and community apps suggest enabling Hermes often cuts Time-To-Interactive (TTI) by nearly half.
A major change is a new, mostly concurrent garbage collector named Hades, replacing the single-threaded GenGC. With the upcoming Fabric renderer able to call JavaScript synchronously on the UI thread, long GC pauses can cause dropped frames. GenGC averaged 200ms pauses on Facebook for Android (1.4s at p99). Hades pauses for 48ms at p99.9 on 64-bit devices and around 88ms on 32-bit devices, at some cost to overall throughput.
Other improvements include:
- A new 32-bit value encoding for small integers and pointers, reducing JavaScript heap size by about 30%.
- Optimized GC cell header layouts, cutting memory usage by another ~15%.
- An experimental Hermes-specific Babel transform profile in Metro at Facebook, which showed 18–25% TTI improvements on many surfaces.
- Pre-tenuring the first 32MiB of allocations into the old generation to avoid GC pauses during startup.
Hermes intentionally does not include a JIT compiler; the team continues to focus on interpreter and compiler optimizations.
Integration with React Native
Hermes supports on-device debugging via the Chrome DevTools Protocol, and its debugger is part of Flipper. The team that maintains Hermes also maintains its JSI implementation, which underpins the new architecture. Promises in React Native were historically polyfilled with setImmediate; work is underway to expose native promises and microtasks via JSI and to introduce queueMicrotask.
Platforms
Hermes was originally Android-only. Callstack brought it to iOS in React Native 0.64, reporting ~40% faster startup and ~18% less memory than JSC in the Mattermost app with 2.4 MiB of size overhead. Microsoft has been bringing Hermes to React Native for Windows and macOS, and Hermes also powers all virtual reality experiences built with the React family of technologies on Oculus.
Community-driven features
- Proxy, requested for libraries like MobX and Immer, is enabled by default from v0.7.
- Intl (ECMA-402) is included by default from v0.8 on Android, built on ICU facilities provided by the operating system with a size impact of about 3% (57-62K per ABI). iOS support will be worked on by fellows of a Major League Hacking open source fellowship.
- A fix for
Array.prototype.sortstability will ship in the next release. - The default heap size limit was raised from 512MiB to 3GiB to reduce GC pressure and OOM crashes.
- Feedback on
Function.prototype.toStringreinforced a stance that Hermes should avoid getting in developers' way.
Feedback
The team asks developers to try Hermes and report issues, questions, and incompatibilities on its GitHub repository.
Links
Source: reactnative.dev