Open laino opened 1 year ago
Did you include that new canvas element in the DOM? 🤔
No. It's being used to do some off-screen rendering with a 2D context and putting the result into a texture.
That really doesn't matter though - I could be getting that texture whichever way and end up with the same problem.
Description
Currently doing something like this does not work*:
The reason being that after the cleanup function destroys the texture, it is still used by the Sprite shortly after. It's probably not specific to such an use-case, but likely anything that involves a texture being destroyed in a cleanup function.
It would be great for ergonomics if this could be made to work. If it is impossible due to constraints of React, having an utility function that takes a callback which is executed when it is safe to destroy unused resources would go a long way:
* This is stack trace caused by destroying the texture without wrapping it in a
setTimeout
or similar: