Skip to content

fix(browser): Reduce number of visibilitystate and pagehide listeners #18584

Description

@github-actions

Note

The pull request "fix(browser): Reduce number of visibilitystate and pagehide listeners" was created by @Lms24 but did not reference an issue. Therefore this issue was created for better visibility in external tools like Linear.

Previously, we called onHidden in our slightly modified version of the vendored in whenIdleOrHidden API from web-vitals. This caused 2 additional event listeners to be registered with each whenIdleOrHidden invocation, which also didn't get cleaned up properly.

To fix this, and prevent similar situations, this PR:

  • inlines the pagehide event listener registration in whenIdleOrHidden so that we can remove the onHidden call
  • adds once: true to the listener registration so that the callback is only invoked once
  • deprecates onHidden because IMHO we should remove it in v11 and replace the one remaining use of it with a direct visibilityChange subscription.

Activity

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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions