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] JS Interop should respect GC pauses #76963

Open
Tracked by #68162
lambdageek opened this issue Oct 12, 2022 · 11 comments
Open
Tracked by #68162

[browser][MT] JS Interop should respect GC pauses #76963

lambdageek opened this issue Oct 12, 2022 · 11 comments
Assignees
Labels
arch-wasm WebAssembly architecture area-VM-threading-mono os-browser Browser variant of arch-wasm
Milestone

Comments

@lambdageek
Copy link
Member

lambdageek commented Oct 12, 2022

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

  • reflection in init_managed_exports
  • mono_wasm_gc_lock, mono_wasm_gc_unlock used by Blazor
  • mono_wasm_read_as_bool_or_null_unsafe used by Blazor
  • GC roots in hybrid globalization
@ghost ghost added the untriaged New issue has not been triaged by the area owner label Oct 12, 2022
@lambdageek lambdageek changed the title JS Interop should respect GC pauses [wasm-mt] JS Interop should respect GC pauses Oct 12, 2022
@ghost
Copy link

ghost commented Oct 12, 2022

Tagging subscribers to this area: @dotnet/gc
See info in area-owners.md if you want to be subscribed.

Issue Details

null

Author: lambdageek
Assignees: -
Labels:

area-GC-coreclr

Milestone: -

@lambdageek lambdageek added area-System.Runtime.InteropServices.JavaScript and removed area-GC-coreclr untriaged New issue has not been triaged by the area owner labels Oct 12, 2022
@lambdageek lambdageek added this to the 8.0.0 milestone Oct 12, 2022
@radical radical added the arch-wasm WebAssembly architecture label Oct 19, 2022
@ghost
Copy link

ghost commented Oct 19, 2022

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

Issue Details

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

Author: lambdageek
Assignees: -
Labels:

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

Milestone: 8.0.0

@lewing
Copy link
Member

lewing commented Jul 11, 2023

@lambdageek what is the state of this

cc @pavelsavara

@lambdageek
Copy link
Member Author

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.

@lewing lewing modified the milestones: 8.0.0, 9.0.0 Jul 11, 2023
@pavelsavara
Copy link
Member

pavelsavara commented Jul 11, 2023

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.

@pavelsavara pavelsavara changed the title [wasm-mt] JS Interop should respect GC pauses [browser][MT] JS Interop should respect GC pauses Nov 9, 2023
@pavelsavara pavelsavara self-assigned this Nov 9, 2023
@pavelsavara

This comment was marked as outdated.

@pavelsavara

This comment was marked as outdated.

@ghost
Copy link

ghost commented Jan 31, 2024

Tagging subscribers to this area: @BrzVlad
See info in area-owners.md if you want to be subscribed.

Issue Details

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

Author: lambdageek
Assignees: pavelsavara
Labels:

arch-wasm, area-GC-mono, area-VM-threading-mono, os-browser

Milestone: 9.0.0

@lewing
Copy link
Member

lewing commented Feb 9, 2024

cc @steveisok

@pavelsavara pavelsavara removed this from the 9.0.0 milestone Mar 28, 2024
@pavelsavara pavelsavara added this to the Future milestone Mar 28, 2024
@pavelsavara
Copy link
Member

If we are able to detach the UI thread from Mono, it would be preferable solution of this problem. See #100411

@pavelsavara
Copy link
Member

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
arch-wasm WebAssembly architecture area-VM-threading-mono os-browser Browser variant of arch-wasm
Projects
None yet
Development

No branches or pull requests

4 participants