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

Allow SharedArrayBuffer to be used by extensions in vscode.dev (using cross-origin isolation) #137884

Closed
michalbali256 opened this issue Nov 25, 2021 · 12 comments
Assignees
Labels
extension-host Extension host issues feature-request Request for new features or functionality on-testplan under-discussion Issue is under discussion for relevance, priority, approach verification-needed Verification of issue is requested verified Verification succeeded web Issues related to running VSCode in the web
Milestone

Comments

@michalbali256
Copy link

Does this issue occur when all extensions are disabled?: No

  • VS Code Version: 1.62.3 (vscode.dev)
  • Browser Version: Chrome 96

Hi,

I am trying to make our extension (https://github.com/eclipse/che-che4z-lsp-for-hlasm) work in browser environment so it can be used with web version of vscode. It is written in C++ and we are using emscripten to compile it into WebAssembly. The C++ backend uses multiple threads, which translate into web workers and emscripten uses SharedArrayBuffer to communicate between them. However SharedArrayBuffer is not available on vscode.dev, since the site does not use cross-origin isolation - see this: https://developer.chrome.com/blog/enabling-shared-array-buffer/

Steps to Reproduce:

  1. Open vscode.dev in your browser (I tried with Chrome 96).
  2. Install this extension: https://marketplace.visualstudio.com/items?itemName=mbali.hlasm-browser-dev
  3. Open arbitrary folder on your computer (empty one is enough)
  4. Create a new empty file
  5. Open developer tools of browser
  6. Choose HLASM as language of the file
    In the Console of developer tools, this message shows:
    image
    And of course, the extension is not enabled.

Additional Info:

I have managed to get it working by starting chrome with disabled security:

chrome.exe --enable-features=SharedArrayBuffer --disable-web-security --user-data-dir="<some-folder-on-your-computer>"

If I reproduce those steps with chrome started this way, the extensions works as expected (just try to type something and there will by some diagnostics).

BTW I have opened a similar issue (microsoft/vscode-test-web#14) in the vscode-test-web repository, but nobody noticed it there, so I created this issue with reproducible example.

@bpasero
Copy link
Member

bpasero commented Nov 25, 2021

Related: #116715

@jrieken jrieken added extension-host Extension host issues under-discussion Issue is under discussion for relevance, priority, approach web Issues related to running VSCode in the web feature-request Request for new features or functionality labels Dec 15, 2021
@jrieken jrieken added this to the Backlog milestone Dec 15, 2021
@jrieken jrieken modified the milestones: Backlog, March 2022 Feb 11, 2022
@jrieken
Copy link
Member

jrieken commented Feb 11, 2022

March to investigate. Enabling crossOrigin isolation can have some ripple on things that we load and those need CORP or CORS to continue to work

@jrieken jrieken modified the milestones: March 2022, April 2022 Mar 21, 2022
@jrieken
Copy link
Member

jrieken commented Mar 21, 2022

We know what to do here but there is still work to configure our CDNs and to find resources that aren't CORP-ready yet

@jrieken jrieken modified the milestones: April 2022, Backlog Apr 22, 2022
@jrieken
Copy link
Member

jrieken commented Apr 22, 2022

Enabling this unfortunately has unwanted side-effects on extensions using webview. I believe we are blocked until browsers relax restrictions for embedded iframe a bit, see #145539 (comment)

@jrieken jrieken modified the milestones: Backlog, June 2022 Jun 10, 2022
@jrieken
Copy link
Member

jrieken commented Jun 10, 2022

We will do more exploring during June

jrieken added a commit that referenced this issue Jun 17, 2022
add `cross-origin-isolated` to web-worker ext host iframe, related #137884
@jrieken jrieken modified the milestones: June 2022, July 2022 Jun 27, 2022
@jrieken
Copy link
Member

jrieken commented Jul 1, 2022

Plan for July

  • add support for a url-query like ?vscode-coi (cross origin isolation)
  • when present the server responds with the COOP/COEP headers
  • this enables COI for the renderer
  • when creating descendant resources (e.g. worker based extension host, web views) we check for globalThis.crossOriginIsolated and use the the same url-query so that our CDN can respond with the COEP header for them
  • this enables COI for the web worker extension host
  • (optionally set a cookie so that subsequent loads don't need the vscode-coi query)

@jrieken
Copy link
Member

jrieken commented Jul 1, 2022

Once we have that we can explore and see what all breaks - webviews loading 3rd party resources, auth, embedding...

@chenzx
Copy link

chenzx commented Jul 7, 2022

We're building a internal wasm ui design/edtior as a vscode plugin which needs SharedArrayBuffer feature, expect this to ship in July!

@jrieken
Copy link
Member

jrieken commented Jul 13, 2022

This is now live on insiders.dev. You have to use the vscode-coi-query argument to enable cross-origin isolation, e.g https://insiders.vscode.dev/?vscode-coi.

Note that for now this is only for insiders.vscode.dev - stable (vscode.dev) will follow with the normal release flow and github.dev will follow later, esp after having gained more insights. Also expect that some external resources aren't loading - they need the CORP header to be set. Please file issues for those cases. Last, this is for web only - #116715 tracks a similar effort for desktop

@jrieken jrieken closed this as completed Jul 13, 2022
@jrieken
Copy link
Member

jrieken commented Jul 13, 2022

Screenshot 2022-07-13 at 12 30 02

@jgentes
Copy link

jgentes commented Jul 18, 2022

I tested this after building from the latest VSC source and running .\scripts\code-web.bat to launch VSCode for Web, but it looks like the vscode-coi argument doesn't work there. I still see crossOriginIsolated = false in the console and also when I initiate that check in a WebView from an extension. This is using version 1.70.0.

I've added a request for vscode-test-web to support this (microsoft/vscode-test-web#31) otherwise is there another way to test it locally?

Thanks!

@jrieken jrieken added the verification-needed Verification of issue is requested label Jul 22, 2022
@jrieken
Copy link
Member

jrieken commented Jul 22, 2022

To verify

  • open insiders.vscode.dev with the ?vscode-coi query
  • make sure everything loads
  • test a webview extensions and see if they work or not

@connor4312 connor4312 added the verified Verification succeeded label Jul 27, 2022
@github-actions github-actions bot locked and limited conversation to collaborators Aug 28, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
extension-host Extension host issues feature-request Request for new features or functionality on-testplan under-discussion Issue is under discussion for relevance, priority, approach verification-needed Verification of issue is requested verified Verification succeeded web Issues related to running VSCode in the web
Projects
None yet
Development

No branches or pull requests

7 participants