[JS] Move from embind to manual bindings #1507

Open
opened 2023-12-10 15:29:41 -08:00 by NickGerleman · 2 comments
NickGerleman commented 2023-12-10 15:29:41 -08:00 (Migrated from github.com)

embind is convenient but not ideal

  1. Its structure makes it hard to implement garbage collection vs finalization registry because we can’t differentiate JS refererence Vs native pointer
  2. It bloats the binary/bundle and adds required runtime support. Goes in the opposite direction of being able to generate portable wasm targeting only WASI.
  3. Our patching of its interface is hard to reason about or add to.

We should instead add the code for the object representation and have it call Yoga C APIs directly, like the JNI bindings.

embind is convenient but not ideal 1. Its structure makes it hard to implement garbage collection vs finalization registry because we can’t differentiate JS refererence Vs native pointer 2. It bloats the binary/bundle and adds required runtime support. Goes in the opposite direction of being able to generate portable wasm targeting only WASI. 3. Our patching of its interface is hard to reason about or add to. We should instead add the code for the object representation and have it call Yoga C APIs directly, like the JNI bindings.
NickGerleman commented 2023-12-10 15:33:14 -08:00 (Migrated from github.com)

This isn’t something I’m going to prioritize, but might be worth picking up as a next step in evolving the bindings, especially if standalone wasm es modules become well supported.

This isn’t something I’m going to prioritize, but might be worth picking up as a next step in evolving the bindings, especially if standalone wasm es modules become well supported.
6XGate commented 2025-04-05 15:19:44 -07:00 (Migrated from github.com)

Is the use of embind related to why Node#getChild seems to return a new instance of a JavaScript/V8 object wrapping the C++ Node instance? If not, I may need to file another bug due to noticing that any symbols I attached to Yoga Nodes don't come back with them from getChild.

Is the use of embind related to why `Node#getChild` seems to return a new instance of a JavaScript/V8 object wrapping the C++ Node instance? If not, I may need to file another bug due to noticing that any symbols I attached to Yoga Nodes don't come back with them from getChild.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: DaddyFrosty/yoga#1507
No description provided.