Change:
<!-- Do Not Delete This! bugreporttemplate --<!-- Please read our Rules of Conduct: --<!-- Read our guide about submitting issues: --<!-- Search existing issues to avoid creating duplicates. --<!-- Test using the latest Insiders build to see if your issue has already been fixed: --<!-- Instead of creating your report here, use 'Report Issue' from the 'Help' menu in VS Code to pre-fill useful information. --<!-- Launch with to check. --Does this issue occur when all extensions are disabled?: No <!-- If you answered No above, use 'Help: Start Extension Bisect' from Command Palette to try to identify the cause. --<!-- Issues caused by an extension need to be reported directly to the extension publisher. The 'Help Report Issue' dialog can assist with this. --- VS Code Version: 1.77.1 OS Version: All Steps to Reproduce: This is not a problem in the extension, the extension code is the same, but a commit changes the way webviews are loaded and it's breaking it. This commit: Has introduced a regression that makes my extension unusable. It introduces a problem on webviews in which workers are not available, and causes the following errors in the console: Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'active') at I have been tracking all changes since 1.76.2 release, building VSCode myself, and setting the build to the previous commit, my webview works flawlessly, if I checkout this commit, it's totally broken. I have not been able to send you are reproducible test case, but if interested, I can show you a video on how to use my extension, so you can check for yourself the issue. Thanks!
To add more information, check these two videos: Not working scenario, with the code at 1.77.1: ! Working scenario at the commit previous to the one I mention. Just remark that checking out the code at the commit I'm pointing, causes the not working scenario: !
Sorry you are running into this. Do you have an extension you can share that shows this issue? I can't simply revert the change because it was made to fix an hang with webviews opening. If I can repo this locally though, I can try to investigate
Thanks for checking this one! My extension is this one: Find attached a sample project: These are the steps: Install the extension Unzip in its own folder Open the folder with VSCode With selected, issue the command Toggle Design/Code This will open up the webview, and with the changes, you could see in the console the issues Find here a video with the steps on how to open the webview, and the behavior when its working: ! Thanks!
Needless to say that if I should perform any changes on the extension to make it work, it's not a problem at all. That is, if I can get an idea on what the changes are, have no problem on that. :-) Thanks!
Thanks for the repo steps I have a potential Please try the next VS Code insiders build that comes out and let me know if you still see the problem. With the fix, things seem to be loading correctly: <img width="1129" alt="Screenshot 2023-04-12 at 4 06 24 PM" src="https://user-"
Checked insiders, but not sure if the fix got through, as I see some checks failed: ! Also tried update from the repository, and it seems still is not merged. In any case, what I see in your shot is that the Tool Palette is missing content. The content is provided by loading an external file called "" and it seems the webview is not able to load it: ! Will keep checking, THANKS!
ignore my last message, I have merged your changes locally and works perfect! So once this is merged, consider the issue fixed, thanks a lot!! !
<!-- AUTHORVERIFICATIONREQUEST --This bug has been fixed in the latest release of ! you can help us out by commenting if things are now working as expected. If things still don't seem right, please ensure you're on version of Insiders (today's or later - you can use in the command palette to check), and leave a comment letting us know what isn't working as expected. Happy Coding!
/verified

Discussion:
// service worker already loaded & ready to receive messages postVersionMessage(currentController); } else { <del> console.log(`Found unexpected service worker controller. Found: ${currentController?.scriptURL}. Expected: ${swPath}`); </del> <ins> if (currentController) { console.log(`Found unexpected service worker controller. Found: ${currentController.scriptURL}. Expected: ${swPath}. Waiting for controllerchange.`); } else { console.log(`No service worker controller found. Waiting for controllerchange.`); } </ins> <del> // either there's no controlling service worker, or it's an old one: // wait for it to change before posting the message </del> <ins> // Either there's no controlling service worker, or it's an old one. // Wait for it to change before posting the message </ins> const onControllerChange = () => { navigator.serviceWorker.removeEventListener('controllerchange', onControllerChange); <ins> if (navigator.serviceWorker.controller) { </ins> postVersionMessage(navigator.serviceWorker.controller); <ins> } else { return reject(new Error('No controller found.')); } </ins> }; navigator.serviceWorker.addEventListener('controllerchange', onControllerChange); }

if (!disableServiceWorker) { hostMessaging.onMessage('did-load-resource', (_event, data) => { <del> navigator.serviceWorker.getRegistration().then(registration => { assertIsDefined(registration.active).postMessage({ channel: 'did-load-resource', data }, data.data?.buffer ? [data.data.buffer] : []); </del> <ins> assertIsDefined(navigator.serviceWorker.controller).postMessage({ channel: 'did-load-resource', data }, data.data?.buffer ? [data.data.buffer] : []); </ins> }); <del> }); </del> hostMessaging.onMessage('did-load-localhost', (_event, data) => { <del> navigator.serviceWorker.getRegistration().then(registration => { assertIsDefined(registration.active).postMessage({ channel: 'did-load-localhost', data }); </del> <ins> assertIsDefined(navigator.serviceWorker.controller).postMessage({ channel: 'did-load-localhost', data }); </ins> }); <del> }); </del> navigator.serviceWorker.addEventListener('message', event => { switch (event.data.channel) {

<meta charset="UTF-8"> <meta http-equiv="Content-Security-Policy" <del> content="default-src 'none'; script-src 'sha256-p+nt+yoC/wuG5etLfVS00qSeblDcYdehfpOYYqdWocI=' 'self'; frame-src 'self'; style-src 'unsafe-inline';"> </del> <ins> content="default-src 'none'; script-src 'sha256-7T0Xm7l4AYKDwm8oYNQ65wcQX7K/ndvxH/2ZgHWUE3w=' 'self'; frame-src 'self'; style-src 'unsafe-inline';"> </ins> <!-- Disable pinch zooming --> <meta name="viewport"

// service worker already loaded & ready to receive messages postVersionMessage(currentController); } else { <del> console.log(`Found unexpected service worker controller. Found: ${currentController?.scriptURL}. Expected: ${swPath}`); </del> <ins> if (currentController) { console.log(`Found unexpected service worker controller. Found: ${currentController.scriptURL}. Expected: ${swPath}. Waiting for controllerchange.`); } else { console.log(`No service worker controller found. Waiting for controllerchange.`); } </ins> <del> // either there's no controlling service worker, or it's an old one: // wait for it to change before posting the message </del> <ins> // Either there's no controlling service worker, or it's an old one. // Wait for it to change before posting the message </ins> const onControllerChange = () => { navigator.serviceWorker.removeEventListener('controllerchange', onControllerChange); <del> postVersionMessage(navigator.serviceWorker.controller); </del> <ins> if (navigator.serviceWorker.controller) { postVersionMessage(navigator.serviceWorker.controller); } else { return reject(new Error('No controller found.')); } </ins> }; navigator.serviceWorker.addEventListener('controllerchange', onControllerChange); }

if (!disableServiceWorker) { hostMessaging.onMessage('did-load-resource', (_event, data) => { <del> navigator.serviceWorker.getRegistration().then(registration => { assertIsDefined(registration.active).postMessage({ channel: 'did-load-resource', data }, data.data?.buffer ? [data.data.buffer] : []); }); </del> <ins> assertIsDefined(navigator.serviceWorker.controller).postMessage({ channel: 'did-load-resource', data }, data.data?.buffer ? [data.data.buffer] : []); </ins> }); hostMessaging.onMessage('did-load-localhost', (_event, data) => { <del> navigator.serviceWorker.getRegistration().then(registration => { assertIsDefined(registration.active).postMessage({ channel: 'did-load-localhost', data }); }); </del> <ins> assertIsDefined(navigator.serviceWorker.controller).postMessage({ channel: 'did-load-localhost', data }); </ins> }); navigator.serviceWorker.addEventListener('message', event => {