mirror of
https://github.com/remorses/gpuix.git
synced 2026-10-28 18:59:22 +08:00
Implement a custom GPUI platform (NodePlatform) that runs inside Node.js
without blocking the event loop. Instead of the old renderer.run() which
called [NSApp run] and blocked forever, the new API is:
renderer.init({ title, width, height }) // non-blocking
renderer.render(jsonTree) // update element tree
renderer.tick() // pump events + render frame
The JS side drives rendering via a setImmediate loop, keeping Node.js alive
for React state updates and event handling.
## NodePlatform architecture
Node.js event loop tick
├── JS: React reconciler produces tree → renderer.render(json)
└── JS: renderer.tick()
└── Rust: pump winit events + drain GPUI tasks + render frame
Key components:
- NodePlatform: implements gpui::Platform, run() returns immediately
- NodeDispatcher: main-thread queue + delayed queue, drained during tick()
- NodeWindow: winit window + wgpu surface, maps winit events to GPUI input
- NodeDisplay: minimal display info for GPUI layout
## React reconciler fix (critical bug)
react-reconciler 0.31+ (React 19) removed the updatePayload parameter from
commitUpdate. The old 6-param signature shifted all args by one, causing
newProps to receive the internal fiber handle instead of actual props. This
silently wiped all instance styles on every state update.
// OLD (broken): commitUpdate(instance, updatePayload, type, oldProps, newProps, handle)
// NEW (fixed): commitUpdate(instance, type, oldProps, newProps, handle)
Also removed dead prepareUpdate method — no longer called by react-reconciler
0.31+. The reconciler now uses oldProps !== newProps reference equality.
## GPUI dependency update
Updated from rev 83ca310 to 14f37ed (post gpui_web merge) which includes:
- gpui_wgpu crate with WgpuRenderer + CosmicTextSystem
- Platform trait changes for non-blocking run()
- Application::with_platform() constructor