What changed
- Move six macOS-only native wrapper bindings out of the common
dlopensymbol table. - Load them through a separate optional handle only on macOS.
- Guard alpha blending, WGPU input handlers, and native text calls when those optional exports are unavailable.
- Add a source-contract regression test so platform-only exports cannot accidentally return to the common binding table.
Why
Bun resolves the full symbol table passed to dlopen eagerly. The Windows native wrapper does not export these six macOS capabilities, so one missing symbol prevented the entire native wrapper from loading and made otherwise valid core APIs unavailable.
This keeps the common binding table aligned with cross-platform exports while preserving the existing macOS functionality through feature detection.
Closes #520.
Validation
bun test package/src/shared/native-platform-ffi.test.ts: 2 passed, 0 failed, 20 assertions.- Targeted FFI and related Windows/DPI tests: 16 passed, 0 failed, 92 assertions.
- End-to-end with
electrobun@1.18.4-beta.25on Windows at 150% scaling: window starts successfully, Per-Monitor V2 is active, window DPI is 144, and WebView device scale factor is 1.5. git diff --check: passed.
Broader baseline checks were also run. The shared suite had 161 passing tests and 4 failures unrelated to this patch (including an unavailable cl.exe environment check and existing source-contract drift). hutch typecheck retained 9 existing main-branch errors involving missing generated/template modules and test typings; this change introduced no platform-FFI type errors.
Activity
4Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.
Suppressed comments (1)
package/src/shared/native-platform-ffi.test.ts:56
- This assertion is overly brittle because it depends on an exact newline + tab indentation sequence in
native.ts(\n\t\t\t). Small formatting changes (or CRLF line endings) will break the test even though behavior is unchanged. Prefer a whitespace-tolerant regex (or split assertions) to make the regression test stable.
expect(nativeSource).toContain(
'!hasFFI ||\n\t\t\ttypeof rasterizeText !== "function"',
);
Pull request overview
This PR fixes cross-platform Bun main-process startup by isolating macOS-only native wrapper FFI symbols into a separate optional
dlopenhandle on macOS, preventing missing platform exports (e.g., on Windows) from breaking the entire native wrapper load.Changes:
macOSNativehandle that is only loaded ondarwin.Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
dlopenhandle and updates call sites to feature-detect optional symbols.💡 Add a
code-reviewagent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.