Add a way to send a pre-encoded string as a text frame over a WebSocket #27129
Labels
area-core-library
SDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries.
library-io
In the vm-service, we have have some large (tens of megabytes) responses that are constructed in C++ and efficiently moved to the service isolate without copying as an external Uint8List. Unfortunately, the current WebSocket API doesn't have a way to send a text frame without converting this Uint8List into a String (UTF8 decode), which the WebSocket implementation then converts back to Uint8List (UTF8 encode). The 3x space overhead of the round-trip conversion can be fatal in memory-constrained environments like iOS.
A possible API change would be to add
WebSocket.sendMessage(TEXT | BINARY type, List<int> bytes)
, as proposed in https://chromiumcodereview.appspot.com/2260073002/.@zanderso @lrhn
The text was updated successfully, but these errors were encountered: