Skip to content
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

debug: try to wait for a debugger before running extensions #108141

Merged
merged 2 commits into from
Oct 7, 2020

Conversation

connor4312
Copy link
Member

Fixes #106698
Fixes #99222

See discussion here: #106698 (comment). This is the same problem we were facing on the web previously, so I implemented it in a way which will solve both.

Most of the changes here are piping data around and adding it to environments. I added a separate debugExpected from just the isExtensionDevelopmentDebug, since isExtensionDevelopmentDebug is true whenever a debugging is enabled at all, which includes running ./scripts/code-cli -- using that as the "wait" signal would cause code-cli to take an extra 5 seconds to run extensions.

Tagging Joh for review seems like you've been touching much of this code most recently according to gitlens.

@connor4312 connor4312 self-assigned this Oct 5, 2020
@connor4312 connor4312 added this to the October 2020 milestone Oct 5, 2020
@connor4312
Copy link
Member Author

CI failure is an existing issue in master

connor4312 added a commit to microsoft/vscode-js-debug that referenced this pull request Oct 5, 2020
@jrieken jrieken requested review from bpasero and alexdima and removed request for jrieken October 6, 2020 07:27
Copy link
Member

@bpasero bpasero left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I could not really figure out the purpose of the new arguments. One thing to keep in mind is that we should check if the properties need to be unset or changed when the window reloads, similar to this code:

// Some configuration things get inherited if the window is being reloaded and we are
// in extension development mode. These options are all development related.
if (this.isExtensionDevelopmentHost && cli) {
configuration.verbose = cli.verbose;
configuration['inspect-extensions'] = cli['inspect-extensions'];
configuration['inspect-brk-extensions'] = cli['inspect-brk-extensions'];
configuration.debugId = cli.debugId;
configuration['extensions-dir'] = cli['extensions-dir'];
}

src/vs/code/electron-main/window.ts Outdated Show resolved Hide resolved
src/vs/code/electron-main/window.ts Outdated Show resolved Hide resolved
src/vs/platform/environment/common/argv.ts Outdated Show resolved Hide resolved
Copy link
Member

@alexdima alexdima left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have reviewed the changes in the extension host area.

I would make extHost.protocol.ts -> IEnvironment.debugExpected an optional argument and only set it for the web worker extension host. I believe that is the one that needs this special treatment, since the other extension hosts are nodejs based and can be launched with --inspect-brk and do not need this mechanism.

@connor4312
Copy link
Member Author

Thanks for the reviews!

It looks like in node-debug2 uses --inspect-brk-extensions, but in js-debug at one point (probably while initially getting extension host dev working) that was changed for --inspect-extensions -- fixing that should fix the debugging in web scenario, and then I can remove the unnecessary generalization here.

@connor4312 connor4312 force-pushed the connor4312/wait-for-ext-host-debugger branch from 5e09c47 to 827241e Compare October 6, 2020 15:29
@connor4312
Copy link
Member Author

One thing to keep in mind is that we should check if the properties need to be unset or changed when the window reloads

thanks for the callout -- it looks like debugRenderer is still in the configuration in that case, and we will not need to unset it as users cannot detach from the renderer without ending the debug session.

Copy link
Member

@alexdima alexdima left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 The changes in extHostExtensionService.ts and webWorkerExtensionHost.ts look good to me.

Copy link
Member

@bpasero bpasero left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One thing to consider is to rename debugRenderer to extensionDebugRenderer if this is only for extension debugging. That way we keep the properties grouped together that belong to extension debug.

@connor4312
Copy link
Member Author

this is only for extension debugging

It's also used for debugging webviews. But, VS Code does not know whether the debugger will attach to webviews, extensions or both, it's only asked to expose the renderer.

@bpasero
Copy link
Member

bpasero commented Oct 7, 2020

@connor4312 I see. I feel renderer is a term that Electron/Chrome introduces. Maybe we find a better more generic name or is this really only specific to Electron renderers?

@connor4312
Copy link
Member Author

It's specific to electron renderers. In web we can never debug the 'renderer', as a tab cannot start another tab in debug mode.

In theory if running serverful web locally we could actually launch a debugged browser instance on the desktop, but this is probably not worth doing...

@connor4312 connor4312 merged commit 8085054 into master Oct 7, 2020
@connor4312 connor4312 deleted the connor4312/wait-for-ext-host-debugger branch October 7, 2020 15:58
@github-actions github-actions bot locked and limited conversation to collaborators Dec 4, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
3 participants