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

Feedback on Hermes support #3940

Closed kneth closed 1 year ago

kneth commented 2 years ago

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

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 commented 2 years ago

Great news thank you!!

8BallBomBom commented 2 years ago

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 👍🏻

cristianoccazinsp commented 2 years ago

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 commented 2 years ago

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 commented 2 years ago

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

moonpang commented 2 years ago

Great news!!!

joaodematejr commented 2 years ago

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 commented 2 years ago

@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 commented 2 years ago

@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 commented 2 years ago

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

kraenhansen commented 2 years ago

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 https://github.com/realm/realm-js/discussions/3978

kraenhansen commented 2 years ago

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 commented 2 years ago

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

HSReact commented 2 years ago

Awesome news

kraenhansen commented 2 years ago

@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 commented 2 years ago

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 commented 2 years ago

@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.

rajpootathar commented 2 years ago

FPS drop significantly when app is offline the issue resolved in 10.10.1 but same issue happened in 10.20.0-alpha.2 Hermes. I think the changes still not merged in this Hermes branch

Related Issue: https://github.com/realm/realm-js/issues/3882

kraenhansen commented 2 years ago

We have a release pending from our Hermes branch, which will pull in the latest improvements from master. It'll land first thing in the new year.

YaoHuiJi commented 2 years ago

We have a release pending from our Hermes branch, which will pull in the latest improvements from master. It'll land first thing in the new year.

I almost cried when I heard this. Thanks to all the developers for your efforts. I had this problem when I was a little kid, and now I'm a happy old man.

kraenhansen commented 2 years ago

We're proud to announce that we've just released Realm JS v10.20.0-beta.0 - the latest in the series of releases with support for the Hermes engine. With this release all our tests are now passing and we're even more confident in our approach.

See issues with the hermes label for outstanding issue that we'll tackle next. We would love to know more about your perceived runtime performance of this releases compared to your use-case requirements and experience from past releases. If you decide to take it for a spin, please report any bugs using the hermes issue template and tell us about your general experience via this discussion on GitHub.

Thanks for your patience and all your encouragement throughout this transition towards Hermes as the default engine for React Native!

liamjones commented 2 years ago

@kraenhansen that's great to hear! Migration to Hermes is going to take us a bit of work due to other dependencies as well - does the beta still support the JSC as well so we can upgrade Realm first and then look at turning on Hermes afterwards?

fronck commented 2 years ago

@liamjones ~~Yes, the beta still supports JSC. You can use the HERMES_ENABLED environment variable to enable/disable JSI (Hermes). See here for example.~~

Edit: Whoops, the above is not correct, sorry. That only applies with building our test apps. However, since we are targeting JSI in general, and not just Hermes, you can switch backends in your own apps (see reactnative.dev). You can, however use the code linked above as inspiration to switch your own app's configuration.

elliottkember commented 2 years ago

Fantastic news. I had just hit a conflict with react-native-reanimated (edit: v2), which seems to require Hermes, so this was perfect timing.

I switched this version in from 10.6.1 and have had no problems so far, but will report back if I find anything. Thank you for all the hard work!

HSReact commented 2 years ago

Fantastic news. I had just hit a conflict with react-native-reanimated, which seems to require Hermes, so this was perfect timing.

I switched this version in from 10.6.1 and have had no problems so far, but will report back if I find anything. Thank you for all the hard work!

Thanks for sharing and do let us know how this goes, we are also using reanimated…though I believe it is reanimated 2 (which has far superior performance) which requires Hermes.

Either way we are happy to switch after hearing your success stories, do keep posting…

YaoHuiJi commented 2 years ago

I tried Realm JS v10.20.0-beta.0, but I met a terrible problem, sometimes I reopen my app, all data is missing, but when I check the default.realm file, all data is still in the file. It seems like sometimes my app don't read the Documents/default.realm file, but create a new db file in some place, because I can still create and update data when I found all data lost.

kraenhansen commented 2 years ago

I met a terrible problem

@YaoHuiJi please create an issue with the relevant information allowing us to reproduce and eventually solve any bug there might be.

YaoHuiJi commented 2 years ago

I met a terrible problem

@YaoHuiJi please create an issue with the relevant information allowing us to reproduce and eventually solve any bug there might be.

Ok, because I tried it the day before yesterday, and now it has rolled back. I will try it again sometime in a few days.

cristianoccazinsp commented 2 years ago

I tried Realm JS v10.20.0-beta.0, but I met a terrible problem, sometimes I reopen my app, all data is missing, but when I check the default.realm file, all data is still in the file. It seems like sometimes my app don't read the Documents/default.realm file, but create a new db file in some place, because I can still create and update data when I found all data lost.

Have you been able to reproduce it? Is it iOS or Android? Keep in mind iOS stores your data in a new absolute location with every new app update, so if for some reason there's an absolute path stored somewhere, it will be lost when you try to read it again.

