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

Add webgpu async check #29927

Closed
wants to merge 1 commit into from
Closed

Conversation

whatisor
Copy link
Contributor

Related issue: #29916

Description
We want to use WebGPU capability check in nodejs project.

@Mugen87
Copy link
Collaborator

Mugen87 commented Nov 20, 2024

With #29933 merged, what parts of the existing WebGPU.js cause issues with node?

@whatisor
Copy link
Contributor Author

"await" cause issue because it does not allow Global scoped await.

@Mugen87
Copy link
Collaborator

Mugen87 commented Nov 20, 2024

So what you are saying is that node.js does not allow the top-level await in the module?

Instead of adding a separate module, I was hoping adding isAvailableAsync() to the existing WebGPU.js would also work.

@donmccurdy
Copy link
Collaborator

Node.js supports top-level await (TLA) in all active versions, but some tooling does not. Node.js v22+ has greatly improved ESM support over previous versions, with one notable limitation: CommonJS modules cannot import ESM modules that use TLA, for sync/async reasons.

But I'm not sure if CommonJS is related to the reported issues in Next.js. I'd like to reproduce the issue before we commit to a particular fix for it, see #29916 (comment). Possibly there are other options. I would have hoped a 'use client' directive in the Next.js component would be enough, in this case.

@whatisor
Copy link
Contributor Author

The ideal is we want to remove all "global" stuff to make it best compatibility with node development.
Right now, I have no idea to support synced version of WebGPU.isAvailable() which is used in many examples folder.

@whatisor
Copy link
Contributor Author

wait in the module

It will create confliction until we update repo @type/three

@whatisor
Copy link
Contributor Author

The ideal is we want to remove all "global" stuff to make it best compatibility with node development. Right now, I have no idea to support synced version of WebGPU.isAvailable() which is used in many examples folder.

Also, I propose to update WebGPU and all example to async check (instead of global scope) because of limitation of current browser webgpu context checking.

@Mugen87
Copy link
Collaborator

Mugen87 commented Nov 25, 2024

Closing, see #29919 (comment).

@Mugen87 Mugen87 closed this Nov 25, 2024
@Mugen87 Mugen87 added this to the r171 milestone Nov 25, 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