Skip to content

[wasm-ep] Use DOTNET_DiagnosticPorts to configure Diagnostic Server #73370

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 5 commits into from
Aug 8, 2022

Conversation

lambdageek
Copy link
Member

@lambdageek lambdageek commented Aug 4, 2022

Parse it the same way that the C code does:

   <uri>[,<connect|listen>][,<suspend|nosuspend>]
  • uri should be a websocket uri
  • listen is not supported as it doesn't make sense with a WebSocket
  • connect is the default if omitted
  • suspend is the default if omitted

Additionally, move mono_wasm_diagnostics_init to later in the
startup flow. This gives Blazor a chance to set
DOTNET_DiagnosticPorts from their onRuntimeInitialized callback.
An unfortunate problem here is that blazor and non-blazor startup need to call diagnostics init from different places because of how environment variables are populated. So we try to init diagnostics twice and set a flag.

Fixes #73011

@ghost
Copy link

ghost commented Aug 4, 2022

Tagging subscribers to 'arch-wasm': @lewing
See info in area-owners.md if you want to be subscribed.

Issue Details

Parse it the same way that the C code does:

   <uri>[,<connect|listen>][,<suspend|nosuspend>]
  • uri should be a websocket uri
  • listen is not supported as it doesn't make sense with a WebSocket
  • connect is the default if omitted
  • suspend is the default if omitted

Additionally, move mono_wasm_diagnostics_init to later in the
startup flow. This gives Blazor a chance to set
DOTNET_DiagnosticPorts from their onRuntimeInitialized callback.

Fixes #73011

Author: lambdageek
Assignees: lambdageek
Labels:

arch-wasm, area-System.Runtime.InteropServices.JavaScript

Milestone: -

@lambdageek lambdageek added this to the 7.0.0 milestone Aug 4, 2022
@@ -329,6 +331,10 @@ async function mono_wasm_after_user_runtime_initialized(): Promise<void> {

if (runtimeHelpers.diagnosticTracing) console.debug("MONO_WASM: Initializing mono runtime");

if (MonoWasmThreads) {
Copy link
Member

Choose a reason for hiding this comment

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

maybe you could now move it earlier in the startup, just after beforeOnRuntimeInitialized.promise_control.resolve. but I'm not sure it's useful.

Copy link
Member Author

Choose a reason for hiding this comment

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

I'll move it. the only hard requirement is that the diagnostic server has to start before we call into driver.c to start the root domain initialization. Starting later is better

Copy link
Member Author

Choose a reason for hiding this comment

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

Ah, there's an annoying problem here. In the non-Blazor startup we don't set environment variables until _apply_configuration_from_args. So actually I have to try to init diagnostics in two places.

@pavelsavara
Copy link
Member

Please also update src\mono\sample\wasm\browser-eventpipe\main.js to use the env variable
Ideally also replacing BINDING.bind_static_method with [JSExport]
or is @maraf already looking at that ?

@maraf
Copy link
Member

maraf commented Aug 4, 2022

Ideally also replacing BINDING.bind_static_method with [JSExport]
or is @maraf Marek Fisera FTE already looking at that ?

Rewrite to JSExport is here #73367

@lambdageek
Copy link
Member Author

@pavelsavara @maraf I'd like to get #73305 in before this one. I can't really test what's here until that other PR goes on.

@maraf I think I want to delete of browser-mt-eventpipe. It was just a proof of concept. browser-eventpipe is good (and i'll update it to use DOTNET_DiagnosticPorts) and the new browser-threads in #73305 is good. Both of them should be able to run in CI, I think. browser-mt-eventpipe isn't really needed.

@lambdageek

This comment was marked as outdated.

@azure-pipelines

This comment was marked as outdated.

lambdageek and others added 4 commits August 7, 2022 14:50
Parse it the same way that the C code does:

```
   <uri>[,<connect|listen>][,<suspend|nosuspend>]
```

- uri should be a websocket uri
- listen is not supported as it doesn't make sense with a WebSocket
- connect is the default if omitted
- suspend is the default if omitted

---

Additionally, move `mono_wasm_diagnostics_init` to later in the
startup flow.  This gives Blazor a chance to set
DOTNET_DiagnosticPorts from their `onRuntimeInitialized` callback.

Fixes dotnet#73011
…lazor

It has to be after environment variables are set, but before
mono_wasm_load_runtime is called.

There is no good place that's common to both startup paths. Try it on
both.  Use a flag to make diagnostics initialization run at most
once
@lambdageek
Copy link
Member Author

/azp run runtime-wasm

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

1 similar comment
@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@lambdageek lambdageek requested review from pavelsavara and maraf August 8, 2022 13:14
@lambdageek
Copy link
Member Author

/azp run runtime-wasm

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

export async function mono_wasm_init_diagnostics(options: DiagnosticOptions): Promise<void> {
let diagnosticsInitialized = false;

export async function mono_wasm_init_diagnostics(opts: "env" | DiagnosticOptions): Promise<void> {
Copy link
Member

Choose a reason for hiding this comment

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

is the signature with DiagnosticOptions param type still useful ?

Copy link
Member Author

Choose a reason for hiding this comment

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

No. I want to do a follow up PR to simplify more of the diagnostics support. removing this argument is just one piece.

@lambdageek lambdageek merged commit 89db9c0 into dotnet:main Aug 8, 2022
@ghost ghost locked as resolved and limited conversation to collaborators Sep 7, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
arch-wasm WebAssembly architecture area-Diagnostics-mono
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[wasm-ep] Configure the Diagnostic Server using DOTNET_DiagnosticPorts
3 participants