TypedArray fail to serialize #5619
Labels
area-blazor
Includes: Blazor, Razor Components
bug
This issue describes a behavior which is not expected - a bug.
help wanted
Up for grabs. We would accept a PR to help resolve this issue
Milestone
Hello folks!
While I was implementing Blazor.Extensions.WebUSB, I had to send/receive buffers to the USB device connected. In C#, I was sending
byte[]
down to JS and it was working perfectly fine. However, when I was sending a buffer back from JS to C#, it fail without any errors since it was unable to deserialize theUint8Array
into abyte[]
. It just hang on theresolve(array)
call.After a day trying to figure out what is going on, I noticed that if I convert it to a regular array it works perfectly with
Array.prototype.slice.call(new Uint8Array(out.data.buffer))
. That is very inefficient...The reason for that (looks like) is because we don't have support to deserialize
TypedArray
s on SimpleJson...The same problem happens on Blazor.Extensions.SignalR when we have a callback that expects a
byte[]
.Look at the examples here and here.
Do we have a less hacky/slow alternative to this?
Thanks!
The text was updated successfully, but these errors were encountered: