Skip to content

Theme images on the welcome page are broken #4483

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

Closed
jsjoeio opened this issue Nov 10, 2021 · 6 comments
Closed

Theme images on the welcome page are broken #4483

jsjoeio opened this issue Nov 10, 2021 · 6 comments
Assignees
Labels
bug Something isn't working

Comments

@jsjoeio
Copy link
Contributor

jsjoeio commented Nov 10, 2021

Introduced in #4414

@code-asher may have more details.

@jsjoeio jsjoeio added the bug Something isn't working label Nov 10, 2021
@jsjoeio jsjoeio mentioned this issue Nov 10, 2021
46 tasks
@jsjoeio jsjoeio self-assigned this Nov 10, 2021
@code-asher
Copy link
Member

code-asher commented Nov 10, 2021

To test:

  1. Open the "Get Started" sub-page (can get there from the main welcome page)
  2. Make sure you are on the first step ("choose the look you want")
  3. Observe broken images

The images do exist and you can open them manually so it is unclear why they fail to load.

@jsjoeio
Copy link
Contributor Author

jsjoeio commented Nov 12, 2021

I will probably pick this up Monday or Tuesday (might not have time today).

@jsjoeio
Copy link
Contributor Author

jsjoeio commented Nov 12, 2021

Verified this is still an issue

image

Errors observed in the console:
image

index.html:1 Mixed Content: The page at 'https://d9385a7a-36ed-4047-9202-43fc2176f639.vscode-webview.net/insider/dc1a6699060423b8c4d2ced736ad70195378fddf/out/vs/workbench/contrib/webview/browser/pre/index.html?id=d9385a7a-36ed-4047-9202-43fc2176f639&swVersion=2&extensionId=&platform=browser&vscode-resource-base-authority=vscode-resource.vscode-webview.net&parentOrigin=http%3A%2F%2Flocalhost%3A8080' was loaded over HTTPS, but requested an insecure element 'http://localhost:8080/static/out/vs/workbench/contrib/welcome/gettingStarted/common/media/light.png'. This request was automatically upgraded to HTTPS, For more information see https://blog.chromium.org/2019/10/no-more-mixed-messages-about-https.html
index.html:1 Mixed Content: The page at 'https://d9385a7a-36ed-4047-9202-43fc2176f639.vscode-webview.net/insider/dc1a6699060423b8c4d2ced736ad70195378fddf/out/vs/workbench/contrib/webview/browser/pre/index.html?id=d9385a7a-36ed-4047-9202-43fc2176f639&swVersion=2&extensionId=&platform=browser&vscode-resource-base-authority=vscode-resource.vscode-webview.net&parentOrigin=http%3A%2F%2Flocalhost%3A8080' was loaded over HTTPS, but requested an insecure element 'http://localhost:8080/static/out/vs/workbench/contrib/welcome/gettingStarted/common/media/dark.png'. This request was automatically upgraded to HTTPS, For more information see https://blog.chromium.org/2019/10/no-more-mixed-messages-about-https.html
index.html:1 Mixed Content: The page at 'https://d9385a7a-36ed-4047-9202-43fc2176f639.vscode-webview.net/insider/dc1a6699060423b8c4d2ced736ad70195378fddf/out/vs/workbench/contrib/webview/browser/pre/index.html?id=d9385a7a-36ed-4047-9202-43fc2176f639&swVersion=2&extensionId=&platform=browser&vscode-resource-base-authority=vscode-resource.vscode-webview.net&parentOrigin=http%3A%2F%2Flocalhost%3A8080' was loaded over HTTPS, but requested an insecure element 'http://localhost:8080/static/out/vs/workbench/contrib/welcome/gettingStarted/common/media/monokai.png'. This request was automatically upgraded to HTTPS, For more information see https://blog.chromium.org/2019/10/no-more-mixed-messages-about-https.html
light.png:1 Failed to load resource: net::ERR_FAILED
dark.png:1 Failed to load resource: net::ERR_FAILED
monokai.png:1 Failed to load resource: net::ERR_FAILED

@jsjoeio jsjoeio self-assigned this Nov 16, 2021
@jsjoeio
Copy link
Contributor Author

jsjoeio commented Nov 16, 2021

Notes

Do the files exist?

When the images fail to load, the first question we ask is, "Do the images exist in the locations we expect them to exist?"

In upstream, they live here.

Looking at our fork, we see them here.

✅ Files exist (at least in the correct place).

Do the files exist in the build output?

When we run yarn watch, we create an /out directory. Let's check if they exist there.

I found this here: vscode/out/vs/workbench/contrib/welcome/gettingStarted/common/media/light.png 🤔

But when we look at the source code using the browser tools, it's clearly missing:

image

This makes me believe that the file exists in the source code but not the build output 🤔

pair-programming

@code-asher the iframe which loads these images uses some Microsoft domain which may be related?

It could also be the HTTP/HTTPS mismatch. It's weird cause it loads in Chrome, but fails in Brave/Safari as well.

HTTP vs. HTTPS

We figured it out! The images are served via http locally, but the iframe expects https so due to the mismatch, the browser says, "Not today" and refuses to serve our images. We figured this out by using localtunnel which serves a localhost address over HTTPS. When you do this, the images load.

image

The solution? Make the iframe src match the current URL.

@jsjoeio
Copy link
Contributor Author

jsjoeio commented Nov 16, 2021

(this would break for airgapped users so good thing we are fixing it)

Notes on Solution

Looking at vscode/src/vs/server/webClientServer.ts around L303, we want to use the webviewEndpoint but when we do, the iframe is blank 🤔

iframe src lives in vscode/src/vs/workbench/contrib/webview/browser/webviewElement.ts on L431 and it uses:
this.webviewContentEndpoint<- this._environmentService.webviewExternalEndpoint <- uses this:

const endpoint = this.options.webviewEndpoint
			|| this.productService.webviewContentExternalBaseUrlTemplate
			|| 'https://{{uuid}}.vscode-webview.net/{{quality}}/{{commit}}/out/vs/workbench/contrib/webview/browser/pre/';

We think it might expect a unique service worker for each path.

Asher thinks we should create a new endpoint, webview with a uuid and serve the file.

Asher found a fix for this - using a unique service worker for each web view.

@jsjoeio
Copy link
Contributor Author

jsjoeio commented Nov 22, 2021

Fixed via coder/vscode#16

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants