镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
Skip to content

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

Open

Description

@lambdageek

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

Activity

  1. ghost added
    untriagedNew issue has not been triaged by the area owner
    on Oct 12, 2022
  2. changed the title [-]JS Interop should respect GC pauses[/-] [+][wasm-mt] JS Interop should respect GC pauses[/+] on Oct 12, 2022
  3. added this to the 8.0.0 milestone on Oct 12, 2022
  4. lewing commented on Jul 11, 2023

    @lewing
    Member

    @lambdageek what is the state of this

    cc @pavelsavara

  5. lambdageek commented on Jul 11, 2023

    @lambdageek
    MemberAuthor

    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.

  6. modified the milestones: 8.0.0, 9.0.0 on Jul 11, 2023
  7. pavelsavara commented on Jul 11, 2023

    @pavelsavara
    Member

    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.

  8. changed the title [-][wasm-mt] JS Interop should respect GC pauses[/-] [+][browser][MT] JS Interop should respect GC pauses[/+] on Nov 9, 2023
  9. self-assigned this
    on Nov 9, 2023
  10. pavelsavara commented on Nov 9, 2023

    @pavelsavara
  11. pavelsavara commented on Jan 14, 2024

    @pavelsavara
  12. lewing commented on Feb 9, 2024

    @lewing
    Member
  13. modified the milestones: 9.0.0, Future on Mar 28, 2024
  14. pavelsavara commented on Mar 28, 2024

    @pavelsavara
    Member

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

  15. pavelsavara commented on Mar 28, 2024

    @pavelsavara
    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

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions