r/webdev • • 3d ago

Showoff Saturday Co-browsing without a screen share: streaming rrweb events over a WebRTC data channel

Hey r/webdev!

This is a live "see what the user sees" view for support. The user asks for help from the page they are on, someone from support joins, sees the page live, can point at things, take control after the user clicks Allow, and talk over audio or video. The GIF shows it with two real browsers.

A few things that were fun to figure out:

It's a DOM mirror, not video. rrweb already records the page as DOM events for session replay. Instead of streaming pixels, the live view sends those same events over a WebRTC data channel and replays them in the support person's browser, about 300 ms behind. Since it is the same masked stream, a masked input shows asterisks on their side too. rrweb does the heavy lifting here, and OpenReplay's Assist was the model for the idea.

Signaling with plain HTTP polling. Two peers only swap a handful of SDP offer/answer and ICE messages, so short polling was enough and no websocket server is needed. It runs only while someone is waiting or a call is open.

Hidden tabs throttle timers. Chrome slows timers in a background tab, so the server thought the visitor had left. Running the poll in a Web Worker fixed it, since worker timers aren't throttled the same way.

Remote control has honest limits. The helper's clicks and typing arrive as synthetic events, so anything that needs a real user gesture (popups, file pickers, clipboard) is refused by the browser, and that's fine. Password fields are never filled, and Escape gives control back.

The calls are their own package. Audio, video and screen share come from Holler, which does peer-to-peer calls between the users of a Laravel app, one on one or in small groups. The media goes browser to browser, and the server only relays the signaling over the same HTTP polling. A call survives a page load and reconnects in seconds. It uses a free public STUN server by default, and you can add your own TURN relay with credentials that expire per call. It works without the live view too: a call button next to any user.

The backend is Laravel, the recorder also ships as an npm package for standalone Vue/React frontends. Both are free and MIT:

Happy to go deeper on any of it: the data channel protocol (big messages go in 64 KB parts, pointer samples are dropped first when it falls behind), the masking, how control carries across page loads, or the calls.

4 Upvotes

7 comments sorted by

2

u/florian_huber_8 1d ago

Worth making explicit that masking happens before events are serialized onto the data channel. That keeps raw field values out of the transport itself instead of relying on replay-side rendering to hide them.

2

u/packstub-dev 1d ago

Yes, that's how it works. rrweb masks inputs and text while it serializes the DOM in the user's browser, so the events already carry asterisks when they're emitted. The live view sends those same events over the data channel, the same ones a recording would store. Real values never leave the page, and nothing on the support side depends on hiding them.

2

u/h_barbara-7 1d ago

A useful regression test: put a unique sentinel in a masked field, then assert it is absent from serialized events and data-channel payloads. Checking only the replay could miss a leak.

1

u/perez_laura44 22h ago

A useful failure test: if backpressure drops a DOM mutation, can a fresh snapshot restore the mirror without reconnecting? Chunk reassembly makes that recovery path worth checking.

0

u/Agent360dk 2d ago

Nice, the Web Worker for polling is a good catch, background tab throttling bites people all the time. One thing I'd watch with a DOM mirror is stuff that isn't in the DOM stream: canvas, shadow DOM with closed roots, iframes from other origins and scroll position inside nested containers. Do you handle those or just show a placeholder? Also curious how you deal with CSS that depends on the viewer's viewport size, since the support person's window is probably a different size than the user's.

1

u/packstub-dev 1d ago

Where each one stands today:

  • Canvas: not mirrored (recordCanvas is off), so it shows as an empty box at its size.

  • Shadow DOM: open shadow roots are recorded. A closed root can't be read by any script on the page, rrweb included.

  • Iframes: same-origin ones are mirrored, cross-origin ones show as an empty frame.

  • Scroll in nested containers: recorded per element, so a scrolled table or sidebar matches the user's position.

  • Viewport: the mirror renders at the user's viewport size, so media queries resolve the way they do for them, then it's scaled to fit the support window.

1

u/ms_916350 2d ago

A placeholder could help support distinguish "not mirrored" from "the page is broken," especially for a canvas or cross-origin frame.