imgui-ws icon indicating copy to clipboard operation
imgui-ws copied to clipboard

Improve compression of ImDrawData buffers

Open ggerganov opened this issue 5 years ago • 0 comments

Description

It is essential for the successful application of this WebSocket approach to minimise the amount of network traffic between the server and the clients. The WebSocket spec allows for extensions that perform general compression on the transmitted data, but it can only do so much. A custom approach, handcrafted for ImDrawData could significantly reduce the network traffic.

Current implementation

The differences are calculated per ImDrawList. For each ImDrawList, we store the position of the first vertex and subtract this value from all vertices in the draw list. This makes the ImDrawList invariant to shifts. The client takes care to restore the position offset before rendering the data.

If the current ImDrawList curList has the same size as it had in the previous frame prevList - the binary contents of curList and prevList are xored and run-length encoded. Otherwise - we send the full curList.

Ideas to explore

  • [X] Per DrawList differences
  • [ ] Deinterleave ImDrawVtx fields
  • [ ] Rate control of focused/hovered windows
  • [ ] Alternative ImDrawList structure

ggerganov avatar Jul 01 '19 20:07 ggerganov