Open lambdageek opened 2 years ago
Tagging subscribers to this area: @dotnet/gc See info in area-owners.md if you want to be subscribed.
Author: | lambdageek |
---|---|
Assignees: | - |
Labels: | `area-GC-coreclr` |
Milestone: | - |
Tagging subscribers to 'arch-wasm': @lewing See info in area-owners.md if you want to be subscribed.
Author: | lambdageek |
---|---|
Assignees: | - |
Labels: | `arch-wasm`, `area-System.Runtime.InteropServices.JavaScript` |
Milestone: | 8.0.0 |
@lambdageek what is the state of this
cc @pavelsavara
Basically wishlist.
I think we have GC Unsafe transitions on all the places where JS runtime code enters native. And managed code has transitions on the native-to- managed wrappers, so calling managed from JS will likewise safepoint.
So the remaining part of this is to design something new that is Promise-aware so that async apis can wait in JS instead of blocking.
Perhaps mono GC could export unresolved Promise. JS would await that promise instead of blocking, before running any managed callbacks. That also assumes that the callback are async in nature. I'm not sure that all DOM or networking events are.
I think that
JSWebWorker
threadJSWebWorker
or deputy thread, we are idling in external loop by default. When timer or any other event ticks, we enter the mono thru GC barrier, like MONO_ENTER_GC_UNSAFE
One which is possibly missing it is mono_wasm_execute_timer
To avoid blocking UI thread on GC, we could add another condition here. https://github.com/dotnet/runtime/blob/72604a4b56851a306a545a4fc7320db3a942398f/src/mono/browser/runtime/scheduling.ts#L56
And postpone mono job execution (also) when GC is running.
Tagging subscribers to this area: @brzvlad See info in area-owners.md if you want to be subscribed.
Author: | lambdageek |
---|---|
Assignees: | pavelsavara |
Labels: | `arch-wasm`, `area-GC-mono`, `area-VM-threading-mono`, `os-browser` |
Milestone: | 9.0.0 |
cc @steveisok
If we are able to detach the UI thread from Mono, it would be preferable solution of this problem. See https://github.com/dotnet/runtime/issues/100411
To be able to postpone calls to mono_wasm_gc_lock
we also need to postpone whole Blazor renderBatch
via setTimeout
Currently it happens synchronously I think.
Block threads (esp the main thread) from entering the runtime from the JS event loop when a GC Stop-The-World is active.
The thread should safepoint in native, or (better) somehow defer its work and return to the JS event loop
Current offenders are
init_managed_exports
mono_wasm_gc_lock
,mono_wasm_gc_unlock
used by Blazormono_wasm_read_as_bool_or_null_unsafe
used by Blazor