MicrosoftEdge / WebView2Feedback

Feedback and discussions about Microsoft Edge WebView2
https://aka.ms/webview2
451 stars 55 forks source link

[Feature]: Fast way to send large amounts of data to frontend #4468

Open aidv opened 7 months ago

aidv commented 7 months ago

Describe the feature/enhancement you need

I'm looking for the fastest way to push large amounts of data to a WebGL/WebGPU context and render something in the WebGL/WebGPU scene.

The pipeline looks like this: CPU -> IPC -> WebView2 -> GPU

However, the performance is very slow, and there are many points of failure along the way.

Our algorithm runs on the CPU (soon on the GPU with OpenCL) The generated data is sent via IPC to the WebView, which is really slow, The WebView2 runs web code that pushes the data to the GPU as a texture, e.g webGPU....writeTexture()

All of these steps take time.

For example, just pushing the texture data to the GPU takes 1.2s with WebGPU, while the equivalent pure C code takes 1.2ms (!!!!!!) with CUDA/OpenCL.

One idea I had was to create an offscreen C/C++ OpenGL renderer and send the frames to the WebView2, but since IPC is slow, this won't work. Sending 62MB of data from C to WebVIew2 takes 4 seconds.

What is the absolute best and most efficient way to render something in my C backend and show it in a on my WebView2?

The scenario/use case where you would use this feature

App generates large amounts of data very fast in the native app and then displays the output in the WebView2 frontend.

How important is this request to you?

Critical. My app's basic functions wouldn't work without it.

Suggested implementation

Shared memory block Shared WebGL / WebGPU handle Shared HTML canvas handle

What does your app do? Is there a pending deadline for this request?

My app is a HPC realtime data visualizer

softworkz commented 6 months ago

I just came across this by accidence: https://learn.microsoft.com/en-us/dotnet/api/microsoft.web.webview2.core.corewebview2texturestream

I haven't looked any deeper into it, don't even know what it's for, but maybe it's of interest for your task..