-
Notifications
You must be signed in to change notification settings - Fork 640
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
[DRAFT] Add Node-API to Hermes #1377
base: main
Are you sure you want to change the base?
Conversation
Thanks for doing this @vmoroz!!! |
@tmikov has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
Thanks so much, @vmoroz! Really excited to play with this. |
Huge effort @vmoroz thank you ❤️ |
Hey @vmoroz, thanks for putting this together! Two high level requests:
|
@neildhar , thank you for the feedback and suggestions! |
Is this the main place to follow work on this topic? Is there still some appetite to support NAPI in React Native? |
I'm still very interested in it and have even submitted conference talk proposals on the topic so would love it to become a reality! I have some native Node addons that I've written for Electron, and it's a shame that I can use them in React Native Windows (as it supports Node-API) yet can't use them in any other flavour of React Native currently. Let me know if there's any way I could help! |
One of the Discord RN channels or a discussion topic in one of the Meta's or Microsoft's related repo could be a better place to discuss all the details, but we can start it here. The goal of supporting Node-API for Hermes, V8, and RN was to provide the industry standard ABI-safe API. It should enable versioning support for modules, support for multiple programming languages, and reuse of native code written for Node.js. I wonder what is your scenario in terms of tergeting platforms (Windows, Mac, Android, etc.) and if you own the code that uses Node-API? It may be not possible to reuse binary Node.js modules, but reusing the majority of the code and recompiling it for the RN is a more achievable scenario. |
We are implementing WebGPU for React Native (
https://x.com/appjsconf/status/1806332497783058900) and right now we are
virtually migrating a webgpu node module to JSI manually. So of course the
thought or being able to use that node module directly is appealing to us.
…On Thu 11 Jul 2024 at 18:09, Vladimir Morozov ***@***.***> wrote:
Is this the main place to follow work on this topic? Is there still some
appetite to support NAPI in React Native? We are eyeing at some node
modules that we would love to use out of the box in React Native.
One of the Discord RN channels or a discussion topic in one of the Meta's
or Microsoft's related repo could be a better place to discuss all the
details, but we can start it here.
The goal of supporting Node-API for Hermes, V8, and RN was to provide the
industry standard ABI-safe API. It should enable versioning support for
modules, support for multiple programming languages, and reuse of native
code written for Node.js.
I wonder what is your scenario in terms of tergeting platforms (Windows,
Mac, Android, etc.) and if you own the code that uses Node-API? It may be
not possible to reuse binary Node.js modules, but reusing the majority of
the code and recompiling it for the RN is a more achievable scenario.
—
Reply to this email directly, view it on GitHub
<#1377 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AACKXVUXFX6NCBLYT5AIRILZL2U2FAVCNFSM6AAAAABGMIZABGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDEMRTGMZTKMBYGM>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
|
This is awesome! In the video clip you say that you target first of all the mobile platforms: iOS and Android. The current version of the Node-API for Hermes is in the hermes-windows repo: https://github.com/microsoft/hermes-windows/ . There we are starting to factor out the Node-API code into its own folder. Yesterday we had a long informative face-to-face meeting with Hermes team. |
@wcandillon when you say that you are implementing WebGPU, do you literally mean the WebGPU spec, 1 to 1, with shader language, etc? |
We use Google Dawn for the native WebGPU implementation (Dawn is also a supported Skia backend), we code generate most of the bindings from its TS definition (which is itself generated from the W3C spec, we also match TS methods to C++ methods, Dawn provides a json model for that), and for the manual part of the work we just look at the node module and migrate it. This is why being able to use that node binding directly (which is already conformant to the official WebGPU testsuite) feels appealing. |
May I emphatically object to using Discord channels, as they inherently make discussions exclusionary, unfriendly to different timezones, transient, difficult to search, and impossible to reference. |
For anyone who wants to try out this PR with react-native use version |
I was able to link and run a react-native app with this hermes NodeAPI PR. However after calling
raw is a hermes/include/hermes/ADT/CompactArray.h Lines 85 to 87 in 175d85f
hermes/include/hermes/ADT/CompactArray.h Lines 53 to 57 in 175d85f
hermes/include/hermes/ADT/CompactArray.h Lines 131 to 133 in 175d85f
hermes/lib/VM/IdentifierTable.cpp Line 331 in 175d85f
so what I'm currently trying to figure out is: why is raw a null pointer and what is the source of this issue Does anybody else tried to use the NAPI in an app and if yes were you successful or did you encounter errors? |
After building hermes in debug mode I get a different error, however without any stacktrace:
and after retrying a few times a different error:
Does anyone know how I can get the stacktrace of these errors to find the cause?? |
Summary
This is an initial implementation of Node-API for Hermes.
The code is taken from the hermes-windows repo.
Node-API is an ABI-safe that is originally implemented for Node.js addons, and then adopted by all major JS runtimes.
This is a draft PR. Before removing the draft status I would like to ask a few questons:
Test Plan
Unit tests for Node-API are to be added.