Repository navigation
perf(canvas): native hosts and GPU snapshots for drawable views - #255
Merged
Merged
Conversation
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the
|
triniwiz
force-pushed
the
feat/html-in-canvas-gpu
branch
3 times, most recently
from
November 18, 2026 14:05
1b9e6d5 to
51887cb
Compare
This was referenced Nov 18, 2026
triniwiz
force-pushed
the
feat/html-in-canvas-gpu
branch
from
November 18, 2026 15:05
51887cb to
9d438bc
Compare
The drawable children of a content="drawable" canvas are now held by a native host view, so the per-frame work, touch routing and capture no longer cross into JS: - Android: NSCDrawableHost (Kotlin) lays the children out with NativeScript's own CommonLayoutParams helpers, tracks invalidations from onDescendantInvalidated, and routes touches from a geometry table JS sets only when geometry changes. On API 29+ it records each changed view into a RenderNode and renders it with HardwareRenderer into an ImageReader, waiting on the image's fence on API 33+. 2D draws the HardwareBuffer through the existing EGLImage path video uses, and WebGPU imports it as a native texture. - iOS: NSCDrawableHost (Swift) does the hit testing and keeps the layer transforms in sync with layout. It renders into an IOSurface that 2D and WebGPU read as a Metal texture. A layer-tree signature taken every frame catches most changes without rendering; a quarter-size probe, checked less often while nothing changes, catches the rest. JS walks the NativeScript tree for drawable views and makes one call to the host per frame. drawElementImage no longer uploads the snapshot's bytes on every draw. WebGL still reads the snapshot back on the CPU.
triniwiz
force-pushed
the
feat/html-in-canvas-gpu
branch
from
November 18, 2026 15:31
9d438bc to
57b9484
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stacked on #254.
The drawable children of a
content="drawable"canvas are now held by a native host view, so per-frame work, touch routing and capture stay native, and snapshots are drawn from the GPU.Change
Android:
NSCDrawableHost(Kotlin, in the AAR)CommonLayoutParamsmeasure/layout (looked up at runtime: widgets ships with the app) and never draws them.onDescendantInvalidated; below API 26, idle views are polled.RenderNodeand renders it withHardwareRendererinto anImageReader, waiting on the image's fence on API 33+. Below 29 it draws into aBitmap.HardwareBufferthrough the EGLImage path video already uses; WebGPU imports it as a native texture.iOS:
NSCDrawableHost(Swift, in CanvasNative)IOSurfacethat 2D (canvas_native_ios_context_draw_external_metal_texture) and WebGPU read as a Metal texture.JS walks the NativeScript tree for drawable views and makes one call to the host per frame.
drawElementImageno longer uploads the snapshot's bytes on every draw, and the geometry it sets on each draw only reaches the host when it changed. WebGL still reads the snapshot back on the CPU.Verified
htmlincanvas24/24 (including a new test that the snapshot draws through Metal),2d182/182,canvassource18/18,offscreen64/64,lifecycle17/17,webgl96/96.htmlincanvas24/24 on three runs (including a new test that the snapshot is aHardwareBufferdrawn through EGL),2d182/182,webgl96/96.lifecyclefails the same present-timing tests as a master build with the same AAR.canvas-htmldemo on the emulator: taps and typing reach the rotated form through the native touch routing, at 60 fps.