YaoHuiJi commented 2 years ago

I tried Realm JS v10.20.0-beta.0, but I met a terrible problem, sometimes I reopen my app, all data is missing, but when I check the default.realm file, all data is still in the file. It seems like sometimes my app don't read the Documents/default.realm file, but create a new db file in some place, because I can still create and update data when I found all data lost.

Have you been able to reproduce it? Is it iOS or Android? Keep in mind iOS stores your data in a new absolute location with every new app update, so if for some reason there's an absolute path stored somewhere, it will be lost when you try to read it again.

Yes, I can reproduce it, but It only happened in the release version(iOS, real device, not attached to Xcode), debug version works well. what I found is weird...

  1. Use Xcode to run my app(release) on my phone, everything works well
  2. Click 'Stop' in XCode to detach the app process
  3. Reopen the app by tapping the app icon on iPhone
  4. All data "disappeared", but I can still create new data records in my App
  5. If I repeat step 1, all data shows up again. Then repeat steps 2, 3, all data disappeared again.

When I check data in Documents/default.realm, all data exists, including the old data and the new data, the app didn't create another realm data file(as I guessed before), just the same one. It seems my app can write data but read nothing, there is no crash, just no data can be read and showed up. It only happened on the release version without Xcode attached, so I don't know how to debug it further...

hi @kraenhansen , I don't know if it's enough to create an issue, because I don't know how to get more information.

packages related: "react-native": "0.66.0", "realm": "10.20.0-beta.0", "redux": "^4.1.1", "react-redux": "^7.2.4",

zoobibackups commented 2 years ago

Fantastic news. I had just hit a conflict with react-native-reanimated (edit: v2), which seems to require Hermes, so this was perfect timing.

I switched this version in from 10.6.1 and have had no problems so far, but will report back if I find anything. Thank you for all the hard work!

Which specific version of realm and reanimated you are using, cs i still facing the same issue with reanimated v2.2.2.

cristianoccazinsp commented 2 years ago

Trying to upgrade to 10.20.0-beta.1 but it won't even let me start the app on iOS (10.20.0-alpha.2 worked fine). Note that I'm not using Hermes on iOS (:hermes_enabled => false) but I am using it on Android.

I'm getting Properties can only be defined on Objects from realm/lib/extensions.js on line 364:

Object.defineProperties(
      realmConstructor.App.Sync.Subscriptions,
      getOwnPropertyDescriptors(subscriptionsMethods.static),
    );
kraenhansen commented 2 years ago

@cristianoccazinsp that's surely annoying, I've created a new issue for you, please follow that for progress.

cristianoccazinsp commented 2 years ago

@kraenhansen thanks, I'm assuming Both Hermes and JSI will be supported for iOS once Hermes support is fully released? Turns out Hermes is only useful for Android, but it's still lacking for iOS, so we don't have plans of upgrading to Hermes on iOS until a bunch of issues are resolved.

On the other hand, while using 10.20.0-alpha.2, we started getting errors from looping through a realm's filtered collection. I don't have a lot of details yet, but at some point all code running queries start failing with the following error: undefined is not an object (evaluating 'v.next'). I'm sorry I don't have a stack trace, the the user that sent this log basically got this error from everywhere a realm query was looped over, and ultimately ended up in a hard crash: EXC_BAD_ACCESS: Attempted to dereference garbage pointer 0x1c.

I will open an issue for this if I see more logs coming through, but wanted to mention it on the hermes thread.

HSReact commented 2 years ago

We’re waiting for it to be a little more stable before we start using it, but use it we will…so happy to see the progress

zoobibackups commented 2 years ago

@cristianoccazinsp that's surely annoying, I've created a new issue for you, please follow that for progress.

Please anyone tell me, which version of realm is working fine with reanimated v2 and herms enabled?????

kraenhansen commented 2 years ago

Please anyone tell me, which version of realm is working fine with reanimated v2 and herms enabled?

@zoobibackups 10.20.0-beta.1, installation instructions are in the topmost comment on this issue 👆

mTondenier commented 2 years ago

Hello everyone , i just installed the latest realm 10.20beta1 and with this version sometimes when i call the method objects() it returns me a strange [[Circular]] object. I don't think it's the expected behavior

tomduncalf commented 2 years ago

Hi @mTondenier, thanks for the report! Do you have an example project or sample code you can share to reproduce this issue please?

mTondenier commented 2 years ago

Hi @tomduncalf i can share some parts of the code :

The schema :

export const ExerciseSummarySchema = {
     name: EXERCISE_SUMMARY_SCHEMA,
     primaryKey: 'id',
     properties: {
          id: 'string',
          name: 'string',
          tags: 'string',
          functionnalGroups: 'string',
          difficulty: 'int',
          equipment: 'string',
          advice: 'string?',
          alias: 'string?',
          description: 'string?',
          videoAuthor: 'string?',
          authorInstagram: 'string?',
     },
};

