-
Notifications
You must be signed in to change notification settings - Fork 24.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
bug(perf): angular2/upgrade keeps running $rootScope.apply() if watchers call setTimeout #6245
Comments
@andreialecu can you provide a plunk that demonstrates the issue. I have a guess but I'd like to double check first. |
@PascalPrecht I'm trying to come up with a repro but I cannot seem to do it outside of my app. I noticed that this is where the repeated angular1 digests start from, which in turn cause the cascading effect: async_1.ObservableWrapper.subscribe(ngZone.onTurnDone, function (_) { ngZone.run(function () { return rootScope.$apply(); }); }); Transpiled from:
I'm not sure what that subscription is supposed to do, but it keeps triggering every tick of the app. I may have something somewhere that is interfering, as this is a relatively big app, but I'm not sure what to look for. Any clues as to what may be triggering that? |
So However, when we upgrade apps using That's basically what this line of code does. It's hard to say without a plunk why this ends in an infinite loop in your case, but it sounds like there are changes happening over and over again out of each performed change detection. Since you're using a pipe, which is not stateless ( OTOH, Angular should actually throw if after the first change detection another changes happened to your expression. This also depends on the version you're using. I think we really need a plunk that demonstrates your issue =/ |
BTW: this is the error I'm talking about: #6005 |
@PascalPrecht after a lot of trial and error, I finally figured out what is causing this. It's related to Here's a repro: http://plnkr.co/edit/rHGx6CoX2lKy6WVFMkFI?p=preview Open the developer console to see the |
Note how removing this block completely solves the problem: $rootScope.$watch(function() {
_debounce || (_debounce = setTimeout(function() {
_debounce = null;
}, 100));
}); |
Well, this seems to be completely blocking the upgrade for us. I'd attempt to submit a PR, but it seems like the core of ng-zone is affected. Might be an easy fix though... @mhevery ? :) |
Changing upgrade_adapter.ts line 341: ObservableWrapper.subscribe(ngZone.onTurnDone,
(_) => { ngZone.run(() => rootScope.$apply()); }); To ObservableWrapper.subscribe(ngZone.onTurnDone,
(_) => { ngZone.runOutsideAngular(() => rootScope.$apply()); }); Fixes the infinite loop. |
Looks like there are still various timers outside of the angular2 zone which get caught in the
This makes upgrading any non trivial app impossible for production purposes. Guess everyone is on vacation still, but some acknowledgement here would be nice. The repro should be pretty clear. |
Closing in favor or #6385 which has simpler repro. |
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. |
I'm trying to upgrade an existing angular1 app to angular2 using the
angular2/upgrade
functionality.I have noticed that after using
angular2/upgrade
to bootstrap the app, I'm now getting angular1 digests on every single tick, and it tracks down to this line (discovered using the CPU profiler):angular/modules/angular2/src/upgrade/downgrade_ng2_adapter.ts
Line 103 in 56a254e
I have an angular2 pipe that is configured as
pure: false
and itstransform
method seems to be executed on every single tick of the page. And since I'm using it inside an*ngFor
and there are a lot of them on the page, the browser becomes unusable.Here's a trace using Chrome's profiler
Am I doing something wrong or is this a bug?
EDIT: Repro at #6245 (comment)
The text was updated successfully, but these errors were encountered: