Skip to content

Enable external pausing of mutation buffer emissions#224

Closed
eoghanmurray wants to merge 5 commits intorrweb-io:masterfrom
statcounter:freezePage
Closed

Enable external pausing of mutation buffer emissions#224
eoghanmurray wants to merge 5 commits intorrweb-io:masterfrom
statcounter:freezePage

Conversation

@eoghanmurray
Copy link
Contributor

  • no automatic pausing based on e.g. pageVisibility yet, assuming such a thing is desirable
    https://developer.mozilla.org/en-US/docs/Web/API/Page_Visibility_API
  • user code has to call new API method freezePage e.g. when page is hidden or after a timeout
  • automatically unpauses when the next user initiated event occurs
    (am assuming everything that isn't a mutation event counts as 'user initiated'
    either way think this is the correct thing to do until I see a counterexample
    of an event that shouldn't cause the mutations to be unbufferred)

@eoghanmurray
Copy link
Contributor Author

eoghanmurray commented Jun 9, 2020

410756e makes a change to delay processing of the addedSet until emission. I'm not sure I understand this all, but the change solves an issue with a build up of additions (when the DOM was just cycling through nodes).

…ffer` object, as otherwise `this` referred to the `MutationObserver` object itself
 - no automatic pausing based on e.g. pageVisibility yet, assuming such a thing is desirable
   https://developer.mozilla.org/en-US/docs/Web/API/Page_Visibility_API
 - user code has to call new API method `freezePage` e.g. when page is hidden or after a timeout
 - automatically unpauses when the next user initiated event occurs
   (am assuming everything that isn't a mutation event counts as 'user initiated'
   either way think this is the correct thing to do until I see a counterexample
   of an event that shouldn't cause the mutations to be unbufferred)
@eoghanmurray
Copy link
Contributor Author

@Yuyz0112 I've rebased based on current master, would it be possible to get another review and merge if this change is okay?

This pull request adds a new API method .freezePage which allows mutations to be suspended externally.

We are using this to prevent pages which have e.g. a carousel implemented with DOM mutation from generating massive recordings even though the website visitor is not taking any actions (and might not even have the tab in focus)

@eoghanmurray eoghanmurray mentioned this pull request Sep 29, 2020
@eoghanmurray
Copy link
Contributor Author

Is suspendMutations a better name than freezePage?

@Yuyz0112
Copy link
Member

Yuyz0112 commented Oct 3, 2020

For me, freezePage sounds more intuitive.

BTW, if I understand correctly, #385 contains all the changes in this PR and we can only review and discuss that one?

@eoghanmurray
Copy link
Contributor Author

Yes, #385 is this pull request and more ... all further discussion can go there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants