Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable external pausing of mutation buffer emissions #224

Closed
wants to merge 5 commits into from

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