Skip to content

Conversation

@pavelsavara
Copy link
Member

@pavelsavara pavelsavara commented Oct 22, 2025

work in progress:

  • -sEXIT_RUNTIME=0 for coreRun too
  • don't call coreclr_shutdown2_func in coreRun/browserHost
  • new AsyncHelpers.Browser.cs with
    • ExecuteAsyncEntryPoint that would call SystemJS_RejectMainPromise or SystemJS_ResolveMainPromise
  • change Assembly::GetEntryPoint to find original async Main()
    • the roslyn wrapper contains blocking TaskAwaiter<int>.GetResult() which is not possible on ST browser.
    • use MemberLoader::FindMethodByName by original name, but ignoring return type
  • change ValidateMainMethod to allow for signatures with Task or Task<int>
    • detect new CorEntryPointType.EntryManagedMainAsync and CorEntryPointType.EntryManagedMainAsyncVoid
  • new SystemJS_ExecuteTimerCallback and SystemJS_ExecuteBackgroundJobCallback
    • ideally this would be [UnmanagedCallersOnly]
    • into src\coreclr\vm\wasm\helpers.cpp and src\coreclr\vm\corelib.h for now

Fixes #120212
Fixes #120211
Fixes #121046

This work with the PR

public static async Task<int> Main()
{
    Console.WriteLine("Hello, World! " + DateTime.Now);
    await Task.Delay(1000);
    Console.WriteLine("After Task.Delay() " + DateTime.Now);
    return 42;
}

TODO

  • implement and test also Task Main() of void signature.
  • make sure that synchronous main still works
  • test exception marshaling
  • fix browserHost
  • test Release version JS name mangling
  • process commandline args

@pavelsavara pavelsavara added this to the 11.0.0 milestone Oct 22, 2025
@pavelsavara pavelsavara self-assigned this Oct 22, 2025
@pavelsavara pavelsavara added arch-wasm WebAssembly architecture area-System.Threading os-browser Browser variant of arch-wasm labels Oct 22, 2025
@build-analysis build-analysis bot mentioned this pull request Oct 31, 2025
3 tasks
@pavelsavara
Copy link
Member Author

is there more feedback ?

…erServices/AsyncHelpers.NonBrowser.cs

Co-authored-by: Aaron R Robinson <[email protected]>
pavelsavara and others added 4 commits November 3, 2025 18:26
…erServices/AsyncHelpers.NonBrowser.cs

Co-authored-by: Aaron R Robinson <[email protected]>
…erServices/AsyncHelpers.NonBrowser.cs

Co-authored-by: Aaron R Robinson <[email protected]>
Co-authored-by: Aaron R Robinson <[email protected]>
Co-authored-by: Aaron R Robinson <[email protected]>
Copy link
Contributor

@gewarren gewarren left a comment

Choose a reason for hiding this comment

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

Left some doc suggestions.

@jkotas
Copy link
Member

jkotas commented Nov 3, 2025

LGTM (the parts that I understand). Somebody with understanding of the JavaScript layer should review and signoff on that part.

@pavelsavara
Copy link
Member Author

/ba-g CI timeouts and #114924

@pavelsavara pavelsavara merged commit 8dbf912 into dotnet:main Nov 4, 2025
147 of 156 checks passed
@pavelsavara pavelsavara deleted the browser_async_main branch November 4, 2025 17:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

arch-wasm WebAssembly architecture area-System.Threading os-browser Browser variant of arch-wasm

Projects

None yet

8 participants