Closed
Description
In order to make diagnostics work with Blazor, we need to provide a mechanism that works with their WebAssebly startup sequence (near here: MonoPlatform.ts). Using a MonoConfig
diagnostic_options
section doesn't work because they don't have this object. Additionally the current call to mono_wasm_init_diagnostics
is in mono_wasm_before_user_runtime_initialized
which is not called for Blazor.
The other constraint is that mono_wasm_init_diagnostics
is async (because it waits for the DS thread to start), so we need to call it during an async part of runtime startup.
So the task is:
- Use the
DOTNET_DiagnosticPorts
environment variable to configure the diagnostic server - similar to desktop. Setting it to a value likews://127.0.0.1:8088/diagnostics,connect,suspend
will cause the runtime to connect to the given WebSocket URL and suspend until a diagnostic tool sends a resume command. We will only supportconnect
, notlisten
(which is not meaningful for a websocket). We will supportsuspend
(the default) andnosuspend
- Blazor can setenv
DOTENT_DiagnosticPorts
from theironRuntimeInitialized
callback - Move the call to
await mono_wasm_init_diagnostics()
tomono_wasm_after_user_runtime_initialized
which is async and runs afteronRuntimeInitialized
but before we call Blazor'spostRun
(which callsMONO.mono_wasm_load_runtime
which is a sync function that actually begins running our C code - ie we must have the diagnostic server running by this point)