r/webdev • • 18h ago

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

Post image

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.

1 Upvotes

2 comments sorted by

1

u/Agent360dk 16h 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/ms_916350 13h ago

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