Repository navigation
rfc: c apis - #33
rfc: c apis#33YUCLing wants to merge 1 commit into
Conversation
02ca86a to
b0ab466
Compare
b0ab466 to
793b511
Compare
itsananderson
left a comment
There was a problem hiding this comment.
Thank you for submitting this proposal!
I've left a few comments about specific details of the RFC, and I have a few other high-level comments/suggestions:
- It sounds like you have some specific Wayland use-cases that motivate this proposal. Would it be possible for you to add a more expanded code example of the kind of feature that you might build with this API. It will be helpful to have some concrete API proposals (and motivating use-cases) that we can review and approve as part of this RFC.
- Something useful that the approach in #3 provided was a way to statically check API availability at compile-time, which would make it easier to verify that a native module is compatible with a specific Electron version, using compile-time checks. If I'm understanding your RFC correctly, it would mostly be limited to runtime checks for checking if an API is available. Would it be possible to incorporate the compile-time feature availability check into your RFC?
- We discussed this a bit in our last API WG meeting, and we think that ABI compatibility should be a non-goal for these C APIs. Because Electron is built on top of Chromium, we are subject Chromium's internal changes every time we upgrade our base Chromium version. This will make it very difficult for us to guarantee API backward compatibility, much less ABI compatibility. Because we can't provide these guarantees, native modules which use this C API will need to be recompiled for the specific Electron version they will be shipped with.
| if (electron_get_api(ELECTRON_API_VERSION, &api) != ELECTRON_RESULT_OK) return -1; | ||
|
|
||
| /* A feature's header declares its table type; discovery itself is by name. */ | ||
| electron_wayland_connection_api_t wl = {0}; |
There was a problem hiding this comment.
If I want to build against a new Electron version, but also support older Electron versions, it would be a compile-time error to reference types like electron_wayland_connection_api_t if they're not yet available in older Electron versions.
|
|
||
| electron_api_t api = {0}; | ||
| api.struct_size = sizeof(api); | ||
| if (electron_get_api(ELECTRON_API_VERSION, &api) != ELECTRON_RESULT_OK) return -1; |
There was a problem hiding this comment.
Does ELECTRON_API_VERSION come from electron/c_api.h or is it a constant that a native module would define for itself, to specify the ABI version that it wants to request.
| 7. **Stability.** The core mechanism is stable from the start and append-only. Feature sets | ||
| are experimental until individually promoted, with their status recorded in | ||
| `docs/experimental.md` beside the existing experimental tag. | ||
| 8. **Enforcement.** A CI conformance test compiles a fixture addon against the previously |
There was a problem hiding this comment.
While I think detecting accidental breakage of the ABI is sensible, I don't think we can necessarily guarantee that old API versions will never be broken, because we sometimes need to deprecate/remove APIs due to changing OS or Chromium support. However, maybe we could use a mechanism like this to detect and remove ABI versions that are no longer supportable by new Electron releases.
Proposes a small, versioned C ABI for native addons: one exported symbol,
electron_get_api(), filling a size-negotiated core table. Feature sets are reached through a genericget_feature()lookup, so adding a feature never adds an exported symbol or changes the core layout.Scope is deliberately narrow — the mechanism, its stability policy, and a CI conformance test. No feature set is proposed here; the Wayland connection feature set that motivates this work will follow separately, and I’m working on it in parallel so it can serve as the first test case for this mechanism.
Note: no additional cross-platform feature set is planned right now; Wayland is the only immediate priority.
Supersedes #3.
Looking forward to feedback from the Electron team! 🚀