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

[browser][MT] dedicated io thread #99422

Merged
merged 9 commits into from
Mar 14, 2024

Conversation

pavelsavara
Copy link
Member

@pavelsavara pavelsavara commented Mar 7, 2024

  • dispatch Task resolve/reject to dedicated managed I/O thread and continuations to managed ThreadPool
  • allow blocking .Wait on deputy thread in async methods, async JSExport, C# Main()
  • keep throwing PNSE inside synchronous JSExport or callback

changes

  • new JSThreadBlockingMode.AllowBlockingWaitInAsyncCode, make it default
  • ToManaged(Task) creates Task with TaskCreationOptions.RunContinuationsAsynchronously
  • mono_wasm_create_io_thread, mono_wasm_register_io_thread, mono_wasm_start_io_thread_async
  • dispatch Promise/Task resolution to I/O Thread
  • dispatch release_js_owned_object_by_gc_handle to I/O thread from UI thread
  • call BeforeSyncJSExport and AfterSyncJSExport also on JSWebWorker (same thread)
  • fix ConfigureAwait(true) in HTTP client
  • add mono_wasm_print_thread_dump to INTERNAL

tests

  • WaitDoesNotAssertInAsyncCode <-- this is why we do this!
  • WaitAssertsOnSyncCallback
  • WaitAssertsOnSyncJSExport
  • _XUnitBackgroundExec not default, we don't need it anymore because blocking is fine!
  • delete System.Runtime.InteropServices.JavaScript.BackgroundExec.Tests

new active issues

@pavelsavara
Copy link
Member Author

/azp run runtime-wasm

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@pavelsavara
Copy link
Member Author

/azp run runtime-wasm

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@pavelsavara
Copy link
Member Author

/azp run runtime-wasm

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@pavelsavara
Copy link
Member Author

we have deadlock in

        public static void InitializationWithUriOnNonAsyncReaderThrows()
        {
            Assert.Throws<System.Net.Http.HttpRequestException>(() => XmlReader.Create("http://test.test/test.html", new XmlReaderSettings() { Async = false }));
        }

This is exactly the scenario that this PR should solve. It's synchronous Wait on fetch.
When I added bunch of Console.WriteLine in the code of XmlDownloadManager.GetStream it fixed itself.
I don't know why yet.

return GetNonFileStreamAsync(uri, credentials, proxy).GetAwaiter().GetResult();

@pavelsavara
Copy link
Member Author

/azp run runtime-wasm

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@pavelsavara
Copy link
Member Author

/azp run runtime-wasm

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

Copy link
Member

@maraf maraf left a comment

Choose a reason for hiding this comment

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

I'm missing change in dotnet.d.ts. Most of the comments are nits

pavelsavara and others added 7 commits March 14, 2024 13:24
…stem/Runtime/InteropServices/JavaScript/Marshaling/JSMarshalerArgument.Task.cs

Co-authored-by: Marek Fišera <[email protected]>
…stem/Runtime/InteropServices/JavaScript/Marshaling/JSMarshalerArgument.Task.cs

Co-authored-by: Marek Fišera <[email protected]>
…stem/Runtime/InteropServices/JavaScript/Marshaling/JSMarshalerArgument.Task.cs

Co-authored-by: Marek Fišera <[email protected]>
…stem/Runtime/InteropServices/JavaScript/Marshaling/JSMarshalerArgument.Task.cs

Co-authored-by: Marek Fišera <[email protected]>
…stem/Runtime/InteropServices/JavaScript/Marshaling/JSMarshalerArgument.Task.cs

Co-authored-by: Marek Fišera <[email protected]>
…stem/Runtime/InteropServices/JavaScript/Marshaling/JSMarshalerArgument.Task.cs

Co-authored-by: Marek Fišera <[email protected]>
@pavelsavara pavelsavara merged commit 411f7e6 into dotnet:main Mar 14, 2024
117 of 123 checks passed
@pavelsavara pavelsavara deleted the browser_mt_io_thread branch March 14, 2024 15:43
@github-actions github-actions bot locked and limited conversation to collaborators Apr 14, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
arch-wasm WebAssembly architecture area-VM-threading-mono os-browser Browser variant of arch-wasm
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants