Skip to content

fix: resolve canvas texture race conditions#803

Merged
jfboeve merged 3 commits into
mainfrom
fix/canvas-texture-race-condition
Jun 5, 2026
Merged

fix: resolve canvas texture race conditions#803
jfboeve merged 3 commits into
mainfrom
fix/canvas-texture-race-condition

Conversation

@wouterlucas

Copy link
Copy Markdown
Contributor
  • CanvasTexture.load(): capture textureData ref before first await to prevent freeTextureDataTask microtask from nulling it mid-flight
  • CanvasTexture.load(): abort if texture is freed while load is in-flight to prevent state/image desync (state=loaded but image=undefined)
  • CanvasTexture.getImage(): return null instead of asserting on missing image, allowing callers to skip gracefully
  • CanvasRenderer.renderContext(): guard against null return from getImage()
  • Texture.free(): null out ctxTexture after freeing to prevent stale reference reuse on reload
  • Texture.canBeCleanedUp(): exclude textures in 'loading' state from eviction to prevent cleanup racing an in-flight load

…rors

- CanvasTexture.load(): capture textureData ref before first await to
  prevent freeTextureDataTask microtask from nulling it mid-flight
- CanvasTexture.load(): abort if texture is freed while load is in-flight
  to prevent state/image desync (state=loaded but image=undefined)
- CanvasTexture.getImage(): return null instead of asserting on missing
  image, allowing callers to skip gracefully
- CanvasRenderer.renderContext(): guard against null return from getImage()
- Texture.free(): null out ctxTexture after freeing to prevent stale
  reference reuse on reload
- Texture.canBeCleanedUp(): exclude textures in 'loading' state from
  eviction to prevent cleanup racing an in-flight load
jfboeve
jfboeve previously approved these changes Jun 5, 2026
@jfboeve jfboeve merged commit 9395713 into main Jun 5, 2026
2 checks passed
@jfboeve jfboeve deleted the fix/canvas-texture-race-condition branch June 5, 2026 08:33
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