Skip to content
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

Update Node-API to latest from node.js #70

Merged
merged 40 commits into from
Feb 22, 2024
Merged

Conversation

carolhmj
Copy link
Contributor

@carolhmj carolhmj commented Jan 5, 2024

No description provided.

@CedricGuillemet
Copy link
Contributor

CedricGuillemet commented Jan 30, 2024

napi_create_external_arraybuffer checks the type of the array just created but it appears to not be a typed array. So napi_get_typedarray_info returns false and the array creation asserts.
image

If I replace this line : return napi_get_typedarray_info( env, *result, nullptr, nullptr, nullptr, result, nullptr); with return napi_ok; then everything works fine (validation tests and unittests pass). This replacement correspond to the code before this update.

@CedricGuillemet
Copy link
Contributor

Regarding performance with BabylonJS/BabylonNative#1350 I get 2.7 seconds before this update 2.9-3 seconds with.

@CedricGuillemet
Copy link
Contributor

It's actually not a good idea to update node-api without updating v8/jsc. So, it's better to mix #59 with this PR and changes in js_native_api_v8.cc are then not needed: v8 api is in sync with node-api.

But there are issues:

  • sandbox. When disabled, I get this error on win32
# Fatal error in , line 0
# Embedder-vs-V8 build configuration mismatch. On embedder side sandbox is DISABLED while on V8 side it's ENABLED.

But, there is this check in node-api:
/~https://github.com/nodejs/node/blob/4ab63db9e207b5dbb6c046946716a49b6e2c3e53/src/node_api.cc#L1053

  • this brings the 2nd issue regarding external buffer. It's currently disabled in this PR (see other comment) and it's a bit painful to put back in the code. I did try but I end up copying many files from node-api and it gets messy quite fast. Is there a way to just add what's needed here?

@CedricGuillemet
Copy link
Contributor

@bghgary
I did another try at fixing the external buffer, with a copy this time. When testing ValidationTests, it crashes after 3 or 4 tests with this callstack :
image

Same crash happens with or without the self-deleting weak reference.

@CedricGuillemet
Copy link
Contributor

The crash I saw was because of async shaders. When running in release, everything is fine with Validation tests. Integration PR is here : BabylonJS/BabylonNative#1353

Core/Node-API/CMakeLists.txt Show resolved Hide resolved
Core/Node-API/Include/Shared/napi/napi.h Outdated Show resolved Hide resolved
@bghgary bghgary enabled auto-merge (squash) February 21, 2024 21:00
@bghgary bghgary changed the title Updating Node-API Update Node-API to latest from node.js Feb 21, 2024
@bghgary bghgary disabled auto-merge February 21, 2024 21:00
@bghgary bghgary merged commit 02055e8 into BabylonJS:main Feb 22, 2024
16 checks passed
This was referenced Feb 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants