Skip to content
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

performance issue #14

Open
esoni88 opened this issue Jan 5, 2019 · 6 comments
Open

performance issue #14

esoni88 opened this issue Jan 5, 2019 · 6 comments

Comments

@esoni88
Copy link

esoni88 commented Jan 5, 2019

Hi All,
if i open many dialogs i have a performance issue due too many change detection.
Why on init in golden layout component of your lib you use this code

....

this.appref.tick = (): void => {
  for (const ar of (this.topWindow as any).__apprefs) {
    ar._zone.run(() => ar.__tick());
  }
};

in this way for a tick in child window is performed tick on other child windows and also in root.
can you explain better ?
thanks

@esoni88
Copy link
Author

esoni88 commented Jan 5, 2019

i think it is a better solution :

public ngOnInit(): void {

const anyWin = this.topWindow as any;
if (!this.isChildWindow) {
  anyWin.__apprefs = [];
  anyWin.__injector = this.injector;
  anyWin.__rootRef = this.appref;
}

// attach the application reference to the root window, save the original 'tick' method
anyWin.__apprefs.push(this.appref);
(this.appref as any).__tick = this.appref.tick;

this.appref.tick = (): void => {
  if (!this.isChildWindow) {
    (this.appref as any).__tick();
  } else {
    (this.appref as any).__tick();
    anyWin.__rootRef._zone.run(() => anyWin.__rootRef.__tick());

  }

};

}

in this way for child window tick : in only execute tick on parent and on that window and not on all window opened

@martin31821
Copy link
Member

That's a fairly complex topic. In my use case, we have state shared between all windows, so the change detection needs to be run in all windows simultaneously.

Also note that this largely depends on your state management pattern, we use a redux-like pattern with OnPush change detection in most components, so performance isn't that much impacted for us.

Maybe a solution is to add a switch which changes this behavior between the original solution and the one you found.

@martin31821
Copy link
Member

@dario-frongillo in the latest commit, I refactored the tick procedure to be contained in a service, if you still have this problem, we might be able to add a flag changing the change detection propagation between the windows now.

@esoni88
Copy link
Author

esoni88 commented Sep 8, 2019

@martin31821 Can you please link the commit change ?

@martin31821
Copy link
Member

There you go: 83fbd30

@martin31821
Copy link
Member

@dario-frongillo is this still a problem or did you get around the issue?

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

No branches or pull requests

2 participants