Fastest way to pass binary data into webview #5361
-
|
I would like to ask what is the fastest way to pass data into javascript hosted inside webview2 from C#? My use-case is that I have some binary file processing in C# and I need to pass it to my javascript code which will render it. This data can be over 100MB large so good performance is important. I would say that in perfect scenario it should be memory copy so very fast way should be possible. I can see there are several ways to communicate from C# to webview:
With HTTP Stream response I'm able to transfer about 100MB of data in about 300-600ms to javascript which is not terrible but I'm wondering if there is some faster way. Even if it's less developer friendly and requires native calls I'm ok with anything really. Thank you |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments
-
|
Have you considered / investigated "SharedBuffer"? |
Beta Was this translation helpful? Give feedback.
-
|
SharedBuffer is the way. I'm running an oscilloscope demo using it, passing 20 million samples per second and could easily go higher. This uses a shared buffer of 128Mb divided up into 128 1Mb slots. I also have a POD demo using sharedbuffer that passes 25kHz packets per second (packet size ambivalent) |
Beta Was this translation helpful? Give feedback.
-
|
Sorry for late response but after doing some proof of concepts this is exactly what I needed and allowed me to reduce data transfer of larger files (over 50MB) to just a few milliseconds. That is a lot better than I ever hoped for. |
Beta Was this translation helpful? Give feedback.
Have you considered / investigated "SharedBuffer"?
CreateSharedBuffer
PostSharedBufferToScript