You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
debtCode quality issueselectronIssues and items related to Electroninsiders-releasedPatch has been released in VS Code InsiderssandboxRunning VSCode in a node-free environmentwebviewWebview issues
Today VS Code implements the webview api on desktops using electron's <webview> tag. We've run into some unexpected behavior with webviews and would prefer to move to a more standard web based approach, such as using iframes
For web, we already implement webviews using normal iframes. You can also enable experimental iframe based webviews in desktop VS Code by setting "webview.experimental.useIframes": true ("webview.experimental.useExternalEndpoint": true in older VS Code versions)
Find does not work for for iframe based webviews. There is no clear way to implement the find functionality for webviews without taking a dependency on a third party html search library
Reacted by Benjamin Pasero, Konstantin Solomatov, Alex Kozack, Simon, Alexander, edillenb, elisachen86, Baptiste Bouffaut, Hamza SAYAH, Walid Benbihi and 6 more
Simon (@sguillia) No. Your extension should never direct users to enable this setting. It is intentionally not documented and marked as experimental because it is not production ready and it is not particularly stable
While can't switch to iframe based webviews yet, this iteration I think we should try the following:
Enable the new vscode-webview-resource scheme our existing webviews. This would let us move away from using a vscode-resource protocol handler for each individual webview.
Update asWebviewUri to return vscode-webview-resource uris.
Add some code that tries to rewrite vscode-resource: uris to vscode-webview-resource uris (this is very similar to the code we already have for web that rewrites vscode-resource uris).
Matt Bierner (@mjbvz) does that solution preserve todays isolation from webview to webview? I thought in order to achieve that, each webview would need its own origin?
And a second question: what is the purpose of vscode-resource scheme. Is it only used for content inside webview that wants to access files?
does that solution preserve todays isolation from webview to webview? I thought in order to achieve that, each webview would need its own origin?
Yup we are preserving that, the idea for desktop is quite similar to web but instead of subdomains we generate new uuids for each webview that will act as the origin and we map that to the webview id. For ex:
vscode-webview is registered as standard scheme, it will respect URI of the format scheme://origin/path. When something like vscode-webview://uuid1/test.html and vscode-webview://uuid2/test.html are loaded in two different webview, chromium will treat these as separate origins because of uuid1 , uuid2 and provide them with their own process.
On the main process side, we pretty much just have to handle the path to load resource from based on the uuid -> webview id mapping
debtCode quality issueselectronIssues and items related to Electroninsiders-releasedPatch has been released in VS Code InsiderssandboxRunning VSCode in a node-free environmentwebviewWebview issues
Activity
mjbvz commentedon Oct 24, 2019
Also potentially addresses:
sguillia commentedon Apr 17, 2020
Hi
I am an extension author
This issue totally prevents some of my users to open the webview contributed by my extension.
The panel opens, but the content is not loaded.
Adding this line to the settings fixes the problem:
Do you recommend me to make my extension spontaneously write useExternalEndpoint to the user settings?
My extension requires internet anyway so this seems a reasonable workaround.
I can try to detect when the problem occurs, by setting up a watchdog in the extension, and making the webview content call
postMessageon first load.mjbvz commentedon Apr 17, 2020
Simon (@sguillia) No. Your extension should never direct users to enable this setting. It is intentionally not documented and marked as
experimentalbecause it is not production ready and it is not particularly stablemjbvz commentedon May 13, 2020
Robo (@deepak1556) Just pushed an update to my branch the enables offline iframe based webviews (without requiring service workers): https://github.com/mjbvz/vscode/tree/iframe-webviews
The bulk of the change is in mjbvz@9091ad7
While can't switch to iframe based webviews yet, this iteration I think we should try the following:
Enable the new
vscode-webview-resourcescheme our existing webviews. This would let us move away from using avscode-resourceprotocol handler for each individual webview.Update
asWebviewUrito returnvscode-webview-resourceuris.Add some code that tries to rewrite
vscode-resource:uris tovscode-webview-resourceuris (this is very similar to the code we already have for web that rewritesvscode-resourceuris).bpasero commentedon May 13, 2020
Matt Bierner (@mjbvz) does that solution preserve todays isolation from
webviewtowebview? I thought in order to achieve that, eachwebviewwould need its own origin?And a second question: what is the purpose of
vscode-resourcescheme. Is it only used for content insidewebviewthat wants to access files?deepak1556 commentedon May 13, 2020
Yup we are preserving that, the idea for desktop is quite similar to web but instead of subdomains we generate new uuids for each webview that will act as the origin and we map that to the webview id. For ex:
vscode-webviewis registered as standard scheme, it will respect URI of the formatscheme://origin/path. When something likevscode-webview://uuid1/test.htmlandvscode-webview://uuid2/test.htmlare loaded in two different webview, chromium will treat these as separate origins because ofuuid1,uuid2and provide them with their own process.On the main process side, we pretty much just have to handle the path to load resource from based on the
uuid -> webview idmappingbpasero commentedon May 13, 2020
Ah ok, I was not aware that having the UUID as part of the URL is sufficient, that is great 👍
mjbvz commentedon Jun 25, 2020
#100991 enables offline iframe based webviews on desktop. Still blocked on moving off of webviews until search is supported: #96307
Fix refocusing clearing existing forcus for iframe based webviews
Enable iframe based webviews on desktop for webviews that don't need …
We should not set isViewerEmbedded false. If it is false, the interna…