realm / realm-js

Realm is a mobile database: an alternative to SQLite & key-value stores
https://realm.io
Apache License 2.0
5.62k stars 558 forks source link

Support Hermes engine #2455

Closed ferrannp closed 2 years ago

ferrannp commented 4 years ago

Goals

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

cbstauss commented 4 years ago

I'm having the same issue. I'm wondering if there is something looking for "libjsc.so" that can't find it because hermes replaces "libjsc.so" with "libhermes.so". I've been looking through the SoLoader documentation and the Realm documentation to see if I can find anything.

fealebenpae commented 4 years ago

realm-js uses JavaScriptCore APIs directly on React Native to implement its JS API so right now it cannot run on Hermes. We're planning on migrating to the new API in the coming months.

ferrannp commented 4 years ago

Yeah I was pretty sure this was not an easy change. Glad to hear it is planned to happen @fealebenpae. Thank you!

paschaldev commented 4 years ago

+1

Spent over 48hours debugging this issue. When I disabled hermes, it started working.

dominicsavb commented 4 years ago

can't wait to implement realm with hermes...

matinzd commented 4 years ago

We got stuck migrating project to hermes :((

raphaeleidus commented 4 years ago

@fealebenpae firstly, thank you for all the hard work creating this amazing software. Do you have any rough idea as to when Hermes support might arrive?

I have an app that is stuck in a difficult predicament, the latest JSCore engine has a very high crash rate on certain devices, we can't rollback to earlier RN as it would drop 64bit support, and we can't move to Hermes as we store most of our data in Realm.

We are exploring some dire options at the moment and it would really help us to know if a Realm version might arrive in the next 2 weeks or if we are definitely going to have to wait until October or later.

Again thank you for the hard work. I would love to be able to submit a PR with this functionality, unfortunately this area is totally out of my depth.

fealebenpae commented 4 years ago

Unfortunately we won’t be able to add support for the new Hermes APIs in the next couple of weeks. Because we need to swap out a large part of our C++ codebase to do that it’s likely it’ll take our team months to pull this off.

gochsner commented 4 years ago

Would Hermes support help at all with this issue the chrome debugging issue? That's been a thorn in our side. https://github.com/realm/realm-js/issues/491

ferrannp commented 4 years ago

@raphaeleidus you do not need to downgrade RN. You can use the latest RN with Realm. Just disable Hermes for now. Realm is fully compatible with RN 64 bits.

raphaeleidus commented 4 years ago

@ferrannp RN is not my problem it is the JSC in 0.59.10 (not hermes). For 64bit support on android we had to upgrade to 0.59.10 but the JSCore at that version has a high crash rate. I am not running Hermes at all but the people experiencing this issue: https://github.com/facebook/react-native/issues/25494 and trying to resolve or mitigate it have suggested that moving to Hermes would resolve the issue. I cannot move to Hermes though because I am using Realm. This is the problem. Can't move forward to Hermes because of Realm and can't move back to only 32 bit support because of Google. It is a difficult situation and nobody's fault on any side but I and many others are caught in the middle.

paschaldev commented 4 years ago

I had a similar issue @raphaeleidus. Unrelated, but what solved mine were

After that I stopped getting any issue. I'm using the latest version of React Native (0.60.5). App works fine

raphaeleidus commented 4 years ago

@paschaldev were you able to reenable hermes after that?

paschaldev commented 4 years ago

No... Realm with Hermes gives the JSC error whatever... We'll have to wait unfortunately for Realm before we can use Hermes.

mattijsf commented 4 years ago

@fealebenpae You mentioned that it will take "months to pull this off". Can you tell whether or not this is something that gets attention in the coming months? In other words, is it planned?

We would like to make use of realm-js and disabling Hermes would be acceptable for now but it will be good to know whether or not support for Hermes can be expected.

cristianoccazinsp commented 4 years ago

Also curious about the roadmap for Hermes. Would it be easier to patch Hermes so it can provide some compatibility to w/e Realm needs?

bmunkholm commented 4 years ago

@mattijsf It is something I expect us to prioritize in Q4 (this year), although we haven't done that planning just yet, but will in the coming weeks.

cristianoccazinsp commented 4 years ago

Has anyone tested Realm with JS v8 on Android? https://github.com/Kudo/react-native-v8

Perhaps it's a good alternative.

raphaeleidus commented 4 years ago

@cristianoccazinsp yeah, I have, it is the same problem. Realm very specifically requires the jscore JS engine and doesn't work with other engines

cristianoccazinsp commented 4 years ago

Bummer! I was reading about the high crash rate of JSCore on Android and started to look at alternatives, but looks like Realm is a blocker for any JS alternative.

mattijsf commented 4 years ago

@bmunkholm Obviously we hope it gets picked up soon. Thanks for the update 👍

tatiesmars commented 4 years ago

I suggest using this build script for the moment:

cristianoccazinsp commented 4 years ago

Is it ant better?

El mié., 28 de agosto de 2019 06:56, tatiesmars notifications@github.com escribió:

I suggest using this build script for the moment:

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/realm/realm-js/issues/2455?email_source=notifications&email_token=ALU263FRRASER2IQ2MO4T43QGZDT3A5CNFSM4ICRE4Y2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD5KR62A#issuecomment-525672296, or mute the thread https://github.com/notifications/unsubscribe-auth/ALU263EU2EC5N4AX4NLGO4DQGZDT3ANCNFSM4ICRE4YQ .

joaodematejr commented 4 years ago

+1

pengcao1 commented 4 years ago

+1

DaveLomber commented 4 years ago

++++1

RenanSanguinete commented 4 years ago

+1 In fact, I have 3 apps using Realm and lot of 64bit users complain about crashes. There is any plan to support hermes by now?

bmunkholm commented 4 years ago

We will support Hermes, but unfortunately we can't share a specific timeline yet.

Doing the +1 is best at the top comment with the 👍 - thanks.

cyastioglu commented 4 years ago

Please, we look forward to it.

The0racle commented 4 years ago

@tatiesmars Were you able to use that? I'm curious since RN 59 already uses an updated JSC and it contained crashes fixed only by using Hermes or react-native-v8, which is what we cannot do at the moment when using Realm.

josecarlosns commented 4 years ago

+1 Please do it!

Realm is my go-to option for data storage in mobile apps and Hermes brings some major performance improvements to RN.

Those two should be best friends.

otuchatindonesia commented 4 years ago

+1 Please , we look forward to increase our app performance :)

ceyhun-akyol commented 4 years ago

+1

mzobe commented 4 years ago

My work around to work with Hermes and Realm was to implement a native module to use a JAVA version for Realm in Android.

sfmedion commented 4 years ago

My work around to work with Hermes and Realm was to implement a native module to use a JAVA version for Realm in Android.

Would you care to share this implementation?

otuchatindonesia commented 4 years ago

+1 please do it !, i waiting, and i hope can boost perform react native well

weslley39 commented 4 years ago

+1 please do it !

tatiesmars commented 4 years ago

@tatiesmars Were you able to use that? I'm curious since RN 59 already uses an updated JSC and it contained crashes fixed only by using Hermes or react-native-v8, which is what we cannot do at the moment when using Realm.

@The0racle So far our app is using this version of JSC on android with RN 60 and realm, work like good for us.

cristianoccazinsp commented 4 years ago

@tatiesmars Were you able to use that? I'm curious since RN 59 already uses an updated JSC and it contained crashes fixed only by using Hermes or react-native-v8, which is what we cannot do at the moment when using Realm.

@The0racle So far our app is using this version of JSC on android with RN 60 and realm, work like good for us.

Is there any real advantage of using that version of JSC over RN's one? There also seems to be a few "big" issues still open (https://github.com/react-native-community/jsc-android-buildscripts/issues/84 and https://github.com/react-native-community/jsc-android-buildscripts/issues/82) which I wonder if they would actually make things worse.

Update: Correct me if I'm wrong, but RN >= 59 already uses the latest JSC for Android.

RenanSanguinete commented 4 years ago

@tatiesmars Were you able to use that? I'm curious since RN 59 already uses an updated JSC and it contained crashes fixed only by using Hermes or react-native-v8, which is what we cannot do at the moment when using Realm.

@The0racle So far our app is using this version of JSC on android with RN 60 and realm, work like good for us.

The app build with this version works, but it also crashes on several devices. That's the bigger issue here. Add to that Hermes or V8 improves the apps performance as well.

The0racle commented 4 years ago

My work around to work with Hermes and Realm was to implement a native module to use a JAVA version for Realm in Android.

Could you share what you did?

ParhamZare commented 4 years ago

+1

dominicsavb commented 4 years ago

+1

seydataskin commented 4 years ago

+1

chmiiller commented 4 years ago

+1

ItsNoHax commented 4 years ago

@ferrannp Maybe you could update the issue to support other JS engines. I specifically am looking into implementing react-native-v8 instead of Hermes as we prioritize performance/memory usage over start up speed.

RenanSanguinete commented 4 years ago

So @kneth you guys a working on it?

Rob-Dre commented 4 years ago

@fealebenpae could you maybe publish some rough timeline? Will it take another couple of month?

My project is stuck until this is fixed. :(

bmunkholm commented 4 years ago

@RenanSanguinete @Rob-Dre We haven't started on this yet. Until we do it's hard to share a timeline. We hope to identify resources during this year.

sergii-invoicesimple commented 4 years ago

+1