[Maintenance]: Alternative chunking strategy in WebRTCConnection

Open
#6,091 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
40/100
Issue type
Refactor
Clarity
Mostly clear
Activity status
Active
Tech stack
java
Domain
networking

Research direction

Start by tracing WebRTCConnection#SendThread and the receiver logic that combines message chunks; the issue names no files or tests. Determine how chunk boundaries and the final empty chunk are represented, then update the protocol and sender together. Done means messages can be sent without the temporary message copy while the receiver reliably reconstructs exact-size and multi-chunk messages.

Written by the indexing model from the issue text.

Description

code-maintenance
Describe the problem

Before a WebRTCConnection can send a message, it first has to write the length to a temporary buffer and then copy the entire message to the temporary buffer before sending the message in chunks. Adding to this, "sending the method" also creates a copy internal to webrtc-java. This is wasteful and could be improved to better support high-traffic situations.

The improvement you'd like to see

A new chunking strategy is used that doesn't require an intermediary copy in WebRTCConnection#SendThread. For example, we could skip writing the length at all, wrap the message in a ByteBuffer, and send chunks until the message is fully sent (sending one final empty message in case the length is an exact multiple of the chunk size). The receiver could read and recombine chunk until it finds the last one, identified as being less than the chunk size.

Expected Benefits

WebRTCConnection would become a lighter-weight component.

Additional Context

No response

Dominant language
Java
Stars
927
Forks
286
Avg merge
3d 17h
Merged PRs (30d)
94

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from RPTools/maptool

All issues in RPTools/maptool

Similar issues

More Java issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.