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

Investigate to enable webview in sandboxed environment #116452

Closed
bpasero opened this issue Feb 11, 2021 · 4 comments
Closed

Investigate to enable webview in sandboxed environment #116452

bpasero opened this issue Feb 11, 2021 · 4 comments
Assignees
Labels
sandbox Running VSCode in a node-free environment webview Webview issues
Milestone

Comments

@bpasero
Copy link
Member

bpasero commented Feb 11, 2021

According to @deepak1556 it seems possible to use webview even whith sandbox: true and contextIsolation: true. This would be great to explore given blocking issues such as #96307 for #83188.

I am unfortunately not able to get a simple webview based editor (release notes) to open in sandboxed environments, here are my steps:

  • make sure to be able to run sources from ben/webview-sandbox branch (this simply adds webview code to sandbox layer)
  • run with scripts/code.sh --__sandbox
  • open command palette
  • select Show Release Notes

Observe devtools (you can open via Cmd+Shift+I, but you need to click once into the workbench first for focus):

[Embedded Page] undefined

I was able to get a better error message when I flip contextIsolation: false (here):

[Embedded Page] Unable to load preload script: /Users/bpasero/Development/Microsoft/monaco/out/vs/workbench/contrib/webview/electron-browser/pre/electron-index.js
[Embedded Page] Error: module not found: ../../browser/pre/main

@mjbvz @deepak1556 I will need your help here for how to proceed. Any clues? I verified that these files are not getting blocked from our protocol, this must be something else...

@bpasero bpasero added webview Webview issues sandbox Running VSCode in a node-free environment labels Feb 11, 2021
@bpasero bpasero added this to the February 2021 milestone Feb 11, 2021
@bpasero bpasero self-assigned this Feb 11, 2021
@mjbvz
Copy link
Collaborator

mjbvz commented Feb 17, 2021

@bpasero Looks like the webview preload script is using a file: uri which ends up being blocked:

file:///Users/matb/projects/vscode/out/vs/workbench/contrib/webview/electron-browser/pre/electron-index.js

@deepak1556 Would we be able to serve this script using a vscode-file or vscode-webview uri instead?

@bpasero
Copy link
Member Author

bpasero commented Feb 17, 2021

@mjbvz @deepak1556 my understanding is that preload scripts for webview must use the file protocol, as any other protocol is blocked by Electron from loading. Since the preload scripts seems to be loaded using node.js, we cannot use our custom protocol.

Besides, if I disable our blocking of file protocol by comment out this line, it still does not work.

@bpasero
Copy link
Member Author

bpasero commented Mar 2, 2021

Since we want to invest in #96307 which would give us a path to dropping webview entirely, moving this to Backlog for now.

@bpasero bpasero closed this as completed Mar 24, 2021
@bpasero
Copy link
Member Author

bpasero commented Mar 24, 2021

I am no longer convinced that webview is the future for sandbox, so closing.

@github-actions github-actions bot locked and limited conversation to collaborators May 9, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
sandbox Running VSCode in a node-free environment webview Webview issues
Projects
None yet
Development

No branches or pull requests

3 participants