Export of the WebAssembly memory buffer

I am trying to compile a C# project to WebAssembly, and I am finding that the actual WebAssembly memory buffer is not accessible from JavaScript.

I can access the initial WebAssembly memory buffer that is provided during the instantiation of the Wasm module using the imports.env.memory.buffer, but once the memory grows (IslandRTL.GrowMemory), any JS ArrayBuffer view that references the initial Wasm memory block will become invalidated, and the following error is reported during runtime:

Cannot perform Construct on a detached ArrayBuffer at new Uint8Array

Furthermore, there are functions in the RemObjectsElements.js file that are using the imports.env.memory.buffer, and break once the memory grows.

Would it be possible to create an exported memory variable, ‘exports.env.memory’, that will be set from within the IslandRTL.GrowMemory function, and update the RemObjectsElements.js to use the new memory variable instead of the initial ‘imports.env.memory.buffer’.

My observations are based on Elements ver.

Curious. That should not have happened no. @Diego_Navarro any idea/

no at this moment, I’m going to check.