[v10] Multi-canvas: under the WebGL2 fallback, a secondary canvas draws into the primary's canvas

Author: DennisSmolekCreated Sep 26, 2026Updated Sep 26, 2026
Labelsv10

When three's WebGPURenderer falls back to its WebGL2 backend (no navigator.gpu), multi-canvas rendering breaks. A secondary canvas (renderer={{ primaryCanvas }}) draws its scene into the primary's canvas, and the secondary canvas stays blank. Both canvases' frame loops keep running.

Repro

Confirmed on unchanged v10: fiber built from origin/v10, packed with pnpm pack, and installed into a fresh Vite app.

typescript
<div style={{ width: 300, height: 300 }}>
  <Canvas id="main" renderer>
    <mesh><boxGeometry /><meshBasicMaterial color="hotpink" /></mesh>
  </Canvas>
</div>
<div style={{ width: 300, height: 300 }}>
  <Canvas renderer={{ primaryCanvas: 'main' }}>
    <mesh><boxGeometry /><meshBasicMaterial color="orange" /></mesh>
  </Canvas>
</div>

In headless Chromium (swiftshader, no WebGPU), three logs "WebGPU is not available, running under WebGL2 backend." The left canvas then shows the orange cube, which is the secondary's scene, and the right canvas is empty.

This affects anyone using primaryCanvas in a browser without usable WebGPU.

Where to look

  • packages/fiber/src/core/renderer.tsx: the secondary path (waitForPrimary, new CanvasTarget(...), isMultiCanvas), and the start-phase canvas-target job, which calls renderer.setCanvasTarget() before each root renders.
  • three's WebGLBackend. A WebGL context is bound to a single canvas element, so switching canvas targets presumably can't redirect output to a second element. The fix is either to copy the frame into the secondary's canvas, or to detect the fallback and fail clearly.

Done when

  • Secondaries render into their own canvas under the WebGL2 fallback, or R3F detects the fallback and reports a clear, documented error instead of silently drawing into the primary.
  • There's a test that uses a mock renderer, like tests/primary-canvas-target.test.tsx.
  • docs/webgpu/multi-canvas.mdx states the behaviour.

Found while smoke-testing the @react-three/tsl packages (pmndrs/react-three-fiber#3964). It's unrelated to that work.

Source: pmndrs/react-three-fiber