Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update project to work with latest react #443

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

martinbooth
Copy link

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
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'
1 participant