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

[browser][MT] Memory growth on worker could cause failure #86642

Closed

Description

@pavelsavara

When we compile the runtime with /p:MonoWasmBuildVariant=multithread and the web worker would cause memory growth, the linear memory buffer is disconnected from the original buffer on the main thread.

Example of allocation and resize on worker
image

Example of subsequent failure on main thread: the buffer is no longer instanceof SharedArrayBuffer but I think it's just disconnected.
image

Leads to

MONO_WASM: TypeError: Failed to execute 'decode' on 'TextDecoder': The provided ArrayBufferView value must not be shared.
    at UTF8ArrayToString (http://localhost:8000/dotnet.native.js:379:22)
    at Object.UTF8ToString (http://localhost:8000/dotnet.native.js:412:15)
    at mono_wasm_trace_logger (http://localhost:8000/dotnet.runtime.js:211:32)
    at wasm_trace_logger (http://localhost:8000/dotnet.native.wasm:wasm-function[142]:0x11902)
    at callback_adapter (http://localhost:8000/dotnet.native.wasm:wasm-function[872]:0x58eec)
    at mono_tracev_inner (http://localhost:8000/dotnet.native.wasm:wasm-function[867]:0x58cfb)
    at mono_trace.13 (http://localhost:8000/dotnet.native.wasm:wasm-function[5213]:0x15b333)
    at mono_runtime_class_init_full (http://localhost:8000/dotnet.native.wasm:wasm-function[5206]:0x15ab4e)
    at do_init_vtable (http://localhost:8000/dotnet.native.wasm:wasm-function[294]:0x2793e)
    at mono_interp_exec_method (http://localhost:8000/dotnet.native.wasm:wasm-function[277]:0x1ec85)

on the main thread.

Activity

  1. added this to the 8.0.0 milestone on May 23, 2023
  2. pavelsavara commented on May 23, 2023

    @pavelsavara
    MemberAuthor

    Something should probably proxy the resize call to all threads emscripten-core/emscripten#8365

  3. lambdageek commented on May 23, 2023

    @lambdageek
    Member

    Resizing on worker threads should be fine, provided the main thread is using Module.GROWABLE_HEAP_U8 (and other views).

    I don't see how proxying to the main thread will help - in that case won't the workers have the same problem?

  4. pavelsavara commented on May 23, 2023

    @pavelsavara
    MemberAuthor

    Our TS code doesn't use Module.GROWABLE_HEAP_U8 yet.

  5. pavelsavara commented on May 24, 2023

    @pavelsavara
    MemberAuthor

    We could disable usage of TextDecoder in emscripten by -s TEXTDECODER=0 and in our code by other means.

    This seems to be related discussions
    emscripten-core/emscripten#18034
    emscripten-core/emscripten#15217

    In the reported case it's not an iframe.

  6. ghost added
    in-prThere is an active PR which will close this issue when it is merged
    on May 25, 2023
  7. ghost removed
    in-prThere is an active PR which will close this issue when it is merged
    on May 28, 2023
  8. ghost locked as resolved and limited conversation to collaborators on Jun 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions