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

SharedArrayBuffer changes in Chrome 91+ #58

Closed
Richienb opened this issue Mar 17, 2021 · 4 comments
Closed

SharedArrayBuffer changes in Chrome 91+ #58

Richienb opened this issue Mar 17, 2021 · 4 comments

Comments

@Richienb
Copy link

In Chrome 91+, a SharedArrayBuffer can only be created if cross-origin isolation is enabled.

Affected part:

isSharedArrayBufferToString(new SharedArrayBuffer())

A possible fix could be falling back to ArrayBuffer if window.crossOriginIsolated !== true.

Related to Richienb/node-polyfill-webpack-plugin#4

@ljharb
Copy link
Member

ljharb commented Mar 17, 2021

If it's not enabled, then isn't typeof SharedArrayBuffer going to be undefined, which would mean the preceding line would cause it to return false?

@Richienb
Copy link
Author

Oh right. In that case, the script is already prepared to work in an environment where SharedArrayBuffer is unavailable.

@daewigma
Copy link

daewigma commented Mar 24, 2021

@ljharb Out of curiosity, is there documentation somewhere that says the cross origin isolation restriction will be implemented by making the constructor undefined as opposed to throwing an error when attempting to use it?

Making it undefined would make sense to do if assuming people have their apps built with backwards/cross-platform compatibility in mind, but I could also see providing the constructor and having it throw an error, as it would make it much more clear what happened to it when code suddenly starts failing.

A lot of places detailing fixing this issue recommend either stopping use of SharedArrayBuffer altogether, or checking window.crossOriginIsolated before using it. I'm not sure if this is because the constructor will just throw an error, they didn't know that SharedArrayBuffer will be undefined, they are wanting to get rid of the deprecation warnings in the meantime, or some other reason I'm not thinking of.

@ljharb
Copy link
Member

ljharb commented Mar 24, 2021

@daewigma yep: tc39/ecma262#1435

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

3 participants