Skip to content

fix(runtime): memory leak on document.hidden - #6811

Open
johnjenkins wants to merge 3 commits into
mainfrom
fix-hidden-tab-memory-leak
Open

fix(runtime): memory leak on document.hidden#6811
johnjenkins wants to merge 3 commits into
mainfrom
fix-hidden-tab-memory-leak

Conversation

@johnjenkins

@johnjenkins johnjenkins commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

What is the current behavior?

GitHub Issue Number: #6762

requestAnimationFrame never fires when document.hidden (e.g. when a tab isn't open).
This means:

  1. all flushed tasks can build up indefinitely
  2. any disconnected elements are not properly cleaned-up / garbage collected

In both cases (esp disconnected cleanup) the indiscriminate use of requestAnimationFrame was never a design decision, just an oversight

What is the new behavior?

Fixes #6762

  1. flushed tasks detect if document.hidden - if true will use microtask instead of RaF
  2. disconnected elements always run cleanup via microtask

Documentation

Does this introduce a breaking change?

  • Yes
  • No

Testing

Other information

@johnjenkins
johnjenkins requested a review from a team as a code owner August 6, 2026 15:36

@mpesic mpesic left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

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.

bug: Memory Leak - Destroyed stencil component retained while tab is hidden

2 participants