functionnalGroups, equipement and tags are objects that are stringified , i don't know if it can help.

The query :

const exerciseList = realm.objects(EXERCISE_SUMMARY_SCHEMA);
 console.log(exerciseList);
 console.log(exerciseList[0]);

the first console.log return : [[Circular]] The second one surprisingly return the expected first item of the array

I'm new in js and react native but i don't think the error come from my code because it works if i downgrade realm (i see a real array in the first console log).

tomduncalf commented 2 years ago

Thanks @mTondenier.

I created a test app based on our React Native "task list" template, enabled Hermes and added a console.log, logging out the tasks, and I do not see the [[Circular]] issue when logging them – I see the expected [{"_id": [ObjectId], "description": "abc", "isComplete": false}, {"_id": [ObjectId], "description": "def", "isComplete": false}, {"_id": [ObjectId], "description": "ghi", "isComplete": false}, {"_id": [ObjectId], "description": "jkl", "isComplete": false}]

I wonder if there's other stuff in your app which could be causing this problem? While my test app has a different schema to yours, I think that they are roughly equivalent in that they are both simple schemas with fields with primitive types, no references, etc: https://github.com/tomduncalf/issue-3940/blob/main/app/models/Task.ts#L17-L25

If you can think of anything else that might be different, or if you'd like to share your code in private, please let me know.

If you'd like to try out my test app to verify that it works for you, you should just be able to clone https://github.com/tomduncalf/issue-3940, then npm install, npx pod-install and npm run ios.

I will speak to the team to see if they have any ideas what else could be causing the [[Circular]] and will let you know if we think of anything.

mTondenier commented 2 years ago

Thanks to you @tomduncalf for anwsering so fast.

I just forgot to mention that the problem is only on android.

I will try to solve the problem and if i find where it come from i will tell you.

tomduncalf commented 2 years ago

Ah I only tested on iOS so that could be part of it! I’ll test android later today and let you know how it goes

tomduncalf commented 2 years ago

@mTondenier Could you please create a new bug report issue with the details of your setup and the issue you are having, and I will assist you with it there? Just so we can keep this main Hermes thread on topic. Thanks!

kraenhansen commented 2 years ago

We're proud to announce that we've just released Realm JS v10.20.0-beta.3 - the latest in the series of releases with support for the Hermes engine. This is mostly a release rebased onto our recent Realm JS v10.14.0 release.

See issues with the hermes label for outstanding issue that we'll tackle next. As I mentioned last time, we would love to know more about your perceived runtime performance of this releases compared to your use-case requirements and experience from past releases. If you decide to take it for a spin, please report any bugs using the hermes issue template.

kraenhansen commented 2 years ago

Again, we're proud to announce that we've just released Realm JS v10.20.0-beta.4 and Realm JS v10.20.0-beta.5 - the latest in the series of releases with support for the Hermes engine. This is mostly a release rebased onto our recent Realm JS v10.15.0 and Realm JS v10.15.0 releases respectively. Although v10.20.0-beta.4 came with two minor bug-fixes as well.

Our current plan is to release the hermes branch as v11.0.0 together with a couple of other breaking changes around summer this year. Hopefully that will give us time to improve it further and the community the time to migrate to hermes (which is technically not a requirement, but will provide a much better debugging experience - as we're removing our support for the legacy chrome debugger).

jaltin commented 1 year ago

Hi,

Do you have any idea of when the Hermes version might be released? @kraenhansen you mentioned in your post from 13/4 that you planned to release it around the summer.

Asking as I am curious if you have the same plan still (it really affects our planning).

HSReact commented 1 year ago

Hi,

Do you have any idea of when the Hermes version might be released? @kraenhansen you mentioned in your post from 13/4 that you planned to release it around the summer.

Asking as I am curious if you have the same plan still (it really affects our planning).

Yes, same for us...we are waiting for this to happen

tomduncalf commented 1 year ago

Hey @jaltin @HSReact, sorry the delay on this. We are investigating some test failures on the Hermes branch, trying to determine if they are actual issues or not. We hope to be able to investigate this this week and if we can fix the issue or clarify what is happening, we will release soon after. I will keep you updated. Thanks for your patience!

tomduncalf commented 1 year ago

Sorry @jaltin @HSReact, I just realised I misunderstood your question, I thought you were asking when we would have a new version of the Hermes branch, but I think you're actually asking when it will become the latest (default) version of Realm on npm?

Our current plan (which is of course subject to change) is to wait until Meta make Hermes the default engine for React Native, and until they are recommending Flipper as the default way to debug React Native apps. Until this is the case, we feel that we can't push users to use our Hermes branch, especially as they'll need to use Flipper to debug.