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

Make getStaticAdapter async #29206

Closed
wants to merge 1 commit into from
Closed

Conversation

wcandillon
Copy link
Contributor

Related issues:
#28107
#26626
#28124

Description

We run three.js in an environnement where top-level await is not available. Making getStaticAdapter async fixes the issue. I couldn't find places where this method is used. Not sure if this approach is sensible, I'd love to hear your thoughts on this.

cc @RenaudRohlinger

@RenaudRohlinger
Copy link
Collaborator

Isn't there some kind of top-level await polyfill in react-native?

I recall discussing this and concluded that it’s more effective to address it within the development tooling. /cc @Mugen87

@wcandillon
Copy link
Contributor Author

wcandillon commented Aug 22, 2024

@RenaudRohlinger As far as I am aware top-level async is a very different kind of JS features that cannot be polyfilled because it makes the whole module system async. I'm the maintainer of React Native Skia and it's something we've looked at a lot because the Web Skia implementation is using WebAssembly and therefore the Web module loading is async.
@tmikov had a good summary on the topic here: facebook/hermes#1481 (comment)

@sunag
Copy link
Collaborator

sunag commented Aug 23, 2024

I think we can remove WebGPU.isAvailable() from WebGPURenderer class if we have a callback for initialization error without breaking the examples for this

@wcandillon
Copy link
Contributor Author

wcandillon commented Aug 23, 2024

I'm very sympathetic to the argument of making this the bundler/env problem instead.
As an open-source maintainer myself, I think this is very sensible.

But of course since the change appears so minimal we would love if there is a fix for this as we would be able to run Three.js on React Native WebGPU without patching the build.
Below is a demo of a Three.js build that only contains two tiny changes: (one already landed) and this PR.

demo.mp4

@sunag I'm very excited that is an opportunity to maybe not use top-level await for now. Let me know if I can do anything to help. ❤️

@sunag sunag closed this in #29218 Aug 23, 2024
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.

3 participants