Skip to content

TypedArray / Memory<T> marshalling fails in Electron due to disabled external buffers #384

@jasongin

Description

@jasongin

I'm creating this issue to continue the discussion from #15 (comment)

Attempting to work with JS TypedArrays from C# may result in an error from Electron's flavor of Node:

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

More information about the limitation is at electron/electron#35801. This 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.

Metadata

Metadata

Assignees

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions