Just want to highlight that I have been at this for about a week and am new to dealing with the heap and pointers and have not had to interact directly with it before. Could really use some help as I have not made any progress.
Problem statement: Need to access an object[] that I created on Blazor side from Javascript without the use of JSUnmarshalled call from Blazor to pass the data in.
Why? Using the JSUnmarshalled call is still too slow for how large the object[] is even though it only takes .25ms (yes .25ms) to actually create the entire array. The array takes 2 seconds to pass to JS. This is a problem because I am rapidly making adjustments based on user input and most time is spent on waiting for the data to be passed over which causes poor user experience.
What I am currently doing:
c# side
JSUnmarshalledRuntime.InvokeUnmarshalled<object[], object>("InitializeGeometry", RenderModel.GetCombined());
InitializeGeometry calls this JS function to process the object[]
JS side
function getInt32Heap(data) {
var m = data + 12;
var r = Module.HEAP32[m >> 2]
return Array.from(new Int32Array(Module.HEAP32.buffer, m + 4, r));}
This is working fine but is quite slow. What I have tried to find is a way to create a pointer for the object[] on the Blazor side and then pass it into JS. Then on the JS side figure out how to use that pointer to get the same data out that I am currently getting.
I have reached out to the .Net team and this is my original question. https://github.com/dotnet/aspnetcore/issues/41490
Here is what I have looked through https://github.com/dotnet/aspnetcore/blob/main/src/Components/Web.JS/src/Rendering/RenderBatch/SharedMemoryRenderBatch.ts
Also found this https://github.com/SteveSandersonMS/BlazorInputFile/blob/db10236b049ea05de28de9b7806447a3c84c8465/BlazorInputFile/wwwroot/inputfile.js#L113
Again, I am new to this so the answers may be in here but I am not seeing them. I know this is due to my lack of understanding but so far I have not read anything that puts things into perspective for me. Any help would be greatly appreciated!