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] make UI thread not managed/attached #100411

Open
pavelsavara opened this issue Mar 28, 2024 · 1 comment
Open

[browser][MT] make UI thread not managed/attached #100411

pavelsavara opened this issue Mar 28, 2024 · 1 comment
Assignees
Labels
arch-wasm WebAssembly architecture area-System.Runtime.InteropServices.JavaScript os-browser Browser variant of arch-wasm
Milestone

Comments

@pavelsavara
Copy link
Member

pavelsavara commented Mar 28, 2024

Currently the UI thread is attached Mono thread and can call into Managed code.
The downside is that it needs to enter GC barrier, which makes it participate in the stop-the-world.

Current blockers are

  • reflection in init_managed_exports
  • mono_wasm_gc_lock, mono_wasm_gc_unlock used by Blazor
  • monoObjectAsBoolOrNullUnsafe used by Blazor
  • monoStringToStringUnsafe used by Blazor
  • mono_wasm_assembly_load, mono_wasm_assembly_find_class, mono_wasm_assembly_find_method by looking for entrypoint
  • GC roots in hybrid globalization

Also emscripten will complain about blocking UI thread when ASSERTIONS are enabled.
Blocking on the main thread is very dangerous, see https://emscripten.org/docs/porting/pthreads.html#blocking-on-the-main-browser-thread

See https://github.com/emscripten-core/emscripten/blob/8c81cac1bbae378bc7dde0c21c99602cbaf452d0/src/library_pthread.js#L910-L922

If we are unable to do this, the alternative is #76963

@pavelsavara pavelsavara added arch-wasm WebAssembly architecture area-System.Runtime.InteropServices.JavaScript os-browser Browser variant of arch-wasm labels Mar 28, 2024
@pavelsavara pavelsavara added this to the Future milestone Mar 28, 2024
@pavelsavara pavelsavara self-assigned this Mar 28, 2024
Copy link
Contributor

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

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

No branches or pull requests

1 participant