-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Webview Doesn't exist in Electron Instance #7156
Comments
I tried using the vscode-extension-samples webview-sample and it also did not work correctly in Electron. When testing it on the browser it worked correctly. |
@akosyakov Any insights about this issue? Did you have the chance to investigate when you self-assigned? I see absolutely no errors anywhere, just a black view, as per the screenshot above. |
@marcdumais-work Unfortunately not, we don't have capacity at TypeFox for it. I think someone who build Electron products should step up here. Important thing that we should not rely on Electron tech. |
I did some quick tests to try and identify the issue and I noticed one anomaly when in electron.
The result is that I see a blank webview on electron. I wonder if the If others have some ideas please don't hesitate to reach out. |
There is a service worker that intercept requests from webview iframe and dispatch to the main window. Could you check that such service worker is running? If not why, if so then you can debug while it does not dispatch. |
Thank you for the pointers @akosyakov, through logging I actually do not see the service-worker running on electron, but it is on the browser. I'll try to investigate further why this is the case. |
I found the following electron limitation regarding service-workers and a corresponding vscode issue:
It looks like electron does not support service workers created with a custom protocol. |
I don’t think it applies to us, we don’t use any electron apis or custom protocols, only standard web apis and iframes. That’s what vs code want to have eventually. |
Did you manage to debug it and see what is the root cause? |
@akosyakov no I wasn't able to successfully debug it and determine the root cause yet. |
@svenefftinge @marcdumais-work @marechal-p I wonder how we should go about security token for iframes? Webview URL is dynamically generated to deploy it on own origin and isolate from the main window context, so it does not have access to cookies and so on. |
@akosyakov write the security cookie in a way that it would be shared across subdomains? |
Webviews are 3rd party remote content. I don’t think we want to let them to access this token. I was wondering about consequences of removing check for them. |
WebViews are contributed by extensions, the same extensions that can access the full nodejs APIs. The token prevents parties that are not part of Theia from accessing the service (via DNS rebinding attacks or other means). But how is VS Code doing? Do they have such mechanism? |
That's true. Could you try to configure a cookie that it works for localhost and its subdomains?
I don't know. Don't think that they have such mechanism. They use electrion APIs and custom protocols, i.e. they don't run web server in Electron. We don't want to go this way because of single sourcing. |
I believe this issue is fixed by a combination of the following merged PRs: |
Description
I'm getting a 404 error when opening a webview vscode extension in an Electron instance of Theia. This only happens in the Electron instance. When I open the webview in the browser, everything works just fine.
Reproduction Steps
I downloaded the latest version of Theia. I then cloned this repo into the plugins folder: https://github.com/leocll/vscode-extension-webview-template (If I loaded with a VSIX, a webview panel wouldn't even open, the extension just did nothing, but I believe it may be an issue with the VSIX he uploaded to the marketplace.) After cloning the repo and running Theia, I ran the command "Example: Webview", which resulted in this:
(Text says: "Not Found. HTTP Error 404. The requested resource is not found" for those that don't like reading black on dark gray text :D)
Thanks for any help you can provide!
The text was updated successfully, but these errors were encountered: