realm / realm-js

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

Impossible to debug on Android with JSC under new version of Realm? #4364

Closed liamjones closed 1 year ago

liamjones commented 2 years ago

Description

When using an Android emulator/device, if you attempt to connect to the Chrome Debugger you now get the following error message:

Error: This version of Realm JS doesn't support the legacy Chrome Debugger. Please use Flipper instead.

This makes sense if your RN app is using hermes but it's misleading if it's still on JSC as you can't use the Hermes debugger in Flipper (and I don't believe there's a JSC debugger in Flipper?)

Does this mean debugging a Realm app on Android is going to become impossible when the Hermes branch releases? For iOS, the Safari debugger is a substitute that can still be used (though isn't ideal as you lose things like the Redux Debugger which is present in the Chrome Debugger based React Native Debugger).

This is probably going to be a blocker for us upgrading Realm if the situation is still the same once the Hermes release becomes the main one. We can't risk losing the ability to debug our entire app on Android because of this (in advance of us being able to shift the app to Hermes).

Stacktrace & log output

No response

Can you reproduce a bug?

Yes, always

Reproduction Steps

No response

Version

10.20.0-beta.1

What SDK flavour are you using?

Local Database only

Are you using encryption?

No, not using encryption

Platform OS and version(s)

N/A

kraenhansen commented 2 years ago

@liamjones I suggest we move our conversation from https://github.com/realm/realm-js/issues/4363 into this issue as it seems more on topic for that.

I thought that, eventually, the hermes branch would merge to the mainline and be the only available release for Realm in future

You're right. I'll share an update on this issue as we get more clarity on when this will happen.

Our ultimate goal is to move our apps to Hermes on both platforms but, in our case, it's not as simple as just switching the engine flag.

This is good news - as we do share the React Native teams vision for a future with Hermes being default.


As per your questions on this issue.

I don't believe there's a JSC debugger in Flipper?

I believe you're right and I don't know if the React Native team has any plans on adding this. I doubt they want to spend more energy in that direction.

Does this mean debugging a Realm app on Android is going to become impossible when the Hermes branch releases?

Right: Once the Hermes branch becomes our "latest" release, you'd have to pin your Realm JS version to be able to debug on Android when running your app with Hermes disabled.

For context

Our legacy Chrome debugger support was tightly coupled with the JavaScriptCore APIs and wasn't using the JS engine abstraction that all our other code was using. Hence, this proved to be difficult to migrate in our efforts to target JSI. Historically our support for the legacy Chrome debugger has been less than ideal - it's been notoriously slow and its maintenance has been actively slowing us down as we've been adding new features over the years. Over all we believe the future of React Native with Hermes and a proper debugging experience through Flipper is very bright and we can't wait to finally say goodbye to our (and hopefully the entire community's) support for the legacy Chrome debugger.


I suggest keeping this issue open to document the lack of support of the legacy Chrome debugger and the caveat:

Releases off our hermes branch (our 10.20.0 pre releases) does not support the legacy Chrome debugging experience and as such there is no known way of debugging JavaScript code when running on Android with Hermes disabled (and JSC enabled). If having this support is important, we suggest you pin your version of Realm JS and postpone upgrading until a point in time when you're ready to make the shift to Hermes and the new / improved debugging experience through Flipper.

liamjones commented 2 years ago

Thanks for clarifying @kraenhansen. Yep, I totally understand the situation the Realm devs are coming from and why JSC support is being phased out.

I thought that, eventually, the hermes branch would merge to the mainline and be the only available release for Realm in future

You're right. I'll share an update on this issue as we get more clarity on when this will happen.

Thanks, that'll be helpful for work prioritisation here.

Gnadhi commented 2 years ago

Is there any updates on this ?

kneth commented 2 years ago

@Gnadhi We strongly recommend to try Hermes, Flipper and Realm JS v11.0.0.rc-1 or later. We do not plan to work on the Chrome debugger integration.

jbarriosenvase commented 2 years ago

@Gnadhi We strongly recommend to try Hermes, Flipper and Realm JS v11.0.0.rc-1 or later. We do not plan to work on the Chrome debugger integration.

Does this means that as long as we use realm, we can forget about proper debugging with any kind of IDE/Editor debugger since they all still work with Chrome JS debugging? And we're gonna have to stick with flipper without being able to make any kind of debugging with Breakpoints?

kneth commented 1 year ago

We have released v11.0.0 with support of Hermes. You might need to add Flipper to your Android app manually: https://fbflipper.com/docs/getting-started/react-native-android/

liamjones commented 1 year ago

@kraenhansen @kneth FYI there's an RFC raised where the RN team is planning on migrating back to Chrome dev tools being the default for debugging in future again to improve the dev debugging experience. I'm mentioning it in case your team wants to input to the RFC re anything Realm specific: https://github.com/react-native-community/discussions-and-proposals/pull/641

kraenhansen commented 1 year ago

@liamjones thanks for sharing this! Reading the document, I see that the proposal will still use the Chrome DevTools Protocol (CDP) and therefore JS code will still be executing on device. I.e. I would say it's incorrect to read this as the "RN team is planning on migrating back to Chrome dev tools" as their proposal is not to revert back to executing JS code in the browser.

From my understanding of the proposal, any app using Realm should be compatible with the proposed debugging experience, although we might see less adoption of our realm-flipper-plugin in the future.

liamjones commented 1 year ago

Ah sorry, didn't mean to mislead. I hadn't had time to read the RFC in detail yet. Good to hear it shouldn't affect Realm. :)

kraenhansen commented 1 year ago

@liamjones no worries. Although we try to engage with the community and stay on top of these things ourselves, it was really good that you brought it to our attention 👍

kalyncoose commented 10 months ago

Working Flipper Solution (as of Dec 7 2023)

For those who are distraught about not being able to use Redux DevTools because of Realm: