You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
measureControl / drawControlIntoSurface are main-thread only: from a Worker they draw, then crash at exit #54
measureControl and drawControlIntoSurface only work on the main thread. Called from a Worker they measure and draw correct pixels, and then the process crashes when it exits. In threaded mode react-x11's renderer lives on a worker, so the bezel path has to reach the UI thread.
Repro (bridge-worker.mjs, in #49; @windowkit/appkit 0.9.0, Node 26.0.0, macOS 15.2)
$ BEZEL_KIND=push node bridge-worker.mjs bezel
[worker] loaded the bridge in a worker (182 verbs)
[worker] measureControl: {"width":30,"height":32}
[worker] drawControlIntoSurface(push): 4056 of 6912 pixels inked
exit=139
$ BEZEL_KIND=checkbox node bridge-worker.mjs bezel
[worker] measureControl: {"width":18,"height":18}
[worker] drawControlIntoSurface(checkbox): 1188 of 3024 pixels inked
exit=139
The draw step, which uses only CoreGraphics and CoreText, exits 0 from the same worker. The bezel path runs BEnsureApp() from the calling thread and allocates BezelDrawView's CALBackendView, an NSView, on the calling thread. For slider and switch it also creates an offscreen NSControl there. That is the likely cause; AppKit does not support views off the main thread.
Proposed (mechanism only)
Threaded mode: both verbs become UI-thread work with an async answer:
The UI thread draws straight into the caller's surface, which is a CG bitmap, so nothing is copied. Until the callback fires, the renderer must not touch that surface.
Pump mode: unchanged, except that a call off the main thread throws a JS error instead of crashing later.
react-x11's BezelStore already caches by (kind, control size, scale, state), so each bezel is rendered once. The first frame that needs one paints the themed control and swaps when the answer lands. Prefetching the common kinds at startup hides even that.
Consumer
react-x11 src/cocoa/bezels.js (BezelStore); docs/macos.md §"JS on a worker: a UI thread of the bridge's own", sidorares/react-x11#539.
Activity