question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Throttling/pausing of Mutation Events

See original GitHub issue

I’m just wondering whether there has been any effort, or rejected effort, to add throttling and/or grouping to the MutationObserver.

I’m recording a website which has an image carousel which transitions images via a setInterval script, so every second, dozens of new mutation events are being generated without any user actions. All the mutations are happening on the style attribute, so there’s quite a lot of commonality between the events, which suggests a few different ‘packing’ strategies, but before delving into this level of complexity, I’m wondering whether an API method to pause mutation tracking would be useful?

This could be triggered by e.g. https://developer.mozilla.org/en-US/docs/Web/API/Page_Visibility_API so that if a user isn’t actually on the page, then mutation events will be batched up until they return.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:7 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
eoghanmurraycommented, May 29, 2020

So the only other possible change would be to create a separate Page Visibility observer, which could e.g. set a class/state on the <iframe> which could be used by the replayer to indicate that the page is not currently visible to the end user. I feel like that’s a separate proposal though.

Otherwise, there’s not much more to it; the changes I’ve made in #224 enables me to do all the things we need to achieve (see sample code above) The idea with ‘config settings’ is that users of rrweb wouldn’t have to use the new freezePage method, but that the logic could be moved into rrweb and behaviour enabled in config, e.g. setting autofreezonBlur: true to call freezePage whenever the document is hidden. or setting autofreezeAfterSeconds to 10 would enable the pause_timeout functionality shown in the sample above.

I’ve sketched out where these config changes could go in https://github.com/statcounter/rrweb/commit/9f24c10e4a88a50195659a78316abd383606f61e

0reactions
Yuyz0112commented, May 28, 2020

Hi @eoghanmurray, thanks a lot for the PRs.

Would you like to explain more about the full plan of doing this? Like the data structure, events, browser API, etc.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Mutation as a Stress Response and the Regulation of ... - NCBI
The first is the regulation of mutagenesis in time by cellular stress responses, which promote random mutations specifically when cells are poorly adapted...
Read more >
Random Mutational Events as a Cause of Birth Defects and ...
Abstract. Faithful and stable inheritance of DNA is coupled with occasional random errors of replication that lead to a change in the DNA...
Read more >
Excess of mutational jackpot events in expanding populations ...
Thus, jackpot events can be generated not only when mutations arise early but also when they occur at favourable locations, which exacerbates ...
Read more >
Mutations: A larger target leads to faster evolution - eLife
These experiments suggest that trait evolution tends not to be caused by one or two mutations with very large effects: rather, tens (or...
Read more >
Rate, molecular spectrum, and consequences of human ...
Of the 10,930 small-scale disease-causing mutations recorded in the present study, 55% involve coding-sequence altering base substitutions (18% nonsense- ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found