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

Memory<T> to TypedArray<T> on Electron 19.1.9 Worked fine. But did not worked on higher Electron #383

Open
Hiwen opened this issue Sep 29, 2024 · 4 comments

Comments

@Hiwen
Copy link

Hiwen commented Sep 29, 2024

I Test Memory<T> to TypedArray<T> on Electron 19.1.9,That Worked fine and has amazing Performance.
But when I Test on higher Electron, such as 32.1.2, it was not worked. And reported an error:

External buffers are not allowed: Error in CreateExternalArrayBuffer at D:\a\1\s\src\NodeApi\JSValue.cs:264

I did some research,the use of External buffers has actually been officially banned.
electron/electron#35801

Does anyone know how to turn on External buffers support in the new version of Electron? Like turn it on by some command parameter or something。

Or has any Other way to transfer big data(such as 100MB) from dotnet to nodejs?

Originally posted by @Hiwen in #15 (comment)

@jasongin
Copy link
Member

jasongin commented Sep 30, 2024

electron/electron#35801 appears to be quite a controversial issue, but the Electron team seems to believe the limitation is necessary for security.

As a workaround, node-api-dotnet probably will need to handle the new napi_no_external_buffers_allowed status code and fall back to copying the memory instead of using external buffers. That's very unfortunate since it can have a major performance impact in some scenarios, and doesn't have the same semantics as shared memory.

@vmoroz
Copy link
Member

vmoroz commented Sep 30, 2024

I was aware about the change, but forgot to bring it to our discussion since we did not discuss the Electron integration.
Recently one developer shared with Node-API team a technique where he creates a big ArrayBuffer, and then uses slices of that buffer for several TypedArrays. I wonder if we can use the same technique to improve speed.

@Hiwen
Copy link
Author

Hiwen commented Oct 1, 2024

Thanks for reply @jasongin. I think it's better to close this issue, and discuss this topic on issue384.

@jasongin
Copy link
Member

jasongin commented Oct 3, 2024

I think it's better to close this issue, and discuss this topic on #384

I closed #384 as a duplicate of this one. I didn't notice when opened that issue that you had already created this one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants