Skip to content

Conversation

@ShaneK
Copy link
Member

@ShaneK ShaneK commented Dec 8, 2025

Issue number: resolves internal


What is the current behavior?

When using ModalController to present a modal in Angular applications, the browser becomes non-responsive and hangs in some circumstances. This regression was introduced in #30544 with the addition of a MutationObserver that watches document.body with subtree: true to detect when a modal's parent element is removed from the DOM. For controller-based modals, this observer fires on every DOM mutation in the document, causing severe performance issues during Angular's change detection cycles.

What is the new behavior?

The MutationObserver for parent removal detection is now skipped for controller-based modals and when the cached parent is the app root (document.body or ion-app). These parents are never removed from the DOM, so observing them is unnecessary. This prevents the performance issues while still maintaining the parent removal detection behavior for inline modals with meaningful parent elements.

Does this introduce a breaking change?

  • Yes
  • No

Other information

Current dev build:

8.7.12-dev.11765231260.1def96ab

@ShaneK ShaneK requested a review from a team as a code owner December 8, 2025 22:10
@ShaneK ShaneK requested a review from OS-jacobbell December 8, 2025 22:10
@vercel
Copy link

vercel bot commented Dec 8, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
ionic-framework Ready Ready Preview Comment Dec 10, 2025 9:03pm

@github-actions github-actions bot added the package: core @ionic/core package label Dec 8, 2025
Copy link
Contributor

@thetaPC thetaPC left a comment

Choose a reason for hiding this comment

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

LGTM, one question though

Copy link
Contributor

Choose a reason for hiding this comment

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

The ticket mentions that it's hard to create reliable test. Would it be possible to create a controller-based modal, open, then verify that we can still interact with the Angular test app? If it can interact, then it passes?

Copy link
Member Author

Choose a reason for hiding this comment

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

Well, that's kind of the thing. This test already "exists", there's e2e tests already doing this exact thing and they didn't break before. That's because the scenario itself is a bit unique and I'm not sure what actually makes it that way.

However, I think this might be a suitable alternative: da1911

In this commit I've created a test that ensures that controller-created modals do not have a mutation observer created for them, which should generally cover the bases here. Note: I had to use this PR as the "issue" because the actual issue is internal.

Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder if we can replicate it under the Angular test app instead of the core e2e tests? Regardless, I like your alternative! I'm happy with it. I only made one small suggestion.

Copy link
Contributor

@thetaPC thetaPC left a comment

Choose a reason for hiding this comment

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

LGTM, one minor request though

Co-authored-by: Maria Hutt <thetaPC@users.noreply.github.com>
@ShaneK ShaneK added this pull request to the merge queue Dec 10, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Dec 10, 2025
@ShaneK ShaneK added this pull request to the merge queue Dec 10, 2025
@ShaneK ShaneK removed this pull request from the merge queue due to a manual request Dec 10, 2025
@ShaneK ShaneK enabled auto-merge December 10, 2025 21:02
@ShaneK ShaneK added this pull request to the merge queue Dec 10, 2025
Merged via the queue into main with commit b164516 Dec 10, 2025
51 checks passed
@ShaneK ShaneK deleted the IONIC-60 branch December 10, 2025 21:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

package: core @ionic/core package

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants