microsoft / vscode

Visual Studio Code
https://code.visualstudio.com
MIT License
164.05k stars 29.21k forks source link

Unable to run sandboxed process when run as elevated under applocker #122951

Open moward opened 3 years ago

moward commented 3 years ago

Steps to Reproduce:

  1. Open a markdown file, and click the "Open preview to the side" button
  2. The preview window is blank, and an error notification pops up in the bottom right:

    Error loading webview: Error: Could not register service workers: TypeError: Failed to register a ServiceWorker for scope ('vscode-webview://36f8a74c-37c6-4d60-9d4c-87414f69ebcc/') with script ('vscode-webview://36f8a74c-37c6-4d60-9d4c-87414f69ebcc/service-worker.js?platform=electron&id=36f8a74c-37c6-4d60-9d4c-87414f69ebcc&vscode-resource-origin=https%3A%2F%2F36f8a74c-37c6-4d60-9d4c-87414f69ebcc.vscode-webview-test.com'): ServiceWorker cannot be started.

The same thing happens for other WebViews, like opening an extension from the Extensions sidebar, or using the "Issue Reporter".

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

vscodebot[bot] commented 3 years ago

(Experimental duplicate detection) Thanks for submitting this issue. Please also check if it is already covered by an existing one, like:

mjbvz commented 3 years ago

Which specific insider build are you on? Please share the commit number. This should be in the about panel

moward commented 3 years ago

Here you go:

Version: 1.56.0-insider (user setup) Commit: 85f8ebf1687661c45fe2633bdd7f640164a20cc2 Date: 2021-05-04T08:04:43.323Z

mjbvz commented 3 years ago

Thanks. Unfortunately I can't reproduce this issue with that build

Can you try launching VS Code by running code-insiders --verbose from the command line. This will print more detailed logs that may help me investigate what is going on

deepak1556 commented 3 years ago

ServiceWorker cannot be started can happen in the following situations,

1) |script_url| is on a different origin from |scope| 2) Fetching |script_url| fails. 3) |script_url| fails to parse or its top-level execution fails.

Based on the error message 1) and 2) are satisfied, very likely we are hitting 3) given the TypeError.

Lets check the webview devtools console log for any script errors thrown, if not we would have to expose a way to pause serviceworker execution on start to debug further, a similar feature provided by chrome://serviceworker-internals/

moward commented 3 years ago

I see this stack appear before the error message:

[5660:0505/094114.425:INFO:CONSOLE(627)] "%c  ERR color: #f33 Cannot read property 'resource' of undefined: TypeError: Cannot read property 'resource' of undefined
    at c.deserializeWebviewPanel (c:\Users\mahowa\AppData\Local\Programs\Microsoft VS Code Insiders\resources\app\extensions\markdown-language-features\dist\extension.js:1:107435)
    at s.$deserializeWebviewPanel (c:\Users\mahowa\AppData\Local\Programs\Microsoft VS Code Insiders\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:88:68958)
    at l._doInvokeHandler (c:\Users\mahowa\AppData\Local\Programs\Microsoft VS Code Insiders\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:91:12836)
    at l._invokeHandler (c:\Users\mahowa\AppData\Local\Programs\Microsoft VS Code Insiders\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:91:12520)
    at l._receiveRequest (c:\Users\mahowa\AppData\Local\Programs\Microsoft VS Code Insiders\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:91:11187)
    at l._receiveOneMessage (c:\Users\mahowa\AppData\Local\Programs\Microsoft VS Code Insiders\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:91:9973)
    at c:\Users\mahowa\AppData\Local\Programs\Microsoft VS Code Insiders\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:91:8074
    at fire (c:\Users\mahowa\AppData\Local\Programs\Microsoft VS Code Insiders\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:57:1836)
    at S.fire (c:\Users\mahowa\AppData\Local\Programs\Microsoft VS Code Insiders\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:65:15497)
    at c:\Users\mahowa\AppData\Local\Programs\Microsoft VS Code Insiders\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:106:29764
    at fire (c:\Users\mahowa\AppData\Local\Programs\Microsoft VS Code Insiders\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:57:1836)
    at S.fire (c:\Users\mahowa\AppData\Local\Programs\Microsoft VS Code Insiders\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:65:15497)
    at t._receiveMessage (c:\Users\mahowa\AppData\Local\Programs\Microsoft VS Code Insiders\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:65:20755)
    at c:\Users\mahowa\AppData\Local\Programs\Microsoft VS Code Insiders\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:65:17641
    at fire (c:\Users\mahowa\AppData\Local\Programs\Microsoft VS Code Insiders\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:57:1836)
    at acceptChunk (c:\Users\mahowa\AppData\Local\Programs\Microsoft VS Code Insiders\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:65:12862)
    at c:\Users\mahowa\AppData\Local\Programs\Microsoft VS Code Insiders\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:65:12210
    at Socket.v (c:\Users\mahowa\AppData\Local\Programs\Microsoft VS Code Insiders\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:106:13195)
    at Socket.emit (events.js:315:20)
    at addChunk (internal/streams/readable.js:309:12)
    at readableAddChunk (internal/streams/readable.js:284:9)
    at Socket.Readable.push (internal/streams/readable.js:223:10)
    at Pipe.onStreamRead (internal/stream_base_commons.js:188:23)", source: file:///C:/Users/mahowa/AppData/Local/Programs/Microsoft VS Code Insiders/resources/app/out/vs/workbench/workbench.desktop.main.js (627)
...
[5660:0505/094114.703:INFO:CONSOLE(627)] "%cDEBUG background: #eee; color: #888 Webview(8b913105-9191-43c8-a617-1606ad761eae): did post message on 'focus'", source: file:///C:/Users/mahowa/AppData/Local/Programs/Microsoft VS Code Insiders/resources/app/out/vs/workbench/workbench.desktop.main.js (627)
[5660:0505/094114.706:INFO:CONSOLE(1728)] "[Embedded Page] Webview fatal error: Error: Could not register service workers: TypeError: Failed to register a ServiceWorker for scope ('vscode-webview://8b913105-9191-43c8-a617-1606ad761eae/') with script ('vscode-webview://8b913105-9191-43c8-a617-1606ad761eae/service-worker.js?platform=electron&id=8b913105-9191-43c8-a617-1606ad761eae&vscode-resource-origin=https%3A%2F%2F8b913105-9191-43c8-a617-1606ad761eae.vscode-webview-test.com'): ServiceWorker cannot be started.", source: file:///C:/Users/mahowa/AppData/Local/Programs/Microsoft VS Code Insiders/resources/app/out/vs/workbench/workbench.desktop.main.js (1728)
[5660:0505/094114.707:INFO:CONSOLE(735)] "Error loading webview: Error: Could not register service workers: TypeError: Failed to register a ServiceWorker for scope ('vscode-webview://8b913105-9191-43c8-a617-1606ad761eae/') with script ('vscode-webview://8b913105-9191-43c8-a617-1606ad761eae/service-worker.js?platform=electron&id=8b913105-9191-43c8-a617-1606ad761eae&vscode-resource-origin=https%3A%2F%2F8b913105-9191-43c8-a617-1606ad761eae.vscode-webview-test.com'): ServiceWorker cannot be started.", source: file:///C:/Users/mahowa/AppData/Local/Programs/Microsoft VS Code Insiders/resources/app/out/vs/workbench/workbench.desktop.main.js (735)
[5660:0505/094114.710:INFO:CONSOLE(627)] "%cDEBUG background: #eee; color: #888 Webview(8b913105-9191-43c8-a617-1606ad761eae): did post message on 'focus'", source: file:///C:/Users/mahowa/AppData/Local/Programs/Microsoft VS Code Insiders/resources/app/out/vs/workbench/workbench.desktop.main.js (627)

I'm not sure if this is a Markdown-specific issue though. I can also try uninstalling and re-installing if you'd like.

bpasero commented 3 years ago

Interesting, this looks a lot like the https://github.com/microsoft/vscode/issues/120157 I saw earlier but then could not reproduce anymore.

mjbvz commented 3 years ago

@moward It happens for all webviews though, not just markdown previews, correct?

moward commented 3 years ago

Image file previews are also broken. Do these use WebViews? I see an empty window but no error notification and don't see anything in the verbose logs. Also, I just upgraded a different machine to 85f8ebf1687661c45fe2633bdd7f640164a20cc2 and am now seeing the same problem there. 🙁

haugerbr commented 3 years ago

I have noticed this issue on the stable build of 1.56.0 that was just released. I have found it only happens if I run vscode as administrator. I noticed because I couldn't read the release notes 😂

Error loading webview: Error: Could not register service workers: TypeError: Failed to register a ServiceWorker for scope ('vscode-webview://vs_code_release_notes/') with script ('vscode-webview://vs_code_release_notes/service-worker.js?platform=electron&id=vs_code_release_notes&vscode-resource-origin=https%3A%2F%2Fvs_code_release_notes.vscode-webview-test.com'): ServiceWorker cannot be started.

moward commented 3 years ago

You're absolutely right, @haugerbr. I always run as administrator and forgot to consider that. I just tried running without elevated permissions and the WebViews work

haugerbr commented 3 years ago

@mjbvz @bpasero can you try to repro using the info I posted. I have a feeling you that may start seeing more issues like this opened because I'm sure there are other people who need vscode to run as admin and while vscode can still be used, it degrades the experience significantly.

mjbvz commented 3 years ago

Seems to work fine for me as an administrator:

Screen Shot 2021-05-06 at 12 15 07 PM

Any extra details about how VS Code is installed or what the permissions are like on your machine?

haugerbr commented 3 years ago

@mjbvz I am an admin on the machine itself and vscode was installed through the windows installer. I am actually unable to open developer tools which is unfortunate because I was trying to get a better error message for you if one exists. I also tried submitting a bug though a non admin vscode instance so there would be more system information but I couldn't get it to post to github.

deepak1556 commented 3 years ago

@haugerbr can you launch with code.cmd --no-sandbox and check if it helps. If not, can you attach the output of code.cmd --verbose

haugerbr commented 3 years ago

@deepak1556 the code --no-sandbox didnt seem to change anything. The below error is repeated infinitely in verbose mode after opening a webview. I redacted configURIPath since I don't think it's relavent and it contains information I don't want shown but it's worth noting that it is a VSCode workspace file.


[main 2021-05-06T21:03:56.021Z] IPC Object URL: Removed channel vscode:ca9cd48f-1175-4975-9ccd-234bfcc00750.
[main 2021-05-06T21:03:56.022Z] Lifecycle#window.on('closed') - window ID 1
[main 2021-05-06T21:03:56.022Z] Lifecycle#onWillShutdown.fire()
[main 2021-05-06T21:03:56.024Z] IPC Object URL: Removed channel vscode:c9cf8323-7048-437c-b08c-1ed3694d61a7.
[main 2021-05-06T21:03:56.057Z] Lifecycle#app.on(window-all-closed)
[main 2021-05-06T21:03:56.057Z] Lifecycle#app.on(before-quit)
[main 2021-05-06T21:03:56.057Z] Lifecycle#onBeforeShutdown.fire()
[main 2021-05-06T21:03:56.058Z] [WindowsStateHandler] onBeforeShutdown {
  lastActiveWindow: {
    workspaceIdentifier: {
      id: 'ab9313a30fade07ac323ad606ba08fe7',
      configURIPath: '<redacted>'
    },
    folder: undefined,
    backupPath: 'C:\\Users\\brianhau\\AppData\\Roaming\\Code\\Backups\\ab9313a30fade07ac323ad606ba08fe7',
    remoteAuthority: undefined,
    uiState: [Object: null prototype] {
      mode: 0,
      x: 128,
      y: 0,
      width: 1024,
      height: 690
    }
  },
  lastPluginDevelopmentHostWindow: {
    workspaceIdentifier: undefined,
    folder: undefined,
    backupPath: undefined,
    remoteAuthority: undefined,
    uiState: { mode: 0, x: 128, y: 0, width: 1024, height: 690 }
  },
  openedWindows: []
}
[main 2021-05-06T21:03:56.061Z] Lifecycle#app.on(will-quit)
[4436:0506/140356.085:INFO:CONSOLE(627)] "%cDEBUG background: #eee; color: #888 Webview(vs_code_release_notes): did post message on 'focus'", source: file:///C:/Users/brianhau/AppData/Local/Programs/Microsoft VS Code/resources/app/out/vs/workbench/workbench.desktop.main.js (627)
[4436:0506/140356.086:INFO:CONSOLE(627)] "%cDEBUG background: #eee; color: #888 Webview(vs_code_release_notes): did post message on 'focus'", source: file:///C:/Users/brianhau/AppData/Local/Programs/Microsoft VS Code/resources/app/out/vs/workbench/workbench.desktop.main.js (627)
Error occurred in handler for 'GUEST_VIEW_MANAGER_CALL': Error: Invalid guestInstanceId: 3
    at getGuestForWebContents (electron/js2c/browser_init.js:189:6386)
    at electron/js2c/browser_init.js:189:5451
    at electron/js2c/browser_init.js:189:1716
    at electron/js2c/browser_init.js:205:579
    at Object.<anonymous> (electron/js2c/browser_init.js:165:10005)
    at Object.emit (events.js:315:20)
