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
Commit b167b80
Browse filesBrowse the repository at this point in the historyBrowse files
feat(canvas): rasterize 2D on a render thread by default (#165)
* feat(canvas): rasterize 2D on a render thread by default
2D calls now record into pictures on the JS thread; a shared render thread replays them onto
the real GPU context and presents. On a busy screen Skia's flush took ~6 ms of main-thread CPU
per frame and starved every view animating beside the canvas. Opt out with
getContext('2d', { threaded: false }) or Canvas.threaded2D = false.
- Android and iOS: threaded creation, surface updates, readbacks routed to the render thread.
- Android: 2D keeps its contents across swaps (offscreen surface copied to the window).
- Video into a threaded canvas: HardwareBuffer (Android) and CVMetalTexture (iOS), zero-copy.
- putImageData honours the dirty rect; reset() drops clips and saves.
- Busy-screen benchmark: canvas-busy page, busy-bench.sh, busy-trace.sh.
* feat(canvas): rasterize 2D on the render thread on Windows
Windows now takes the threaded 2D path by default too (Canvas.threaded2D = true): the real
context lives on the shared render thread's Direct3D 12 device, which presents; the JS thread
only records. The render thread never waits on the UI thread.
- Creation: canvas_native_context_create_d3d_threaded; the render thread keeps contexts boxed,
so register_d3d() gets their final address. Falls back to unthreaded D3D, then CPU.
- Swapchain panels: the swapchain is made on the render thread and bound on the UI thread.
- XAML SurfaceImageSources (every alpha canvas): XamlHandoff. The render thread begins, draws
and suspends through ISurfaceImageSourceNativeWithD2D and posts the UI thread's message-only
window, which ends the draw (EndDraw must run on the UI thread). SetDevice stays there too.
- Presents the display was not ready for are retried on the render thread.
- Device loss: lost flags from the render thread; restore releases what still shows lost
canvases from the UI thread, then shows the canvas again and resets the recorder's state.
__simulateD3DDeviceRemoval and __d3dAdapterInfo cover the render thread's device.
- drawImage(video): canvas-media's shared frame is opened on the rasterizing device, waited on
(ready fence) and given back after Skia submits (release fence), zero-copy.
- Tests: threaded_d3d (panel, resize, shared video frame) and threaded_d3d_lost.
* chore: 3.0.0-alpha.22
0 commit comments