Skip to content

Enable WASM debugging #17162

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

Merged
merged 10 commits into from
Nov 25, 2019
Merged

Enable WASM debugging #17162

merged 10 commits into from
Nov 25, 2019

Conversation

ryanbrandenburg
Copy link
Contributor

Fixes #13902.

Most of this code is from @SteveSandersonMS, I basically only merged it into the blazor-wasm branch, fixed merge problems, then @ajaybhargavb and I proved that it can work.

This currently works with VSCode (with the Chrome Debugging extension) and VS (through a multi-step process of attaching to the process). It does NOT work on the "F5 experience", but my understanding is that that's a tooling issue on the VS side.

Steps for running through this in VSCode:

  1. Install the Chrome debugging extension.
  2. Launch your app in debug mode and navigate to it on a chrome tab with debug on (Ctrl-F5 in VS was how we did it).
  3. In a blazorwasm app create a new debug launch profile of type "Chrome attach".
  4. Launch the profile from above.
  5. Set a breakpoint and take an action which causes it to be hit.

CC @danroth27

@Pilchie Pilchie added the area-blazor Includes: Blazor, Razor Components label Nov 18, 2019
Copy link
Contributor

@pranavkm pranavkm left a comment

Choose a reason for hiding this comment

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

Would you like to demo this feature during the blazor sync up?

{
var request = context.Request;
var requestPath = request.Path;
if (requestPath.StartsWithSegments("/json")
Copy link
Contributor

Choose a reason for hiding this comment

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

@rynowak could this be changed to use endpoint routing?

Copy link
Member

Choose a reason for hiding this comment

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

It could be, but that's a big user-experience change. Let's not blocks this PR on that.

@ryanbrandenburg
Copy link
Contributor Author

Update.

@ryanbrandenburg
Copy link
Contributor Author

🆙📅

if (requestPath.StartsWithSegments("/json")
&& !request.Headers.ContainsKey("User-Agent"))
{
var debuggerHost = "http://localhost:9222";
Copy link
Member

Choose a reason for hiding this comment

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

Eventually we might need to make this port number (and possibly hostname) configurable, but hopefully we will only do that if we find out it's necessary for tooling (e.g., if VS really wants to launch the browser with a nonstandard debugging port). So I'm OK with this as-is for now.

Copy link

Choose a reason for hiding this comment

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

Eventually we might need to make this port number (and possibly hostname) configurable

Wouldn't this fit in launchSettings? I don't know if VS actually picks an unused port to launch IIS Express or simply picks any at random (and might randomly fail), but that seems semantically related.

Copy link
Member

Choose a reason for hiding this comment

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

@chucker This is the port that the browser listens on for debugging, not the port your app runs on. So the correct value depends on how you (or the IDE) started up your browser.

Copy link
Member

@SteveSandersonMS SteveSandersonMS Nov 20, 2019

Choose a reason for hiding this comment

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

@ryanbrandenburg

OK, we've learned now thanks to a meeting with VS and web tools people that we do need to make this into a parameter. We're thinking it should be an environment variable. So:

  • If the environment variable ASPNETCORE_WEBASSEMBLYDEBUGHOST is set, we should use that value for debuggerHost. The value will be something like http://localhost:49573 as an example.
  • Otherwise we keep using http://localhost:9222

Do you think that's a change we could include in this PR?

Update: Sorry @pranavkm for notifying you last time. I got mixed up about which PR this was. I know you're not doing this one!

@SteveSandersonMS SteveSandersonMS self-requested a review November 20, 2019 18:14
Copy link
Member

@SteveSandersonMS SteveSandersonMS left a comment

Choose a reason for hiding this comment

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

Looks great!

@ryanbrandenburg
Copy link
Contributor Author

@SteveSandersonMS can I get you to give one last review to just the latest commit since I had to change behavior somewhat?

@ryanbrandenburg ryanbrandenburg merged commit 03dd93c into blazor-wasm Nov 25, 2019
@ryanbrandenburg ryanbrandenburg deleted the rybrande/WasmDebug branch November 25, 2019 21:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-blazor Includes: Blazor, Razor Components
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants