TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Ask HN: How does software such as rrweb and OpenReplay work?

3 点作者 punkpeye超过 2 年前
I&#x27;ve seen them mentioned in a few conversations. From what I understand, they effectively allow to record and replay browsing sessions. However, if I understand correctly, it isn&#x27;t a video recording but rather some sort of serialized version of the UI.<p>How does that serialization&#x2F;deserialization work?

2 条评论

Juice10超过 2 年前
Core team member of rrweb here. rrweb and other tools that do user session recording heavily depend on the mutation observer <a href="https:&#x2F;&#x2F;developer.mozilla.org&#x2F;en-US&#x2F;docs&#x2F;Web&#x2F;API&#x2F;MutationObserver" rel="nofollow">https:&#x2F;&#x2F;developer.mozilla.org&#x2F;en-US&#x2F;docs&#x2F;Web&#x2F;API&#x2F;MutationObs...</a> to surface changes to a webpage, each of those changes gets serialized into a JSON event and get captured for later viewing. Apart from the things we can get directly from the Mutation Observer we also end up monkey patching things like the <a href="https:&#x2F;&#x2F;developer.mozilla.org&#x2F;en-US&#x2F;docs&#x2F;Web&#x2F;API&#x2F;WebGLRenderingContext" rel="nofollow">https:&#x2F;&#x2F;developer.mozilla.org&#x2F;en-US&#x2F;docs&#x2F;Web&#x2F;API&#x2F;WebGLRender...</a> and record each call that is done to it so that we can play those back in the same order for replay.<p>Before we do all of the diff recording we start with a full snapshot of the webpage which captures every dom node. And it does a lot more than just your plain old `document.documentElement.outerHTML`, it captures contents of style sheets, images, scroll positions etc.. We use those full snapshots as keyframes to base our diffs off of. This works in a similar way to how video files work, but the snapshots don&#x27;t contain any pixel data, just DOM information.<p>On replay we go ahead and rebuild the DOM as close to how it was recorded and we then animate the changes as they occurred.<p>Let me know if you&#x27;d like some more detail on a specific part of any of this.<p>There is also a video which explains some of this which might be helpful: <a href="https:&#x2F;&#x2F;youtu.be&#x2F;cWxpp9HwLYw?t=1163" rel="nofollow">https:&#x2F;&#x2F;youtu.be&#x2F;cWxpp9HwLYw?t=1163</a>
评论 #32660874 未加载
评论 #32665243 未加载
deliriumchn超过 2 年前
OR is opensource so you can pretty much explore it on your own but TLDR is that it records diffs of DOM, network and state alongside with mouse and send it as a byte array batches to the backend that gzip this files, and then this process is going the other way (unpack, bytes to diff to display) in the player parts.<p>Videos would take too much space plus API is limited as I can see on MDN