-
Notifications
You must be signed in to change notification settings - Fork 25.8k
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
Infinite loop with MutationObserver + browser zoom #31712
Comments
@eric-simonton-sama , there is a walk around about this one. import { Component, OnInit, NgZone } from '@angular/core';
import ResizeObserver from 'resize-observer-polyfill';
@Component({
selector: 'ngx-app',
templateUrl: 'app.component.html'
})
export class AppComponent {
array = new Array(20);
constructor(private ngZone: NgZone) {
this.ngZone.runOutsideAngular(() => {
new ResizeObserver(() => {}).observe(document.body);
});
}
} The reason is , So the infinite loop is,
so the walkaround is to make the MutationObserver callback outside of ngZone. |
Thank you for the workaround. To fix this in our real application it sounds like we would do as you suggest here, then manually trigger change detection from our resize handler when needed. That's better than having the browser crash! |
So we have recently run into this too (using 0.8.26). Weird part is, the components using the ResizeObserver and MutationObservers are built using StencilJS so they are not part of the Angular ecosystem. Are there workarounds for 3rd party libraries? |
Trying to integrate a custom component (WebComponent v1) with Angular app. The component uses MutationObserver for observing changes in native control, but falls into infinite loop while placed into Angular app. Template in the application:
In my component class:
Tried a proposed workaround with instantiating I'd appreciate any suggestion. |
@notbear, could you create a reproduce repo? |
@JiaLiPassion , sure. I borrowed the example from #31483 which seems to be very similar issue. During investigation, I noticed that webcomponents are not necessary to reproduce this bug. See examples: The But if you work with collection which reinstatiates object items like in the method |
Related tickets #26948 and #31483 were recently closed because of inactivity. I've just checked the example provided last time using latest versions of Angular and Zone (see versions below) and the issue still exists. But luckily... the known workaround with unwrapping Zone previously worked only for plain objects. Now it seems to help also for collections. Could you comment or confirm that it's been fixed somehow?
|
@IgorMinar and I looked at this and we think this is at least working as expected. Angular uses zones to drive change detection, so using APIs like |
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
Using a combination of
ngx-bootstrap
tooltips,MutationObserver
, and browser zooming it is possible to trigger an infinite loop that locks up the browser tab. Here is a plunker demonstrating the issue. Try different browser zoom levels, then mousing over the tooltips. For me it will lock the browser at 90% and 125% zoom, but not at 100% or 110%.I filed this issue with a couple other libraries while trying to nail down the culprit:
@que-etc mentioned
zone.js
as his prime suspect in that second link, thus I am filing this issue.Thanks for making Angular easier to use with this library!
The text was updated successfully, but these errors were encountered: