Support Hermes engine
See original GitHub issueGoals
Make Hermes engine to work with Realm. Hermes comes from react-native 0.60.2 and significantly improves app performance on Android.
Steps to Reproduce
Following https://facebook.github.io/react-native/docs/hermes. if enableHermes: true
, you will get the following:
java.lang.UnsatisfiedLinkError: couldn't find DSO to load: librealmreact.so caused by: dlopen failed: library "libjsc.so" not found
at com.facebook.soloader.SoLoader.doLoadLibraryBySoName(SoLoader.java:738)
at com.facebook.soloader.SoLoader.loadLibraryBySoName(SoLoader.java:591)
at com.facebook.soloader.SoLoader.loadLibrary(SoLoader.java:529)
at com.facebook.soloader.SoLoader.loadLibrary(SoLoader.java:484)
at io.realm.react.RealmReactModule.<clinit>(RealmReactModule.java:56)
at io.realm.react.RealmReactPackage.createNativeModules(RealmReactPackage.java:31)
With enableHermes: false
, everything works as expected.
Version of Realm and Tooling
- Realm JS SDK Version: 2.28.1
- React Native: 0.60.3
Issue Analytics
- State:
- Created 4 years ago
- Reactions:313
- Comments:138 (15 by maintainers)
Top Results From Across the Web
Using Hermes - React Native
Hermes is an open-source JavaScript engine optimized for React Native. ... Hermes supports the Chrome debugger by implementing the Chrome ...
Read more >Hermes | Hermes
Support Ukraine Help Provide Humanitarian Aid to Ukraine. Hermes. JavaScript engine optimized for React Native. Start Using Hermes ...
Read more >Using Hermes Engine - Expo Documentation
A guide on configuring Hermes for both Android and iOS in an Expo project. ... The Hermes engine is fully supported across all...
Read more >react-native with Hermes (android) using Realm: Crash on ...
It turns out that, as stated here, Realm does not support Hermes and the team is struggling to get it done. Seems like...
Read more >Realm JavaScript v11: A Step Forward for React Native
... React Native — Hermes Support, Realm React, Flipper, and Much More ... we have built underlying support for the new Hermes JS...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Is v10 with MongoDB Realm Cloud really more important than Hermes support? Hermes is a requirement for new versions of some core libraries, so this issue is a huge blocker
Hey All - Product from Realm here, we appreciate all of the community interest and we agree - Hermes is an important piece of the React Native platform and we want to build support for it - it’s a top priority. However, the team and I have done an extensive review of the Hermes integration and the React Native options for embedding and we are unfortunately blocked by the Hermes and React Native architecture. Let me explain.
The Realm Database, at its core, is written in C++ - all of the things that make Realm great - an object database with automatic schema generation, live objects with queries and writes performed in an ACID compliant way, fine-grained notifications enabling a reactive UI, and sync - depend on our ability to expose APIs to the JavaScript VM on the same thread it runs on. Unfortunately, React Native does not provide a public API that allows us to talk to the JS VM. When we built our integration four years ago we wrote a workaround that intercepts the creation of the JS VM and allows us to inject our APIs and otherwise interact with the VM. You can see this here: https://github.com/realm/realm-js/blob/master/src/android/jsc_override.cpp
If you haven’t seen Assembly code in a long time, it’s because you shouldn’t. Our expectation, and I believe any developer’s expectation, would be that if a platform wanted to support embedded libraries there would be stable public APIs for us to interface with. This workaround has led to all of the things you would predict - broken releases as new versions of RN are released and as they change the underlying private API implementation, writing new workarounds to fix the old ones, leading to reduced productivity and feature velocity.
The addition of the JavaScript Interface (JSI) API is an important step towards enabling C++ React Native modules which expose synchronous APIs on the JavaScript thread. But even though Hermes implements JSI, the crucial plumbing that lets C++ modules use JSI to implement JS APIs is still missing. This means that for Hermes we need to develop a new workaround that intercepts the JS VM. And while JavaScriptCore is relatively mature and stable and the private APIs we access for our workaround don’t change much anymore, Hermes is actively developed and any private APIs we might need to resort to for our workaround will most likely change often, and thus break our Hermes integration.
There are proposals from the RN community on how to solve this, we are not alone. One of them is Turbo Modules, which have been in progress for some time, but not enabled by default yet. This has been discussed here -
https://github.com/react-native-community/discussions-and-proposals/blob/master/proposals/0002
Our hope is that the combination of JSI and TurboModules will enable cross-platform C++ modules like Realm to target all React Native platforms - iOS, Android, macOS, and Windows, all with different JavaScript engines, without requiring app developers to perform any extra steps beyond installing a package from NPM.
There is an open issue to implement them here but it appears to be deprioritized - https://github.com/facebook/react-native/issues/28128
I share this with you in the vein of full transparency but my ask to the community is can you help us getting this prioritized and delivered by the RN team? This would help us and countless other libraries out there that want to embed.
There is a clear need and use case. In fact, Microsoft, with a much newer platform, is already going in the direction we need with https://github.com/microsoft/react-native-windows/pull/5085 https://github.com/microsoft/react-native-windows/pull/5461
Thank you, Ian