-
-
Couldn't load subscription status.
- Fork 36.1k
LoadingManager: Lazily instantiate abort controller. #32120
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
Conversation
📦 Bundle sizeFull ESM build, minified and gzipped.
🌳 Bundle size after tree-shakingMinimal build including a renderer, camera, empty scene, and dependencies.
|
|
I'm not sure it's appropriate to add a fix for a bug in another library. Have you considered to bump cloudflare/workerd#3657 and ask for an update? TBH, I'm much not in favor of this fix since it feels a bit unintuitive. |
|
Could we accept this change temporarily until cloudflare/workerd#3657 is fixed? |
|
Because @NuroDev didn't do it, I have bumped the issue at |
In my opinion, that would be a very good idea. Because while
So while I do believe that it might get fixed ( At the moment, Three.js does not work at all on Cloudflare Workers. Libraries like OpenNext (used to deploy Next.js to Cloudflare Workers) use a sledge hammer solution to avoid such constraints by importing the entire application inside the request hander, which obviously slows down the worker since the code is now evaluated when the first request comes in, rather than at bootup time. That's why Three.js currently "works" when used in e.g. Next.js on CF. It's not a reasonable solution for production applications. |
|
Um, would you at least add a comment in
@jasnell Is that true? I was hoping we could avoid adding such code changes to three.js, tbh. |
|
Sure, that makes total sense @Mugen87. I've added a TODO to the abort controller getter as a note for now. |
|
@Mugen87 Thanks a lot for the feedback! Do you think the PR could be merged now? Otherwise, please feel free to let us know what else should be changed. |
|
I have approved the change. I was hoping to get some feedback from the Cloudflare team in time but I agree it's better to merge before waiting too long. |
LoadingManager abort controller|
Incredible, thank you so much! 🙏 |
Description
This is a fix for a very niche edge case, but wanted to at least propose a fix for it.
The problem
For context, I work for @ronin-co and we are building
blade, a React framework for building instant web apps. With this we have found when deploying to Cloudflare Workers, which is powered by workerd, their API throws an error if a Blade project tries to use Three.js:After a bit of investigating I found this issue outlining that workerd does not currently support creating a new abort controller instance in global scope, which the
LoadingManagerloader seems to rely on to construct a new instance.The solution
I found this PR which defers calling
new AbortController()on class construction, and instead uses a getter to manage it. Testing this on our Blade project that uses Three.js it seems to fix the issue.With this I have added some basic unit tests to validate this logic, however I am not deeply familiar with this code base so there could be something I am missing here.