Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feedback on Hermes support #3940

Closed
kneth opened this issue Sep 2, 2021 · 94 comments
Closed

Feedback on Hermes support #3940

kneth opened this issue Sep 2, 2021 · 94 comments
Labels
hermes Bugs and features related to running on the React Native hermes engine Reproduction-Required T-Bug

Comments

@kneth
Copy link
Contributor

kneth commented Sep 2, 2021

We are working hard on getting Hermes supported by Realm JavaScript, and we are releasing a series of pre-releases to test our progress.

We encourage you to try out the pre-release in your development environment (don't use it in production yet). Create a new issue with your observations, including details about iOS version, other JavaScript libraries. Please use the Hermes issue template.

We appreciate your feedback, but we cannot guarantee if and when we respond to your comment.

Current state

  • Version: v11.0.0-rc.1 (or v11.0.0-rc.0 if you're using a React Native version between 0.66.0 and 0.68.2)
  • Both iOS and Android are supported
  • Required React Native version is 0.69.0 or above this is very important, since JSI is not ABI stable and your app will simply crash if the version isn't correct. Use v11.0.0-rc.0 for older versions of React Native).
  • 0 of 276 tests are failing

Installation

We are keeping the pre-releases under the tag hermes, and you can install the latest pre-release using the following command:

npm install realm@hermes

For a more comprehensive list of TODOs, please see our PR and the source code for TODO comments.

@HSReact
Copy link

HSReact commented Sep 2, 2021

Great news thank you!!

@8BallBomBom
Copy link

Wonderful news but as most of my development is mainly focused on Android... the waiting game continues.
Will jump in to test once that arrives 👍🏻

@bmunkholm bmunkholm added the hermes Bugs and features related to running on the React Native hermes engine label Sep 2, 2021
@cristianoccazinsp
Copy link

I'm also more interested on the Android side as non-hermes for iOS is quite fast and stable, but Android is the one that's slow and buggy. However, great progress, I will be giving it a try as well on my free time.

What is the roadmap for Android? Does it need an entire new implementation as well, or is it the same code base with some tweaks?

@kraenhansen
Copy link
Member

kraenhansen commented Sep 2, 2021

What is the roadmap for Android? Does it need an entire new implementation as well, or is it the same code base with some tweaks?

We fully understand the need to get this out on Android ASAP too and we're full-throttling into that now 🚀
The only reason we're pre-releasing for iOS and not Android at this moment is because we've hit less road-blocks in our implementation on iOS.

To be more detailed: We have a couple of outstanding issues in the way we bootstrap the module and the ability to catch exceptions natively on Android that we have to solve for a release to be usable. The good news is that majority of the code is shared between iOS and Android and we mainly need to solve issues in code and build-scripts for the part that bootstraps our .so library on Android.

@tedi
Copy link

tedi commented Sep 2, 2021

Great news, thank you for all your hard work. We will be testing this in our next dev cycle and report back.

@moonpang
Copy link

moonpang commented Sep 3, 2021

Great news!!!

@joaodematejr
Copy link

I created a new application and installed it but it doesn't open the application, some Flipper log

Screen Shot 2021-09-04 at 01 29 55

Screen Shot 2021-09-04 at 01 29 32

Screen Shot 2021-09-04 at 01 18 07

Screen Shot 2021-09-04 at 01 12 29

Process: realmHermes [16230]
Path: /Users/USER/Library/Developer/CoreSimulator/Devices/A0FFE31C-C19D-4CAC-917B-010B6CE3F4A2/data/Containers/Bundle/Application/732FAEC5-5CE9-4101-B41A-59C0DC19BF48/realmHermes.app/realmHermes
Identifier: realmHermes
Version: 1.0 (1)
Code Type: X86-64 (Native)
Parent Process: launchd_sim [11811]
Responsible: SimulatorTrampoline [7116]
User ID: 501

Date/Time: 2021-09-04 01:10:10.191 -0300
OS Version: macOS 11.5.2 (20G95)
Report Version: 12
Anonymous UUID: 1E47EC22-9B28-370B-4B8C-FC36E91171B3

Time Awake Since Boot: 5600 seconds

System Integrity Protection: disabled

Crashed Thread: 12 com.facebook.react.JavaScript

Exception Type: EXC_BAD_INSTRUCTION (SIGILL)
Exception Codes: 0x0000000000000001, 0x0000000000000000
Exception Note: EXC_CORPSE_NOTIFY

Termination Signal: Illegal instruction: 4
Termination Reason: Namespace SIGNAL, Code 0x4
Terminating Process: exc handler [16230]

Application Specific Information:
CoreSimulator 757.5 - Device: iPhone 8 (A0FFE31C-C19D-4CAC-917B-010B6CE3F4A2) - Runtime: iOS 14.5 (18E182) - DeviceType: iPhone 8

Thread 0:: Dispatch queue: com.apple.main-thread
0 com.apple.CoreFoundation 0x00007fff2038b171 __CFRunLoopRun + 2789
1 com.apple.CoreFoundation 0x00007fff2038a1a7 CFRunLoopRunSpecific + 567
2 com.apple.GraphicsServices 0x00007fff2b874d85 GSEventRunModal + 139
3 com.apple.UIKitCore 0x00007fff246c14df -[UIApplication _run] + 912
4 com.apple.UIKitCore 0x00007fff246c639c UIApplicationMain + 101
5 org.reactjs.native.example.realmHermes 0x000000010ed664d0 main + 112 (main.m:7)
6 libdyld.dylib 0x00007fff2025abbd start + 1

EXC_BAD_INSTRUCTION

EXC_BAD_INSTRUCTION

Process: realmHermes [21541]
Path: /Users/USER/Library/Developer/CoreSimulator/Devices/D5A0AFC6-F590-4E42-8B9D-867AD36CB43A/data/Containers/Bundle/Application/6AF8443A-4B97-4CCE-86AC-9F90A66740CA/realmHermes.app/realmHermes
Identifier: realmHermes
Version: 1.0 (1)
Code Type: X86-64 (Native)
Parent Process: launchd_sim [18331]
Responsible: SimulatorTrampoline [7116]
User ID: 501

Date/Time: 2021-09-04 01:27:10.133 -0300
OS Version: macOS 11.5.2 (20G95)
Report Version: 12
Anonymous UUID: 1E47EC22-9B28-370B-4B8C-FC36E91171B3

Time Awake Since Boot: 6600 seconds

System Integrity Protection: disabled

Crashed Thread: 12 com.facebook.react.JavaScript

Exception Type: EXC_BAD_INSTRUCTION (SIGILL)
Exception Codes: 0x0000000000000001, 0x0000000000000000
Exception Note: EXC_CORPSE_NOTIFY

Termination Signal: Illegal instruction: 4
Termination Reason: Namespace SIGNAL, Code 0x4
Terminating Process: exc handler [21541]

Application Specific Information:
CoreSimulator 757.5 - Device: iPhone 12 (D5A0AFC6-F590-4E42-8B9D-867AD36CB43A) - Runtime: iOS 14.5 (18E182) - DeviceType: iPhone 12

Thread 0:: Dispatch queue: com.apple.main-thread
0 com.apple.CFNetwork 0x00007fff237203e4 0x7fff2353f000 + 1971172
1 com.apple.CoreFoundation 0x00007fff20392513 _CFRelease + 244
2 com.apple.CFNetwork 0x00007fff235ed2a9 0x7fff2353f000 + 713385
3 libobjc.A.dylib 0x00007fff20178c42 object_cxxDestructFromClass(objc_object*, objc_class*) + 83
4 libobjc.A.dylib 0x00007fff2018abee objc_destructInstance + 64
5 libobjc.A.dylib 0x00007fff20190d88 -[NSObject dealloc] + 21
6 com.apple.CFNetwork 0x00007fff236fff51 0x7fff2353f000 + 1838929
7 libobjc.A.dylib 0x00007fff20191604 objc_object::sidetable_release(bool, bool) + 174
8 com.apple.CFNetwork 0x00007fff237017c5 0x7fff2353f000 + 1845189
9 libobjc.A.dylib 0x00007fff20191604 objc_object::sidetable_release(bool, bool) + 174
10 com.apple.CFNetwork 0x00007fff2377bddb 0x7fff2353f000 + 2346459
11 com.apple.CFNetwork 0x00007fff23556f4f 0x7fff2353f000 + 98127
12 libobjc.A.dylib 0x00007fff20191604 objc_object::sidetable_release(bool, bool) + 174
13 libobjc.A.dylib 0x00007fff20192dc7 AutoreleasePoolPage::releaseUntil(objc_object**) + 175
14 libobjc.A.dylib 0x00007fff20192cb6 objc_autoreleasePoolPop + 185
15 com.apple.CoreFoundation 0x00007fff20432036 _CFAutoreleasePoolPop + 22
16 com.apple.CoreFoundation 0x00007fff2038fd5c __CFRunLoopPerCalloutARPEnd + 41
17 com.apple.CoreFoundation 0x00007fff2038b1a2 __CFRunLoopRun + 2838
18 com.apple.CoreFoundation 0x00007fff2038a1a7 CFRunLoopRunSpecific + 567
19 com.apple.GraphicsServices 0x00007fff2b874d85 GSEventRunModal + 139
20 com.apple.UIKitCore 0x00007fff246c14df -[UIApplication _run] + 912
21 com.apple.UIKitCore 0x00007fff246c639c UIApplicationMain + 101
22 org.reactjs.native.example.realmHermes 0x0000000109f3e4d0 main + 112 (main.m:7)
23 libdyld.dylib 0x00007fff2025abbd start + 1

@kraenhansen
Copy link
Member

kraenhansen commented Sep 4, 2021

@joaodematejr thanks a lot for taking this for a spin! Can I get you to move this to a new issue? GitHub comments are really bad at threaded conversations ...

@liamjones
Copy link

@kneth Does this require a specific version of RN? I'd like to give this a try with one of our apps but that's still on 0.63.4, is that up-to-date enough?

@kneth
Copy link
Contributor Author

kneth commented Sep 6, 2021

@liamjones Our tests are using 0.64.2, and you might have to bump to 0.64 for it to work.

@kraenhansen
Copy link
Member

kraenhansen commented Sep 22, 2021

We just pre-released realm at v10.20.0-alpha.1 with support for Hermes running on Android too! 🎉

Please note that React Native must be at version 0.66.0-rc.3 or later .. this is very important, since JSI is not ABI stable and your app will simply crash if the version isn't correct.
Also hot reloading of app is working on iOS only (Android will be coming soon).

As an experiment, we're trying out the GitHub release discussion feature: So if you have any experiences (good or bad) with this pre-release, please share them over at #3978

@kraenhansen
Copy link
Member

kraenhansen commented Nov 29, 2021

We've released a new version of Realm JS with support for the Hermes engine: Realm JS v10.20.0-alpha.2.
This fix the crash when reloading the app on Android.

Please take it for a spin and provide any feedback or issues you might have using the Hermes issue template:

npm install realm@hermes

@salembaira
Copy link

salembaira commented Dec 11, 2021

@kraenhansen Tested this extensively with a pool of users in one of my apps. No issues reported so far!

@HSReact
Copy link

HSReact commented Dec 11, 2021

Awesome news

@kraenhansen
Copy link
Member

@baira thank you so much for doing that!
This helps us build confidence in the release, which moves us one step closer to releasing this on our "latest" branch.

@cristianoccazinsp
Copy link

Where can I find currently known issues?

Is it possible to test only for Android with this version? Which one is more stable, Android or iOS?

@cristianoccazinsp
Copy link

@kraenhansen I will be testing 10.20.0-alpha.2 on Android with Hermes over the next few days to about ~50 users.

I will also be testing 10.20.0-alpha.2 on iOS, but without Hermes (as it doesn't support INTL yet and polyfills are terrible), do you know if this Realm version without Hermes may be problematic? I've noticed you got rid of GCDWebServer dependency, so I'm afraid this version may have issues if not using Hermes.

@mordechaim
Copy link

Does rc.1 work on react-native@0.70.0-rc.4?

I've spent my entire day to get it to work but I'm running into RealmProvider not being available from @realm/react

@takameyer
Copy link
Contributor

takameyer commented Aug 30, 2022

I'm running into RealmProvider not being available from @realm/react

The RealmProvider is returned in the object returned by createRealmContext. This allows one to create and use multiple Realms.

import {createRealmContext} from '@realm/react';

const myRealmConfig = { schema: [Task, User, /*...*/]};

const { RealmProvider, useRealm, useObject, useQuery } = createRealmContext(myRealmConfig);

const AppWrapper = () => {
  return (
    <RealmProvider>
      <App/>
    <RealmProvider>
  )
}

src: https://github.com/realm/realm-js/tree/master/packages/realm-react#setting-things-up

@HSReact
Copy link

HSReact commented Aug 30, 2022

An update on the current status from the Realm team would be nice @kraenhansen @kneth Thank you

@osama-kwanso
Copy link

osama-kwanso commented Aug 30, 2022

An update on the current status from the Realm team would be nice @kraenhansen @kneth Thank you

Yes its been a year since they last updated. @kneth we really wanna use this in production so please guide us can we now?

@kneth
Copy link
Contributor Author

kneth commented Aug 30, 2022

We are moving forward with JSI and Hermes. Unfortunately we are experiencing some performance regressions but our confidence is growing as we put out new prereleases of v11.

Version 11.0.0 will bring more than JSI/Hermes support - we have outlined what you can expect here.

@HSReact
Copy link

HSReact commented Aug 30, 2022

From your outline:

"We cannot promise any specific release date, only that we will release it when we and the code are ready."

The writing is on the wall for me. You guys are struggling to make this happen and this does not bode well.

As paying customers who have stayed with you, this is the least we can expect.

Sad News for me.

@salembaira
Copy link

I've been following this thread for a long time. I guess a lot of people also do silently. I have many projects with realm already and everytime we start a new one, realm seems to be holding us back.

@mordechaim
Copy link

mordechaim commented Aug 30, 2022

The RealmProvider is returned in the object returned by createRealmContext. This allows one to create and use multiple Realms.

Yes, I'm aware of this, I'm trying to migrate an existing app from 0.68.2 to 0.70.0-rc.4.

I updated my dependency from realm@11.0.0-rc.0 to 11.0.0-rc.1 but the following code

const { RealmProvider, useRealm, useObject, useQuery } = createRealmContext(myRealmConfig);

Will fail with

cannot read property 'RealmProvider' from undefined

Now, I'm still having trouble building on the new architecture so I was trying with newArchEnabled=false, this could be the issue, although it did work perfectly on 0.68 with realm@11.0.0-rc.0

@takameyer
Copy link
Contributor

takameyer commented Aug 30, 2022

@mordechaim can you please create a new issue for this? We haven't officially made an update for 0.70.0-rc.4. It is possible that we need to create a new release for this. Since the Hermes migration, we are hard bound to any updates to react-native and need to create a new release if there are any changes to the Hermes engine that are not compatible with the previous version.
Since you are running on multiple -rc version between realm and react-native it is very well possible there will be issues.

@ianpward
Copy link

ianpward commented Aug 30, 2022

Hi All, Product for Realm here. As the engineering team mentioned, we have some outstanding work that we want to wrap up before moving v11 to master. Kenneth mentioned a performance regression that we uncovered and right now, that performance regression seems to be due to React Native's underlying architecture - so unfortunately, we are waiting for them to fix this issue. Once they fix this, we will need to retest to see where we are at.

However, there is nothing stopping you from using our RC version in production today (perhaps your code doesn't hit the regressions at all?) Only you, as the app developer and owner, can make the call whether you are comfortable with using a release candidate in production. In fact, you already are if you are using React Native as a platform, which is pre-1.0 framework with an ever-changing and breaking API. This makes it difficult for us to keep up without making breaking changes in our version support. For an embedder such as ourselves, we've had to fight quite a bit against the framework and overwrite private APIs in order for us to even work, which is likely why you don't see many native C++ libraries that need to reflect across the bridge. We hope that the new architecture with TurboModules and Fabric will make this easier and easier in the future.

I would advise you to first run all your unit and performance testing with our RC release and if this passes, along with a successful UAT - you can then make a call whether you feel comfortable releasing to the app store.

All this being said, we are in contact with the React Native team, and are hopeful that fixes will come soon - I hope that we will release our v11 master before the end of the year. If there is anyone who would like to discuss their situation further I am always available for a chat and you can reach out to me at ian.ward@mongodb.com and we can setup a meeting time.

@martinpoulsen
Copy link

Excited to see progress on v11! However, I'm still confused about the compatibility:

  1. Will it require some minimum/specific RN version?
  2. Is enabling Hermes required?
  3. Is enabling the new architecture required?

@kneth
Copy link
Contributor Author

kneth commented Sep 2, 2022

Will it require some minimum/specific RN version?

Yes, but we haven't decided which one yet. 0.70 is just around the corner,

Is enabling Hermes required?

With our JSI implementation, we are able to support both JSC and Hermes. When we release v11, we will try to document the advantages and disadvantages for both so you can make an informed decision.

Is enabling the new architecture required?

Currently our focus is on JSI. TurboModules will be worth investigating at some point.

@martinpoulsen
Copy link

Currently our focus is on JSI. TurboModules will be worth investigating at some point.

Does this mean that enabling the new architecture will not be an option in the foreseeable future when depending on Realm?

@HSReact
Copy link

HSReact commented Sep 2, 2022

So, can I ask a straight question.

I would like to use Hermes to get the benefits (faster UI load times, smaller pkg sizes etc).

Will Realm ever be in a position to support Hermes on React Native.

It’s not clear to me from your answer. I’m sensing that you’re saying that Hermes and Realm will never be a perfect fit.

@HSReact
Copy link

HSReact commented Sep 2, 2022

@martinpoulsen my question exactly, I’m not getting a clear picture

@takameyer
Copy link
Contributor

Will Realm ever be in a position to support Hermes on React Native.

Yes, you can do this today. npm install realm@11.0.0-rc.1 with React Native 0.69.*

@mordechaim
Copy link

Currently our focus is on JSI. TurboModules will be worth investigating at some point.

Does this mean that enabling the new architecture will not be an option in the foreseeable future when depending on Realm?

The new architecture was designed for gradual migration. You can enable the new architecture and still have libraries that use legacy modules.

The JSI is available regardless.

@tedi
Copy link

tedi commented Sep 2, 2022

We've been running realm with hermes in production on IOS the past 4 months with no real issues. We recently ran into some issues when upgrading to RN .69x but had to revert back to .68 for a few other reasons.

We have kept a close eye on local db related issues since we updated to the hermes supported realm and are happy to report everything has been working great on our end. We've been using it for fairly heavy operations, often managing thousands of records at a time and haven't run into any problems at all.

Thank you for your work Realm team.

@tomduncalf
Copy link
Contributor

tomduncalf commented Sep 6, 2022

TL;DR: Update on v11 performance regression. With RN v0.70, we are seeing benchmark results around 0.6x vs master with Hermes enabled, and 0.4x vs master with Hermes disabled. Note that this is a reasonable worst case, and for many use cases we would not expect the regression to have an impact. We expect RN v0.71 should allow us to greatly improve performance for Hermes users, but unfortunately there is nothing we can do for users with Hermes disabled without changes to RN, so our recommendation to these users is to move to using Hermes or to stay on v10 if your use case is performance sensitive.

Hi all,

I wanted to provide a bit more detail on the situation related to performance regressions referenced above and in #4443, as I've been doing a lot of research into this.

To briefly summarise, in order to support Hermes we had to move from interacting with the JavaScriptCore engine (JSC) directly, to using JSI (which is an abstraction layer for working with Hermes and JSC). This meant we had to change the way we attach C++ objects to JS objects, as JSI does not support the mechanism we used previously (JSC's JSObjectSetPrivate).

Unfortunately, the best method we were able to find to do this with JSI is quite a lot slower (Realm JS does not fit well with the HostObject concept JSI provides), and this results in performance regressions, as accessing the C++ object is a "hot path" in Realm. I should stress that this should only be an issue in “worst case” scenarios, e.g. inserting many objects in a loop, and for most common use cases, we wouldn't expect there to be any noticeable regression.

The current situation on our v11 branch with the final React Native 0.70 release (we will be releasing a version supporting 0.70 soon) is that our benchmark (which repeatedly accesses an object in a loop as fast as it can) performs around 0.6x the speed of master with Hermes enabled (this is a vast improvement on 0.69, where it was around 0.25x), and around 0.4x with Hermes disabled.

We've been working with Meta to try to understand the options available to us to improve this situation, and the good news is that in React Native v0.71, a new API is being introduced for attaching C++ objects to JS objects, and our initial testing suggests that this should bring performance much closer to parity with master when using the Hermes engine (we have a draft PR to add support for this when RN v0.71 is ready).

Unfortunately, this API is not currently available when Hermes is disabled, and so we do not expect RN v0.71 to improve performance for users with Hermes disabled. We have created a proposal to implement this support in React Native. Until that happens (which cannot be guaranteed, as I imagine Meta are mainly focussed on Hermes), we would expect performance using v11 with Hermes disabled to suffer from this regression. Whether this regression is significant or not would depend on your workload.

We’ve exhausted every other avenue we can think of in trying to find a solution for this, but without support for it at the React Native level, there’s no way we can work around this (while still supporting libraries such as Reanimated), so we recommend all users migrate to Hermes, and if this performance regression is critical to your use case, to remain on Realm v10 until you can migrate.

Thanks,
Tom

@brunoducattii
Copy link

brunoducattii commented Sep 27, 2022

Have there been any changes to the Realm 11.0.0-rc.2 in the last few days?

The same projects with RN 0.70.1 + Realm 11.0.0-rc.2 + Hermes true are slow again. About 4 days ago it was ok.

Both Android and iOS.

@kneth
Copy link
Contributor Author

kneth commented Sep 27, 2022

@joaotmachado We don't modify versions after release. Can it be explained by a different use pattern? If so, we are interesting to hear about it as it might help us to optimise in the future.

@kneth
Copy link
Contributor Author

kneth commented Oct 19, 2022

Yesterday we released version 11.0.0 and we now consider Hermes a fully supported JavaScript engine.

I would like to thank everybody who have tried our prereleases, provided feedback and showed us patience and trust during the integration with Hermes. It has been a large effort for a small team, and we have been motivated by your support.

@kneth kneth closed this as completed Oct 19, 2022
@HSReact
Copy link

HSReact commented Oct 19, 2022

Great news and thank you all for your hard work and in exercising patience whilst accepting our feedback.

@8BallBomBom
Copy link

Been a long road, thanks for the great work 👍🏻

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 15, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
hermes Bugs and features related to running on the React Native hermes engine Reproduction-Required T-Bug
Projects
None yet
Development

No branches or pull requests