Error occurred in handler for 'GUEST_VIEW_MANAGER_CALL': Error: Invalid guestInstanceId: 3
    at getGuestForWebContents (electron/js2c/browser_init.js:189:6386)
    at electron/js2c/browser_init.js:189:5451
    at electron/js2c/browser_init.js:189:1716
    at electron/js2c/browser_init.js:205:579
    at Object.<anonymous> (electron/js2c/browser_init.js:165:10005)
    at Object.emit (events.js:315:20)
Error occurred in handler for 'GUEST_VIEW_MANAGER_CALL': Error: Invalid guestInstanceId: 3
    at getGuestForWebContents (electron/js2c/browser_init.js:189:6386)
    at electron/js2c/browser_init.js:189:5451
    at electron/js2c/browser_init.js:189:1716
    at electron/js2c/browser_init.js:205:579
    at Object.<anonymous> (electron/js2c/browser_init.js:165:10005)
    at Object.emit (events.js:315:20)
Error occurred in handler for 'GUEST_VIEW_MANAGER_CALL': Error: Invalid guestInstanceId: 3
    at getGuestForWebContents (electron/js2c/browser_init.js:189:6386)
    at electron/js2c/browser_init.js:189:5451
    at electron/js2c/browser_init.js:189:1716
    at electron/js2c/browser_init.js:205:579
    at Object.<anonymous> (electron/js2c/browser_init.js:165:10005)
    at Object.emit (events.js:315:20)
Error occurred in handler for 'GUEST_VIEW_MANAGER_CALL': Error: Invalid guestInstanceId: 3
    at getGuestForWebContents (electron/js2c/browser_init.js:189:6386)
    at electron/js2c/browser_init.js:189:5451
    at electron/js2c/browser_init.js:189:1716
    at electron/js2c/browser_init.js:205:579
    at Object.<anonymous> (electron/js2c/browser_init.js:165:10005)
    at Object.emit (events.js:315:20)
[4436:0506/140356.097:INFO:CONSOLE(627)] "%cDEBUG background: #eee; color: #888 Webview(vs_code_release_notes): did post message on 'focus'", source: file:///C:/Users/brianhau/AppData/Local/Programs/Microsoft VS Code/resources/app/out/vs/workbench/workbench.desktop.main.js (627)
Error occurred in handler for 'GUEST_VIEW_MANAGER_CALL': Error: Invalid guestInstanceId: 3
    at getGuestForWebContents (electron/js2c/browser_init.js:189:6386)
    at electron/js2c/browser_init.js:189:5451
    at electron/js2c/browser_init.js:189:1716
    at electron/js2c/browser_init.js:205:579
    at Object.<anonymous> (electron/js2c/browser_init.js:165:10005)
    at Object.emit (events.js:315:20)
