-
Notifications
You must be signed in to change notification settings - Fork 29.4k
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
Debugging webviews in VS Code #96626
Comments
For now unassigning myself, for features / changes on the VS Code side of course ping me and create corresponding issues. Thanks :) |
Some extra work will be needed on js-debug here. It's not "just" a target -- the target is for the outer webview, and we have an iframe inside of it. But the debugger for the webview is accessible on However, this is asynchronous, and we want to be able to hit breakpoints early on in the code. I would recommend that we run something like this if we see extension host debugging is launched with renderer attachment: let waitingForDebugger = true;
while (waitingForDebugger) { debugger; } We can then hit that and set |
Sorry for hijacking this issue to bring up something else, but if I'm not mistaken, this would/could allow one to attach a puppeteer/playwright client to these webviews and validate the UI, as part of a Smoke Test. |
That's already possible if you launch vs code like we do in the launch.json using |
Oh I need to try that, I didn't know it was possible to inspect webviews in this manner. Thanks |
Looking into this more. Currently when we debug an extension host, we simply vscode/src/vs/code/browser/workbench/workbench.ts Lines 216 to 233 in 2b166d8
This will re-use the same renderer. I think we will either need to:
This will, of course, not work when developing in the browser, since we can't force a running browser into debug mode nor launch a new one from the web |
Turns out there one piece of API missing that Electron does not expose to us. I have opened an issue for this here... extremely annoying electron/electron#24168 I may be able to hack around this if I only attach to a single iframe at once (though I would still be unable to distinguish between the iframe's messages and those of the root session). That involves some deeper changes in the debug adapter. We will see what they say for this. |
Recently several people have asked about wanting to debug the contents webviews in VS Code.
I think is possible if the renderer is launched in debug mode; when debugging VS Code OSS I actually see CDP events for webviews coming down the pipe, e.g
If js-debug was able to attach to the renderer as well, then we should be able to attach to those webviews and debug them natively. There are two things that need to happen for this:
launchVSCode
DAP request, and then we get a subsequent attach request with aport
set to the port of the extension host process. We could have a way to request the renderer to be launched in debug mode in thelaunchVSCode
request, and have arendererPort
or something similar in the attach request./cc @rebornix @eamodio @RMacfarlane as people who have asked for this :)
The text was updated successfully, but these errors were encountered: