vscode: Webview is unable to load resources while reconstructing after a reload

  • VSCode Version: Insiders Version: 1.42.0-insider – Commit: 2832fc3c234daeda025f205a862703ba7eee6a10 – Date: 2020-01-21T11:30:21.087Z – OS Version: OSX

Steps to Reproduce:

With CodeStream extension:

  1. Open the webview
  2. Reload the window
  3. CodeStream panel will be blank
  4. Open webview dev tools
  5. The console will contain errors like Failed to load resource: net::ERR_UNKNOWN_URL_SCHEME
  6. Close the blank panel
  7. Re-open the CodeStream view
  8. Content should be displayed

With Markdown Preview:

  1. Open markdown preview for a markdown file
  2. Reload the window
  3. Preview panel will display message about an error restoring

EDIT: markdown preview seems fine now

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 16
  • Comments: 33 (14 by maintainers)

Commits related to this issue

Most upvoted comments

We are currently having this same error in our extension.

Steps to reproduce:

  • Open extension and open a webview
  • Close VSCode window
  • Open VSCode
  • Open project

Expected:

  • The webview should load properly along with its content

Actual:

  • The webview tab opens with garbled up content

Reproducer: vscode-issue(2)

@RandomFractals Yes. Extensions that use asWebviewUri will just automatically start using the new protocol. The PR also tries to rewrite any hardcoded vscode-resource uris (which have been deprecated for a while since they also don’t work on web)

same issue with my extension https://github.com/ConsenSys/vscode-solidity-metrics/issues/1 (https://marketplace.visualstudio.com/items?itemName=tintinweb.solidity-metrics)

mostly happens right after starting vscode. closing the web-view and trying again usually works.

repro:

  1. launch vscode
  2. click on a folder and generate solidity metrics 2.1 this collects source code metrics, spawns a web panel, and postMessages data into it… However, the view fails because ERR_UNKNOWN_URL_SCHEME on all the vscode-resource:// URI’s.

if you cannot reproduce: close (reload) vscode and try again

permanent workaround: pack everything into one HTML file and avoid loadingvscode-resource:// URI’s.

Version: 1.43.2
Commit: 0ba0ca52957102ca3527cf479571617f0de6ed50
Date: 2020-03-24T07:34:57.037Z
Electron: 7.1.11
Chrome: 78.0.3904.130
Node.js: 12.8.1
V8: 7.8.279.23-electron.0
OS: Darwin x64 19.4.0

image

I have not seen this in the last few weeks working on webview debugging or reproduce it as I used to be able to, thus marking verified.

Had to revert this fix due to #98768

Will revisit for June

Unfortunately, didn’t work 😞 .

At first it appeared ok, but after a few retries, the issue reappeared. It’s instable, at least.

Just out of curiosity, using scheme: "vscode-resource" gives me this:

<img src="vscode-resource:/thePath/vscode-readme.png">

Using asWebviewUri has a slight different syntax:

<img src="vscode-resource://file///thePath/vscode-readme.png">

I hope the above PR should solve this, and be released as an patch to 1.45.

Thank you

This one should also be async now, see https://www.electronjs.org/docs/api/breaking-changes-ns#planned-breaking-api-changes

The other callback ( async (request, callback: any)) is the handler for requests themselves once they come in