[4436:0506/140356.099:INFO:CONSOLE(627)] "%cDEBUG background: #eee; color: #888 Webview(vs_code_release_notes): did post message on 'focus'", source: file:///C:/Users/brianhau/AppData/Local/Programs/Microsoft VS Code/resources/app/out/vs/workbench/workbench.desktop.main.js (627)
[main 2021-05-06T21:03:56.137Z] StorageMainService: closed global storage```
deepak1556 commented 3 years ago

the code --no-sandbox didnt seem to change anything

Are you also unable to open devtools with the flag ? Just to confirm, did you make sure any open instances of vscode was exited before performing the above operation ?

Error occurred in handler for 'GUEST_VIEW_MANAGER_CALL': Error: Invalid guestInstanceId: 3

This is indeed related to webview management but it is very likely just a side-effect of the actual bug which we haven't deduced yet.

Can you also provide the output of code --verbose --vmodule=*/content/*=3,*/component/*=3,*/sandbox/*=3

StanKirilov commented 3 years ago

For me using code --no-sandbox solved the problem and I can see the Markdown Preview on one of my machines (running on VM). On other machines - it doesn't help at all.

deepak1556 commented 3 years ago

On other machines - it doesn't help at all.

@StanKirilov Can you run with code --no-sandbox --user-data-dir <specify-some-absolute-directory-path-here>

ooeygui commented 3 years ago

Hello All, I'm in the Azure Edge Robotics team, maintaining the VSCode extension for ROS. We are hitting this issue as well for our Robot Visualizer. It seems to be related to a move from vscode-resource to https?

For example, we have a workspace rooted at c:\ws\tb, which has sources including stl files. We convert this to a file URI, then to a webview URI. Before the update, it would look something like: vscode-resource://c%3A/ws/tb/src/turtlebot3/turtlebot3_description/meshes/wheels/right_tire.stl

but now looks like this:

https://47c83f32-da7e-4be3-9b90-42735e27223e.vscode-webview-test.com/vscode-resource/file///c%3A/ws/tb/src/turtlebot3/turtlebot3_description/meshes/wheels/right_tire.stl 

The file/// does not look right to me.

mjbvz commented 3 years ago

@ooeygui Split to #123318. This issue about every webview not working

mjbvz commented 3 years ago

@StanKirilov is at MS, so we can ask for more detailed logs/traces if needed. @deepak1556 What would help us investigate this issue?

haugerbr commented 3 years ago

@mjbvz I believe everyone in this thread is at MS so you should be able to get better logs from all of us.

@deepak1556 after checking again the situations are as follows:

  1. Opening VSCode without any flags as admin for my workspace. Webviews crash with Error: Could not register service workers and devtools is unable to be opened.

  2. With code --no-sandbox webviews and devtools both work. I must have had an extra window still open the last time I tried.

  3. After using code --verbose --vmodule=*/content/*=3,*/component/*=3,*/sandbox/*=3 the only error message I see is

    [28328:0509/024035.970:INFO:CONSOLE(627)] "%cDEBUG background: #eee; color: #888 Webview(vs_code_release_notes): did post message on 'focus'", source: file:///C:/Users/brianhau/AppData/Local/Programs/Microsoft VS Code/resources/app/out/vs/workbench/workbench.desktop.main.js (627)

    being posted infinitely.

haugerbr commented 3 years ago

@mjbvz @deepak1556 is there any more information needed?

ashahabov commented 3 years ago

I had a similar issue — .md preview did not work. And I also could not run Chrome Debugger for Angular app. VS Code re-installing helped!

pattarika commented 3 years ago

@haugerbr can you launch with code.cmd --no-sandbox and check if it helps. If not, can you attach the output of code.cmd --verbose

code --no-sandbox works for me but I never have to do it since I have been using vscode (window machine)

GrooveGod commented 3 years ago

code.cmd --no-sandbox Works for me as well under similar constraints.

  • not a local admin on the machine
  • run the app as an admin

code --verbose --vmodule=*/content/*=3,*/component/*=3,*/sandbox/*=3 Occurs on clean install of 1.55.2 and upgrade to 1.56.1; reproducible on clean install of 1.55.2 and upgrade to 1.56.2. Occurs on anything that touches a web view as far as I can tell.

Infinite repeating error as well:

[22552:0514/090525.472:INFO:CONSOLE(627)] "%cDEBUG background: #eee; color: #888 Webview(vs_code_release_notes): did post message on 'focus'", source: file:///C:/Program Files/Microsoft VS Code/resources/app/out/vs/workbench/workbench.desktop.main.js (627)

Notification similar to others' reports.

Error loading webview: Error: Could not register service workers: TypeError: 
  Failed to register a ServiceWorker for scope ('vscode-webview://vs_code_release_notes/') 
  with script ('vscode-webview://vs_code_release_notes/service-worker.js?platform=electron&id=
  vs_code_release_notes&vscode-resource-origin=https%3A%2F%2Fvs_code_release_notes.vscode-webview-test.com'):
  ServiceWorker cannot be started.
rushilShetty commented 3 years ago

I had the same issue, had to re-install VS Code. That seemed to have fix the issue.

haugerbr commented 3 years ago

Reinstalling does not fix it for me however my AppData folder was left intact through the process of reinstalling so it could be related to the fact that it wasn't a clean install.

qianghuang1 commented 3 years ago

I can also reproduce this issue, feel free to ping me via teams to collect my logs: qihuang

shijunti19 commented 3 years ago

When can I get a solution and fix it

irvingzhang0512 commented 3 years ago

Reinstalling couldn't fix this. Waiting for a solution.

guhetier commented 3 years ago

Having the same issue, even release notes cannot be displayed. Reinstalling didn't fix it.

sdabhi23 commented 3 years ago

I am running VSCode in Admin mode on Windows. Given below is the version info:

Version: 1.56.2 (system setup)
Commit: 054a9295330880ed74ceaedda236253b4f39a335
Date: 2021-05-12T17:13:13.157Z
Electron: 12.0.4
Chrome: 89.0.4389.114
Node.js: 14.16.0
V8: 8.9.255.24-electron.0
OS: Windows_NT x64 10.0.18363

Given below is the error I was getting on opening anything with a webview:

Error loading webview: Error: Could not register service workers:
TypeError: Failed to register a ServiceWorker for scope ('vscode-webview://8ba33001-5143-42ce-9f9d-50bfe84a06b8/')
with script ('vscode-webview://8ba33001-5143-42ce-9f9d-50bfe84a06b8/service-worker.js?
platform=electron&id=8ba33001-5143-42ce-9f9d-50bfe84a06b8&
vscode-resource-origin=https%3A%2F%2F8ba33001-5143-42ce-9f9d-50bfe84a06b8.vscode-webview-test.com'):
ServiceWorker cannot be started.

I can confirm that code --no-sandbox fixes it, but slows down the webview rendering significantly.

illgitthat commented 3 years ago

This is tagged as needs-more-info

What type of info is still needed?

Reference : https://github.com/microsoft/vscode/issues/124791

rogererens commented 3 years ago

This also happened to me using a non-administrator zip-based installation when trying to open an existing Jupyter notebook, or running a cell in a new Jupyter-file. The work-around gets me going again.

LupengWang commented 3 years ago

have same issue. I don't think reinstalling can "fix" the issue, it may just not trigger the issue yet after re-installing.

medihack commented 3 years ago

Having also the same problem under Windows, but without running it as Administrator. I am even quite restricted as it is a corporate computer. That's why I am using the .zip edition of VSCode. The previous version (v1.55.2) works fine.

Error loading webview: Error: Could not register service workers: TypeError: Failed to register a ServiceWorker for scope ('vscode-webview://vs_code_release_notes/') with script ('vscode-webview://vs_code_release_notes/service-worker.js?platform=electron&id=vs_code_release_notes&vscode-resource-origin=https%3A%2F%2Fvs_code_release_notes.vscode-webview-test.com'): ServiceWorker cannot be started.

Version: 1.56.2
Commit: 054a9295330880ed74ceaedda236253b4f39a335
Date: 2021-05-12T17:13:13.157Z
Electron: 12.0.4
Chrome: 89.0.4389.114
Node.js: 14.16.0
V8: 8.9.255.24-electron.0
OS: Windows_NT x64 10.0.18363
LupengWang commented 3 years ago

Error loading webview: Error: Could not register service workers: TypeError: Failed to register a ServiceWorker for scope ('vscode-webview://extensioneditor/') with script ('vscode-webview://extensioneditor/service-worker.js?platform=electron&id=extensionEditor&vscode-resource-origin=https%3A%2F%2FextensionEditor.vscode-webview-test.com'): ServiceWorker cannot be started.

Version: 1.56.2 (user setup) Commit: 054a9295330880ed74ceaedda236253b4f39a335 Date: 2021-05-12T17:13:13.157Z Electron: 12.0.4 Chrome: 89.0.4389.114 Node.js: 14.16.0 V8: 8.9.255.24-electron.0 OS: Windows_NT x64 10.0.19041


issue describe:

anytime if open a webview related function(eg. markdown preview, PlantML preview, extensions notes etc.), the issue will happen; and after the issue happened and you close VScode, then

1) sub scenario-1: then next time you open vscode, the whole vscode window is blank, but with right click on vscode icon, you can open a new vscode window and it display normally (still cannot use webview related function) 2) sub scenario -2: use "code.cmd --no-sandbox", the vscode can be opened and display window normally (can use webview related function) ; 3) sub scenario-3: restart the computere, the vscode can be opened and display normal window (still cannot use webview related function) ;

haugerbr commented 3 years ago

I know this is probably expected but just wanted to add that this is still broken in 1.57.0

illgitthat commented 3 years ago

I had actually previously fixed this by uninstalling and reinstalling (1.56.2). After getting the update for 1.57.0, this is now broken again.

mjbvz commented 3 years ago

Also seems to be happening to a few Linux users, see #125993

pvspain commented 3 years ago

@mjbvz I can confirm this has been affecting me across Linux (Ubuntu 20.04.2 LTS), ChromeOS 91.0 (based on Debian 10) and Windows 10 Pro since 1.56.0. I have reverted to the last working version (1.55.2) across all platforms.

pvspain commented 3 years ago

Happy to report symptoms have disappeared on Linux-based platforms on upgrade to VS Code 1.57.0, but still present on Windows 10.

The webview problem was manifesting for me with:

Here are the application stacks for my installations:

Ubuntu 20.04.2 LTS (Focal Fossa) working

Version: 1.57.0
Commit: b4c1bd0a9b03c749ea011b06c6d2676c8091a70c
Date: 2021-06-09T17:18:42.895Z
Electron: 12.0.9
Chrome: 89.0.4389.128
Node.js: 14.16.0
V8: 8.9.255.25-electron.0
OS: Linux x64 5.4.0-74-generic

Chrome OS 91.0.4472.81 (Official Build) (64-bit) working

Version: 1.57.0
Commit: b4c1bd0a9b03c749ea011b06c6d2676c8091a70c
Date: 2021-06-09T17:18:42.895Z
Electron: 12.0.9
Chrome: 89.0.4389.128
Node.js: 14.16.0
V8: 8.9.255.25-electron.0
OS: Linux x64 5.4.109-26077-g12746d86825a

Windows 10 Professional broken

Version: 1.57.0 (system setup)
Commit: b4c1bd0a9b03c749ea011b06c6d2676c8091a70c
Date: 2021-06-09T17:18:42.354Z
Electron: 12.0.9
Chrome: 89.0.4389.128
Node.js: 14.16.0
V8: 8.9.255.25-electron.0
OS: Windows_NT x64 10.0.19041
yydog commented 3 years ago

it is helpful for me! https://stackoverflow.com/questions/67698176/error-loading-webview-error-could-not-register-service-workers-typeerror-fai

cottrell commented 3 years ago

Just a note to say --no-sandbox is no longer available in the newest version and this webview error still persists (particularly in Latex-workshop

$ code --help
Visual Studio Code 1.57.1

Usage: code [options][paths...]

To read from stdin, append '-' (e.g. 'ps aux | grep code | code -')

Options
  -d --diff <file> <file>           Compare two files with each other.
  -a --add <folder>                 Add folder(s) to the last active window.
  -g --goto <file:line[:character]> Open a file at the path on the specified line and character position.
  -n --new-window                   Force to open a new window.
  -r --reuse-window                 Force to open a file or folder in an already opened window.
  -w --wait                         Wait for the files to be closed before returning.
  --locale <locale>                 The locale to use (e.g. en-US or zh-TW).
  --user-data-dir <dir>             Specifies the directory that user data is kept in. Can be used to open multiple distinct instances of Code.
  -h --help                         Print usage.

Extensions Management
  --extensions-dir <dir>                                      Set the root path for extensions.
  --list-extensions                                           List the installed extensions.
  --show-versions                                             Show versions of installed extensions, when using --list-extensions.
  --category <category>                                       Filters installed extensions by provided category, when using --list-extensions.
  --install-extension <extension-id[@version] | path-to-vsix> Installs or updates the extension. The identifier of an extension is always `${publisher}.${name}`. Use `--force` argument to update to latest
                                                              version. To install a specific version provide `@${version}`. For example: 'vscode.csharp@1.2.3'.
  --uninstall-extension <extension-id>                        Uninstalls an extension.
  --enable-proposed-api <extension-id>                        Enables proposed API features for extensions. Can receive one or more extension IDs to enable individually.

Troubleshooting
  -v --version                       Print version.
  --verbose                          Print verbose output (implies --wait).
  --log <level>                      Log level to use. Default is 'info'. Allowed values are 'critical', 'error', 'warn', 'info', 'debug', 'trace', 'off'.
  -s --status                        Print process usage and diagnostics information.
  --prof-startup                     Run CPU profiler during startup.
  --disable-extensions               Disable all installed extensions.
  --disable-extension <extension-id> Disable an extension.
  --sync <on> <off>                  Turn sync on or off.
  --inspect-extensions <port>        Allow debugging and profiling of extensions. Check the developer tools for the connection URI.
  --inspect-brk-extensions <port>    Allow debugging and profiling of extensions with the extension host being paused after start. Check the developer tools for the connection URI.
  --disable-gpu                      Disable GPU hardware acceleration.
  --max-memory <memory>              Max memory size for a window (in Mbytes).
  --telemetry                        Shows all telemetry events which VS code collects.
cottrell commented 3 years ago

And for anyone debugging this, I have downgraded to

1.55.2 3c4e3df9e89829dce27b7b5c24508306b151f30d x64

and the problem seems to no longer be present.

Skywalkess commented 3 years ago

it is helpful for me! https://stackoverflow.com/questions/67698176/error-loading-webview-error-could-not-register-service-workers-typeerror-fai

it is also helpful for me! thank you very much!

on windows just add this startup parameter in the right click-> attribute dialog: image

LupengWang commented 3 years ago

Error loading webview: Error: Could not register service workers: TypeError: Failed to register a ServiceWorker for scope ('vscode-webview://extensioneditor/') with script ('vscode-webview://extensioneditor/service-worker.js?platform=electron&id=extensionEditor&vscode-resource-origin=https%3A%2F%2FextensionEditor.vscode-webview-test.com'): ServiceWorker cannot be started.

Version: 1.56.2 (user setup) Commit: 054a929 Date: 2021-05-12T17:13:13.157Z Electron: 12.0.4 Chrome: 89.0.4389.114 Node.js: 14.16.0 V8: 8.9.255.24-electron.0 OS: Windows_NT x64 10.0.19041

issue describe:

anytime if open a webview related function(eg. markdown preview, PlantML preview, extensions notes etc.), the issue will happen; and after the issue happened and you close VScode, then

  1. sub scenario-1: then next time you open vscode, the whole vscode window is blank, but with right click on vscode icon, you can open a new vscode window and it display normally (still cannot use webview related function)
  2. sub scenario -2: use "code.cmd --no-sandbox", the vscode can be opened and display window normally (can use webview related function) ;
  3. sub scenario-3: restart the computere, the vscode can be opened and display normal window (still cannot use webview related function) ;

I met similiar issues under 1.55.2: I roll back to 1.55.2. and find the same issue happens: if use "code.exe" to run the application, the whole app window is blank, can not do any operation .
use ''code.exe --no-sandbox", it is ok, just like what happened under 1.56 or 1.57.

the difference is, under 1.55.2 I cannot preduce webview issue(few try, didn't spend many effort) because I have no chance to do that ( I either see a total blank window via "code.exe" or see a well-worked environment via "code.exe --no-sandbox".)

So, the issue might be caused by some external component(browser kernel? ) updated in last few months?

Treit commented 3 years ago

I seem to be hitting this error and am wondering what the workaround is on current builds. I am on build 1.57.1 running on Windows 11.

image

The --no-sandbox option does not appear to work any longer (as discussed above, seems it's not a thing now).

Is there any other work-around?