rrweb-io / rrweb

record and replay the web
https://www.rrweb.io/
MIT License
16.76k stars 1.43k forks source link

Separate FullSnapshot to smaller chunks #534

Closed phuong closed 3 years ago

phuong commented 3 years ago

Thank you for make rrweb better day by day.

Based on the document, FullSnapshot record will be increase the size bigger and bigger.

@Yuyz0112 @here is there any way to separate FullSnapshot into small chunks?

ucjonathan commented 3 years ago

Have you considered using the recipe to compress the events generated on the client side?

phuong commented 3 years ago

Have you considered using the recipe to compress the events generated on the client side?

@ucjonathan I did tried with compress-json, but the size is still large

Yuyz0112 commented 3 years ago

@phuong

You can stringify the full snapshot JSON.stringify(snapshot) and split the string into multiple chunks

function chunkSubstr(str, size) {
  const numChunks = Math.ceil(str.length / size)
  const chunks = new Array(numChunks)

  for (let i = 0, o = 0; i < numChunks; ++i, o += size) {
    chunks[i] = str.substr(o, size)
  }

  return chunks
}
ucjonathan commented 3 years ago

Have you looked at the packFn support in this recipe?

https://github.com/rrweb-io/rrweb/blob/master/docs/recipes/optimize-storage.md

no-1ne commented 3 years ago

Can this help https://github.com/saltyrtc/chunked-dc-js