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] Marshal resolved/unresolved tasks separately #99347

Merged

Conversation

pavelsavara
Copy link
Member

@pavelsavara pavelsavara commented Mar 6, 2024

This change will avoid sending 2 messages to target thread (UI) and instead will only send one.

  • when the target thread is the same as current thread and this is synchronous/blocking return from JSExport
  • when this is non-return parameter of JSImport <- this is new here

Otherwise will use new JSAsyncTaskScheduler

  • to make sure that the mono_wasm_resolve_or_reject_promise_post happens after mono_wasm_invoke_jsimport_async_post
  • I'm not sure why #99317 was not enough and didn't help it.

contributes to #98406

@pavelsavara pavelsavara added arch-wasm WebAssembly architecture area-System.Runtime.InteropServices.JavaScript os-browser Browser variant of arch-wasm labels Mar 6, 2024
@pavelsavara pavelsavara added this to the 9.0.0 milestone Mar 6, 2024
@pavelsavara pavelsavara requested a review from maraf March 6, 2024 10:02
@pavelsavara pavelsavara self-assigned this Mar 6, 2024
@ghost
Copy link

ghost commented Mar 6, 2024

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

Issue Details

This change will avoid sending 2 messages to target thread (UI) and instead will only send one.

  • when the target thread is the same as current thread and this is synchronous/blocking return from JSExport
  • when this is non-return parameter of JSImport <- this is new here

It could still happen that Task completion (on TP thread) is racing with the task.IsCompleted condition here, so it may not fix all cases, but it will dramatically reduce the chances.

I'm not 100% sure why #99317 didn't help it.

contributes to #98406

Author: pavelsavara
Assignees: pavelsavara
Labels:

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

Milestone: 9.0.0

@pavelsavara pavelsavara changed the title [browser][MT] Marshal resolved tasks immediately, when they are parametr of JSImport [browser][MT] Marshal resolved/unresolved tasks separately Mar 6, 2024
@pavelsavara pavelsavara marked this pull request as ready for review March 6, 2024 14:48
@pavelsavara pavelsavara requested a review from lewing as a code owner March 6, 2024 14:48
pavelsavara and others added 4 commits March 6, 2024 17:36
…stem/Runtime/InteropServices/JavaScript/JSProxyContext.cs

Co-authored-by: Ilona Tomkowicz <32700855+ilonatommy@users.noreply.github.com>
…stem/Runtime/InteropServices/JavaScript/Marshaling/JSMarshalerArgument.Task.cs

Co-authored-by: Ilona Tomkowicz <32700855+ilonatommy@users.noreply.github.com>
@pavelsavara
Copy link
Member Author

Filled #99395

@pavelsavara
Copy link
Member Author

CI issue is #98721

@pavelsavara pavelsavara merged commit b0f6444 into dotnet:main Mar 7, 2024
119 of 121 checks passed
@pavelsavara pavelsavara deleted the browser_marshal_resoved_tasks_parameters branch March 7, 2024 09:45
@github-actions github-actions bot locked and limited conversation to collaborators Apr 7, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
arch-wasm WebAssembly architecture area-System.Runtime.InteropServices.JavaScript os-browser Browser variant of arch-wasm
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants