Skip to content

Conversation

@felixpalmer
Copy link
Collaborator

@felixpalmer felixpalmer commented Jan 8, 2026

Implemented against 9.2-release

Background

Using luma in an React environment with StrictMode causes the getMaxDrawingBufferSize() method in canvas-context to be called twice, once with and invalid device, leading to a error (repeated whenever the DOM node is remounted):

Uncaught TypeError: Cannot read properties of undefined (reading 'maxTextureDimension2D')
    at WebGLCanvasContext.getMaxDrawingBufferSize (canvas-context.ts:241:52)
    at WebGLCanvasContext._handleResize (canvas-context.ts:379:62)
    at ResizeObserver.<anonymous> (canvas-context.ts:171:65)
getMaxDrawingBufferSize @ canvas-context.ts:241
_handleResize @ canvas-context.ts:379
(anonymous) @ canvas-context.ts:171

Change List

  • Add this.canvasContext.destroy() in webgl-device.ts to cleanup orphaned canvas
  • Disconnect observers to prevent callbacks from firing after destruction
  • Defensive checks in canvas-context.ts
  • Add new hello-react tutorial app to repro bug and help test React integration in future

@felixpalmer felixpalmer requested a review from ibgreen January 8, 2026 14:06
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.

2 participants