Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.Sign up
Debugging JSC directly #7
The ability to attach to JSC directly to debug React Native JavasScript code.
Currently, we use Chrome to run the JS code when React Native is in the debug mode. When we start the debug mode, a new web socket connection is established via the packager to an instance of Chrome. We then use Chrome developer tools to debug the JS code. Similar mechanisms are used in the VSCode debugger for React Native, and the Idea react native plugin.
When Native Modules today use a synchronous API, Chrome debugging fails. Sync API for native modules are not common, and at many places, such module provide alternative async calls.
There are currently two possible approach to support debugging in the future for OSS React Native projects.
Side Note - We would also need to start supporting debugging Chakra in case of RN-Windows.
With 2) having the bundle running in NodeJS is super cool
For reference this is where I do that:
Debugging/bundle in NodeJS seems like the simpler approach / more user-friendly I think - would also open up a few dev tooling options like JS code coverage.
In terms of 3) I remembered the software mansion guys had an Android repo that had JSC debugging for RN - https://github.com/SoftwareMansion/react-native-android-jsc-debugging - if it helps as a reference for anything.
The fact that the Android JSC runtime is pretty old should not be a show-stopper - it should be upgraded either way in order to properly add 64-it support (and other features such as Proxy objects etc, which are used by Libraries such as Mobx 5.x).
Edit. before you decide, read this:
To be honest, I switched to Haul a while ago. Debugging in Safari was a breath of fresh air for me, since the JS code runs in the device and not in my browser - and I can debug it there. Using Node is a step back in my opinion. It will provide a hack, but this kind of short term decisions are the ones that got us talking about switching debugging methodology in the first place. I believe we should solve this once and for all and provide a way to debug JSCore in the device.
I believe that the only major barrier to using Safari Debugging is the lack of sourcemaps. We might be able to fix that by including inline sourcemaps for dev builds?
This project also has a good example of how to bridge from the JSC debug protocol to a Chrome compatible one (and hence VSCode and others):