Skip to content

Feasibility of mutable getArrayBuffer return value #230

@isaac-mason

Description

@isaac-mason

I am experimenting with using quickjs-emscripten for a simulation use case where I write to an array buffer within quickjs to step a simulation, and visualise the simulation by reading from the same array buffer (via array views on the emscripten buffer) outside of quickjs. I'm particularly interested in whether this is possible without per-frame allocations/copying for performance reasons.

I noted that using getArrayBuffer returns a copy of the array buffer's data. Looking at the source of the underlying QTS_GetArrayBuffer interface, I see a copy of the JS_GetArrayBuffer result is returned. Would introducing a variation of this API that doesn't copy be possible with QuickJS? Or is there a reason copying the result must be done always immediately? My current understanding is that the pointer to the buffer can become invalid at any time, so I see why an API that copies the result can be preferable, but I'm curious to understand if this must be done.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions