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

WebAssembly Debugging Not Working #17654

Open
BLesnau opened this issue Dec 1, 2024 · 0 comments
Open

WebAssembly Debugging Not Working #17654

BLesnau opened this issue Dec 1, 2024 · 0 comments

Comments

@BLesnau
Copy link

BLesnau commented Dec 1, 2024

Describe the bug

I am building and running a WebAssembly Browser project from Visual Studio. It runs fine without debugging and even when debugging without breakpoints. As soon as I add a breakpoint, the app will no longer load. It gets stuck at the Powered by Avalonia screen. It is the same behavior with Chrome, Edge, and IE.

I tried turning on all experimental features related to WebAssembly in Chrome with no changes to the result. I saw information online about needing to enable WebAssembly debugging in Chrome, but it sounds like that is enabled by default now. I also reproduced the problem with a default project from the Avalonia templates with no modifications of my own.

It's possible that I am just missing something that I need to do to make this work. I tried going to the debug URLs like https://localhost:7169/_framework/debug that show up in the terminal, and I did get exceptions unrelated to my code. That URL had me run a command like this to enable debugging.

chrome --remote-debugging-port=9222 --user-data-dir="C:\Users\lesna\AppData\Local\Temp\blazor-chrome-debug"

This was the exception output

Debug at url: https://localhost:7169/_framework/debug
warn: Microsoft.AspNetCore.Watch.BrowserRefresh.BrowserRefreshMiddleware[3]
Unable to configure browser refresh script injection on the response. Consider manually adding '<script src="/_framework/aspnetcore-browser-refresh.js"></script>' to the body of the page.
warn: Microsoft.AspNetCore.Watch.BrowserRefresh.BrowserRefreshMiddleware[3]
Unable to configure browser refresh script injection on the response. Consider manually adding '<script src="/_framework/aspnetcore-browser-refresh.js"></script>' to the body of the page.
[22:31:19] fail: DevToolsProxy[0]
DevToolsProxy.Run: System.Net.WebSockets.WebSocketException (0x80004005): The server returned status code '500' when status code '101' was expected.
at System.Net.WebSockets.WebSocketHandle.ValidateResponse(HttpResponseMessage response, String secValue)
at System.Net.WebSockets.WebSocketHandle.ConnectAsync(Uri uri, HttpMessageInvoker invoker, CancellationToken cancellationToken, ClientWebSocketOptions options)
at System.Net.WebSockets.ClientWebSocket.ConnectAsyncCore(Uri uri, HttpMessageInvoker invoker, CancellationToken cancellationToken)
at Microsoft.WebAssembly.Diagnostics.DevToolsProxy.RunForDevTools(Uri browserUri, WebSocket ideSocket, CancellationTokenSource cts)
[22:31:19] fail: Microsoft.WebAssembly.Diagnostics.Startup[0]
Failed to start proxy: System.Net.WebSockets.WebSocketException (0x80004005): The server returned status code '500' when status code '101' was expected.
at System.Net.WebSockets.WebSocketHandle.ValidateResponse(HttpResponseMessage response, String secValue)
at System.Net.WebSockets.WebSocketHandle.ConnectAsync(Uri uri, HttpMessageInvoker invoker, CancellationToken cancellationToken, ClientWebSocketOptions options)
at System.Net.WebSockets.ClientWebSocket.ConnectAsyncCore(Uri uri, HttpMessageInvoker invoker, CancellationToken cancellationToken)
at Microsoft.WebAssembly.Diagnostics.DevToolsProxy.RunForDevTools(Uri browserUri, WebSocket ideSocket, CancellationTokenSource cts)
at Microsoft.WebAssembly.Diagnostics.DebugExtensions.<>c__DisplayClass3_0.<g__ConnectProxy|5>d.MoveNext()
[22:31:19] fail: Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware[1]
An unhandled exception has occurred while executing the request.
System.InvalidOperationException: StatusCode cannot be set because the response has already started.
at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpProtocol.ThrowResponseAlreadyStartedException(String value)
at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpProtocol.set_StatusCode(Int32 value)
at Microsoft.WebAssembly.Diagnostics.DebugExtensions.<>c__DisplayClass3_0.<g__ConnectProxy|5>d.MoveNext()
--- End of stack trace from previous location ---
at Microsoft.AspNetCore.Builder.RouterMiddleware.Invoke(HttpContext httpContext)
at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddlewareImpl.Invoke(HttpContext context)
[22:31:19] warn: Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware[2]
The response has already started, the error page middleware will not be executed.
[22:31:19] fail: Microsoft.AspNetCore.Server.Kestrel[13]
Connection id "0HN8HN24KVDVQ", Request id "0HN8HN24KVDVQ:00000001": An unhandled exception was thrown by the application.
System.InvalidOperationException: StatusCode cannot be set because the response has already started.
at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpProtocol.ThrowResponseAlreadyStartedException(String value)
at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpProtocol.set_StatusCode(Int32 value)
at Microsoft.WebAssembly.Diagnostics.DebugExtensions.<>c__DisplayClass3_0.<g__ConnectProxy|5>d.MoveNext()
--- End of stack trace from previous location ---
at Microsoft.AspNetCore.Builder.RouterMiddleware.Invoke(HttpContext httpContext)
at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddlewareImpl.Invoke(HttpContext context)
at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddlewareImpl.Invoke(HttpContext context)
at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpProtocol.ProcessRequests[TContext](IHttpApplication`1 application)

C:\Program Files\dotnet\dotnet.exe (process 21100) exited with code 0 (0x0).
To automatically close the console when debugging stops, enable Tools->Options->Debugging->Automatically close the console when debugging stops.

I am on the latest or almost latest version of both Avalonia and Visual Studio. I am using .NET 9.

To Reproduce

  • Create a new AvaloniaUI project with the templates
  • Debug or run without debugging and see that it runs the app as expected
  • Add a breakpoint anywhere and debug again.
  • The web page opens and gets stuck at the Powered By Avalonia screen

Expected behavior

Debugging with breakpoints should work and you should see the breakpoints be hit.

Avalonia version

11.2.1

OS

WebAssembly

Additional context

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants