-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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] JSImport dispatch to target thread via JSSynchronizationContext #96319
[browser][MT] JSImport dispatch to target thread via JSSynchronizationContext #96319
Conversation
Tagging subscribers to 'arch-wasm': @lewing Issue DetailsJSImport dispatch
Tests
Other
|
/azp run runtime-wasm |
Azure Pipelines successfully started running 1 pipeline(s). |
/azp run runtime-wasm |
Azure Pipelines successfully started running 1 pipeline(s). |
...eropServices.JavaScript/src/System/Runtime/InteropServices/JavaScript/JSObject.References.cs
Show resolved
Hide resolved
/azp run runtime-wasm |
[MethodImpl(MethodImplOptions.AggressiveInlining)] | ||
internal static unsafe void ResolveOrRejectPromise(JSProxyContext targetContext, Span<JSMarshalerArgument> arguments) | ||
{ | ||
// this copy is freed in mono_wasm_invoke_import_async |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this used to be always synchronous, and now becomes always-asynchronous. should we preserve the old synchronous execution when the target context is the current context?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that JS Promise
handlers always go through microtask queue. So in effect this was already async before from user code perspective. We could avoid allocating C# queue item if we do the optimization you suggest.
I want to switch this to emscripten dispatch later anyway. I will add comment and keep this open question for now.
...Runtime.InteropServices.JavaScript/src/System/Runtime/InteropServices/JavaScript/JSObject.cs
Outdated
Show resolved
Hide resolved
...pt/src/System/Runtime/InteropServices/JavaScript/Marshaling/JSMarshalerArgument.Exception.cs
Outdated
Show resolved
Hide resolved
...ervices.JavaScript.UnitTests/System/Runtime/InteropServices/JavaScript/JSImportExportTest.cs
Outdated
Show resolved
Hide resolved
...vices.JavaScript.UnitTests/System/Runtime/InteropServices/JavaScript/JavaScriptTestHelper.cs
Show resolved
Hide resolved
...eropServices.JavaScript.UnitTests/System/Runtime/InteropServices/JavaScript/WebWorkerTest.cs
Outdated
Show resolved
Hide resolved
...rvices.JavaScript.UnitTests/System/Runtime/InteropServices/JavaScript/WebWorkerTestHelper.cs
Outdated
Show resolved
Hide resolved
...rvices.JavaScript.UnitTests/System/Runtime/InteropServices/JavaScript/WebWorkerTestHelper.cs
Outdated
Show resolved
Hide resolved
...rvices.JavaScript.UnitTests/System/Runtime/InteropServices/JavaScript/WebWorkerTestHelper.cs
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
other than my comments this all looks good to me, and i feel like i understand most of it
/azp run runtime-wasm |
Azure Pipelines successfully started running 1 pipeline(s). |
JSImport dispatch
JSImport
will now dispatch the call to the correct threadJSObject
passed as parametersJSWebWorker
Task
/Promise
Task
/Promise
resultJSImportGenerator
doesn't generateThreadStatic
anymore for the binding variableTests
System.Runtime.InteropServices.JavaScript.Tests.WebWorkerTest
, more to come laterSystem.Runtime.InteropServices.JavaScript.Tests
now also run xunit on thread pool in MTOther
AssertIsInteropThread
JSFunctionBinding.FunctionName
only in Debug buildJSWebWorker
mono_set_thread_id
improves TID in JS console logging from threadsmono_wasm_main_thread_ptr
worker.pthread_ptr
Follow up in #95370