Lokasi ngalangkungan proxy:   [ UP ]  
[Ngawartoskeun bug]   [Panyetelan cookie]                
Skip to content

Update project to work with latest react#443

Merged
gre merged 2 commits into
gre:masterfrom
martinbooth:remove_legacy_context_usage
Oct 8, 2025
Merged

Update project to work with latest react#443
gre merged 2 commits into
gre:masterfrom
martinbooth:remove_legacy_context_usage

Conversation

@martinbooth

Copy link
Copy Markdown
Contributor

Summary

This removes the usage of the legacy context apis which have been completely removed in react 19.

Additionally, it fixes: #408. It's not a great fix as it removes code deliberately added to help chrome GC unused webglcontexts, but chrome will GC them (eventually).. this is an api that is only supposed to be used for testing. The bug is caused because react (in dev mode) double renders to ensure your app is compatible with concurrent mode features, and destroying the webglcontext like this means on the second render the webglcontext is unusable. I've found no way to restore it

Finally it fixes an issue with nested Nodes also caused by the double render. When a parent Node is unmounted it tells the children it is no longer a dependent but it doesn't remove the child node from itself as a dependency. When the tree is reconstructed in the second render it doesn't re-add the child as a dependency (because it was never removed on unmount) but this no-op means it doesn't add itself as a dependent again (which does need to happen because it was removed)

Test plan

I've tested the example in the readme, and more complicated examples that have nested Nodes.. The PR should be pretty safe because things can't get much more broken then they are now (with the latest react at least)

React double mounts/unmounts components and loseGL is not compatible with that
Moved usage of the legacy context to newer context apis
@gre

gre commented Oct 8, 2025

Copy link
Copy Markdown
Owner

awesome. thanks for this ❤️

@gre gre merged commit 3d0f762 into gre:master Oct 8, 2025
@ea167

ea167 commented Feb 19, 2026

Copy link
Copy Markdown

Hello @gre, it would be wonderful if you could publish a new npm version with these updates 🙏

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.

Failed to execute 'shaderSource' on 'WebGL2RenderingContext': parameter 1 is not of type 'WebGLShader'

3 participants