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
Abort controller support #3005
Comments
I'm not sure I understand why a code change is needed in suspend-react since that only resolves promises via React Suspense. For three.js loaders, that is indeed not actionable until that PR gets through. I see you've already updated there, since it was lost. |
Maybe it isn't required to support an abortcontroller but could be useful to detect the unmount of the component to abort the request if the component gets dismissed during the loading screen, since it's hard to do it inside a Suspense (for the issue about useEffect I mentioned). It is probably doable by wrapping the useLoader component with |
A suspended component is never mounted -- suspense interrupts rendering to the nearest suspense boundary. If you're trying to address memory leaks from three.js loaders, upstream support is the only way around that. You could maybe fork or patch three.js |
Yes that's the problem, I think that the issue in suspend-react was asking for a way to automatically abort the loading on unmount from the same component or hook using the suspend function, but as I also mentioned inside that issue it doesn't seem to be possible. But I think that by wrapping the loader with
Obviously this can't be included inside a library but only in the end implementation. |
Currently there's no way to abort a pending request using useLoader or similar hooks.
It's a big problem in use cases where large models are downloaded using slow connections, and currently the requests keep loading in background even when the component using useLoader gets unmounted.
Sadly it seems that two dependencies needs to add abort controller support before being able to use it on r3f...
three.js: mrdoob/three.js#23070
suspend-react: pmndrs/suspend-react#10
Currently because of the suspend call, a component using useLoader can't even detect the unmount with the useEffect hook, since the component doesn't get mounted during the loading.
This example will make it clearer:
It is probably an intended behavior but may be a problem when implementing abort controller support.
I hope that opening an issue here helps catching some more attention to this problem and to find the nicest and smoothest API on both dependencies.
The text was updated successfully, but these errors were encountered: