Skip to content

[browser][JSImport] Support for marshaling float memory views #97380

Closed

Description

@pavelsavara

Support for float[], Span<Single> and ArraySegment<Single> in [JSImport]/[JSExport]

As requested in #97268

Activity

  1. added this to the 9.0.0 milestone on Jan 23, 2024
  2. self-assigned this
    on Jan 23, 2024
  3. pavelsavara commented on Jan 23, 2024

    @pavelsavara
    MemberAuthor
  4. eeegs commented on Jan 24, 2024

    @eeegs

    Please include arrays too - float[].

    Thankyou for looking at this. Taking a quick look at the various WASM doco and the WebGPU API, the ability to move data across the .Net/WASM/JavaScript divide with as little ceremony and no transformation is important for performant apps. If we want C# to be a top contender we have to deal with this.

    What is stopping the full range of javascript TypedArrays being supported? (sans clamped ones)?

    Can we discuss the mechanisms involved?

  5. pavelsavara commented on Jan 24, 2024

    @pavelsavara
    MemberAuthor

    Please include arrays too - float[].

    Added above.

    Can we discuss the mechanisms involved?

    Mostly, this could be nice copy & paste PR from contributor (hint hint ..).
    You just follow example of double.

    There is

    • C# public API of the runtime in System.Runtime.InteropServices.JavaScript , this needs to pass API review process.

      • That's separate github issue, once you have working draft in a PR.
      • (some of this is for the code generator to use)
    • Update the code generator.

    • C# methods for the generated code marshaler

    • Update the JS side of the marshaler for array, segment

    • update unit tests, more

    • update docs,

    This is not exhaustive list, but I guess if you understand the pattern you will be able to follow it and find all places.

    What is stopping the full range of javascript TypedArrays being supported? (sans clamped ones)?

    Other priorities, and also so far nobody asked for it. If you plan to work on it, please start with float and see if you can deliver that before you broaden your scope.

    Just to make it clear, what you get for double already is TypedArray, it's view or simple wrapper around it.

  6. added
    help wanted
    on May 14, 2024
  7. modified the milestones: 9.0.0, Future on May 14, 2024
  8. removed their assignment
    on May 14, 2024
  9. added
    in-pr
    on Jan 26, 2026
  10. locked and limited conversation to collaborators on Mar 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    arch-wasmarea-System.Runtime.InteropServices.JavaScriptfeature-requesthelp wantedin-pros-browser

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions