wails icon indicating copy to clipboard operation
wails copied to clipboard

binary support

Open snopywithchary opened this issue 1 year ago • 11 comments

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

snopywithchary avatar Jan 20 '24 02:01 snopywithchary

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

leaanthony avatar Jan 20 '24 21:01 leaanthony

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

snopywithchary avatar Jan 24 '24 02:01 snopywithchary

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.

afocus avatar Jan 24 '24 14:01 afocus

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

leaanthony avatar Jan 25 '24 10:01 leaanthony

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 avatar Jan 25 '24 12:01 stffabi

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.

stffabi avatar Jan 25 '24 12:01 stffabi

@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

gedw99 avatar Feb 02 '24 16:02 gedw99

@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.

stffabi avatar Feb 16 '24 07:02 stffabi

Any update on this one?

KiddoV avatar May 16 '24 20:05 KiddoV

i have same problem @snopywithchary

rubyangxg avatar Jul 06 '24 15:07 rubyangxg

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

leaanthony avatar Jul 07 '24 03:07 leaanthony