Commit 885ffe1
committed
feat(webgl): run iOS WebGL contexts on the WebGL thread
iOS WebGL drew through a GLKView, whose display (the per-frame present)
only runs on the main thread, which is the JS thread: a heavy scene held
the UI to the GPU's pace.
The GLKView is replaced by a view backed by a CAEAGLLayer. The context
owns its drawing buffer: a framebuffer whose color buffer is stored in the
layer (renderbufferStorage:fromDrawable:) and presented with
presentRenderbuffer:, both of which run on any thread, plus a packed
depth/stencil buffer from the context attributes. An offscreen context
gets plain renderbuffers instead of an unshown GLKView.
That lets an iOS context be threaded as on Android (the default;
getContext(..., { threaded: false }) opts out): it is created, drawn,
presented and dropped on the shared WebGL thread, and requestAnimationFrame
is held back while a canvas is behind.
- Resizing reallocates the drawing buffer, queued behind earlier calls;
a GL-backed 2D context reallocates its own as it resizes.
- Snapshots read the drawing buffer on the context's thread.
- The texImage helpers and video frame uploads (NSCRender) run on the
context's thread; NSCRender makes its GL objects on first use there.
- Depth and stencil are discarded after each present unless
preserveDrawingBuffer is set, as GLKView did.1 parent 6dcb6dd commit 885ffe1
12 files changed
Lines changed: 678 additions & 539 deletions
File tree
- crates
- canvas-core/src/gpu/gl
- canvas-c/src/c2d
- canvas-ios/src
- canvas-webgl/src
- packages
- canvas-media
- typings
- video
- canvas
- Canvas
- src-native/canvas-ios
- CanvasNative
- Source
- include
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
124 | 124 | | |
125 | 125 | | |
126 | 126 | | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
127 | 134 | | |
128 | 135 | | |
129 | 136 | | |
| |||
0 commit comments