Skip to content

feat(engine): drawElementImage capture service#1917

Open
vanceingalls wants to merge 1 commit into
de2-01-config-clifrom
de2-02-drawelementservice
Open

feat(engine): drawElementImage capture service#1917
vanceingalls wants to merge 1 commit into
de2-01-config-clifrom
de2-02-drawelementservice

Conversation

@vanceingalls

@vanceingalls vanceingalls commented Jul 4, 2026

Copy link
Copy Markdown
Collaborator

drawElement capture service (stack 2/6)

The core drawElementImage-based capture service — reads a DOM subtree's paint records directly into a <canvas layoutsubtree> on the macOS GPU, the mechanism that makes fast capture ~2× cheaper per frame than the CDP screenshot round-trip.

What this adds — packages/engine/src/services/drawElementService.ts (+834)

  • captureDrawElementFrame — force a paint-record invalidation, await the canvas paint event, then canvas.drawElementImage(root). Paint-wait ~1.3ms/frame; encode dominates (offloaded in 4/6).
  • Accelerated-canvas handling — WebGL/WebGL2/WebGPU canvases never repaint (stale paint record), so they're hidden before the paint and composited live via drawImage underneath the drawElementImage output; 2D canvases refresh natively via a per-frame sentinel paint on paint-synced hosts.
  • produceDrawElementFrame / worker-encode entry — hands the captured bitmap to the OffscreenCanvas encode worker (wired in 4/6).
  • Background/ancestor fill so drawElementImage(root) matches what captureScreenshot composites.

Notes

  • macOS-GPU-only by design (BeginFrame path on Linux is separate); gated upstream.
  • Tests: drawElementService.test.ts + drawElementService.integration.test.ts.

Stack: #1916#1917 (here)#1918#1919#1920#1921. Rebased onto current main; supersedes #1295 + #1444. Intermediate PRs don't compile independently — feature is green at the tip (#1921), tsc-clean + 231 tests pass.

🤖 Generated with Claude Code

vanceingalls commented Jul 4, 2026

Copy link
Copy Markdown
Collaborator Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant