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

Unable to create web-worker if SharedArrayBuffer is enabled #1103

Closed
LeXXik opened this issue Feb 17, 2024 · 14 comments
Closed

Unable to create web-worker if SharedArrayBuffer is enabled #1103

LeXXik opened this issue Feb 17, 2024 · 14 comments
Assignees

Comments

@LeXXik
Copy link

LeXXik commented Feb 17, 2024

Unable to create a web-worker, if SharedArrayBuffer option is enabled.

Repro: https://playcanvas.com/project/1191623/overview/corp-issue

image

image

@LeXXik LeXXik changed the title Unable to use Shared Array Buffer Unable to create web-worker if SharedArrayBuffer is enabled Feb 17, 2024
@mvaligursky mvaligursky transferred this issue from playcanvas/engine Feb 19, 2024
@MAG-AdrianMeredith
Copy link

Literally came here to log the same issue. We have a client hoping to make use of this. It looks like assets come from a different server and that one doesn;t set the COOP + COEP headers that are required for secure features e.g. sharedarraybuffer and workers

@mvaligursky
Copy link

Do we know what the solution to this is?
@isumygin-sc or anybody else?

@MAG-AdrianMeredith
Copy link

@mvaligursky It should be the same that you did to add SharedArrayBuffer support. All of the servers you use need to return COOP and COEP http headers.
Basically do exactly what that error message says in the screenshot above

@isumygin-sc
Copy link

We use credentialless for Cross-Origin-Embedder-Policy if SharedArrayBuffer is enabled

require-corp
A document can only load resources from the same origin, or resources explicitly marked as loadable from another origin. If a cross origin resource supports CORS, the crossorigin attribute or the Cross-Origin-Resource-Policy header must be used to load it without being blocked by COEP.

credentialless
no-cors cross-origin requests are sent without credentials. In particular, it means Cookies are omitted from the request, and ignored from the response. The responses are allowed without an explicit permission via the Cross-Origin-Resource-Policy header. Navigate responses behave similarly as the require-corp mode: They require Cross-Origin-Resource-Policy response header.

@isumygin-sc
Copy link

isumygin-sc commented Feb 27, 2024

right, so the headers are set for the launch page only and should be set for the worker as well

@isumygin-sc
Copy link

could you build me a test case please?

@marklundin
Copy link
Member

marklundin commented Feb 27, 2024

@yak32
Copy link

yak32 commented Feb 27, 2024

i prepared a fix, will be deployed soon

@LeXXik
Copy link
Author

LeXXik commented Mar 9, 2024

Eagerly waiting ;)

@willeastcott
Copy link
Contributor

@LeXXik It should be Monday morning. 😄

@isumygin-sc
Copy link

the fix is deployed, please test your projects

@MAG-AdrianMeredith
Copy link

Looks good, can confirm I am getting data from a websocket connection handled by a worker thread with sharedarraybuffer!
Weirdly enough I get these error but nothing appears to be broken
Screenshot 2024-03-12 at 08 36 16

Thanks everyone

@marklundin
Copy link
Member

marklundin commented Mar 12, 2024

@MAG-AdrianMeredith Those errors are because the scripts are not loaded as modules, so static imports and import.meta are invalid. This will be fixes soon, but for now you can see if there is a UMD/CJS build of the library you're using

@LeXXik
Copy link
Author

LeXXik commented Mar 12, 2024

It works on my end. Thank you!

Although, it throws an issue with Draco. I will open another ticket for it.

This was referenced Mar 12, 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

No branches or pull requests

7 participants