wailsapp / wails

Create beautiful applications using Go
https://wails.io
MIT License
25.55k stars 1.24k forks source link

binary support #3212

Open snopywithchary opened 10 months ago

snopywithchary commented 10 months ago

Is your feature request related to a problem? Please describe.

I use wails to transmit binary image streams, but I found that if I bind the method of transmitting binary, wails will automatically base64 encode the binary. Is there a more efficient method?

Describe the solution you'd like

such as this: https://github.com/MicrosoftEdge/WebView2Feedback/blob/main/specs/SharedBuffer.md

Describe alternatives you've considered

No response

Additional context

No response

leaanthony commented 10 months ago

Without knowing your use case, I can only suggest https://wails.io/docs/guides/dynamic-assets/

snopywithchary commented 10 months ago

Without knowing your use case, I can only suggest https://wails.io/docs/guides/dynamic-assets/ I have a video, the backend reads the video and sends the image data to the frontend for rendering, I am currently using websocket transport because I didn't find a more efficient transport method in wails

afocus commented 10 months ago

There are certain scenarios where json encoding and decoding is costly, such as photoshop and video editing software. While the use of binary with Uint8Array in websockets can temporarily handle this, it would be nice to have binary support built into the binding.

leaanthony commented 10 months ago

SharedBuffer would be good. What about Mac and Linux though?

stffabi commented 10 months ago

SharedBuffer would be good. What about Mac and Linux though?

There are no such things on those platforms. The only thing that works there is streaming responses through the AssetServer as you already mentioned (https://wails.io/docs/guides/dynamic-assets/)

stffabi commented 10 months ago

I have a video, the backend reads the video and sends the image data to the frontend for rendering, I am currently using websocket transport because I didn't find a more efficient transport method in wails

Please be aware, Websockets don't work over the custom scheme used in-app, unless you are starting your own http server on the network stack.

gedw99 commented 10 months ago

@stffabi

Would be awesome if sockets were used for the IO between the Backend and Frontend.

Pushup does it this way for golang htmx projects.

https://github.com/adhocteam/pushup/blob/main/_runtime/cmd/main.go#L29

stffabi commented 9 months ago

@gedw99 Opening unix sockets or ports on the network stack is probably not a feature people want to see in a default Wails app. That would allow to intercept traffic from backend/frontend relatively easy, that's why the AssetServer is not bound to the network stack and uses IPC.

But if someone wants to do that, that is pretty easily doable with just a couple of lines in Go to start a http server and use that in your frontend.

KiddoV commented 6 months ago

Any update on this one?

rubyangxg commented 4 months ago

i have same problem @snopywithchary

leaanthony commented 4 months ago

Will gladly accept a PR for this if anyone wants to try.