akveo / akveo/ngx-admin

Major performance concerns with pace-js

未关闭
#1,628 2 条评论 1 个 reaction 已指派 0 人 在 GitHub 查看
bug P1: urgent
主要语言
TypeScript
星标
25.7k
派生
7.9k
PR 合并指标
30 天内没有已合并 PR

描述

### Issue type

**I'm submitting a ...** (check one with "x")

* [x] bug report
* [ ] feature request
* [x] question about the decisions made in the repository

### Issue description

**Current behavior:**
Its seems that change detection is called way too many times on most pages. With the starter kit, the [`NbLoginComponent`](https://github.com/akveo/nebular/blob/c8273da500bfd6315be42be9427fa9e477e83778/src/framework/auth/components/login/login.component.ts) causes method `getConfigValue()` to be called roughly 350 times in Safari and 230 in Chrome. When the page takes a while to load in Chrome, the counter goes up to 5000+ calls after a few seconds.

When removing `pace-js` (loading bar at the top), the counter drops down to 20 on both Safari and Chrome, yet acceptable but still a bit high IMO.

**Expected behavior:**
Considering that `getConfigValue()` is used twice in the [`NbLoginComponent` template](), and also considering that change detection runs twice as more in Angular CLI's dev mode, I would still expect the number of calls to be around 2-6, not ~90 times (350/2/2). I have tried a production build and the number drops (as expected) to roughly half that amount, but still remains too high.

**Steps to reproduce:**
- Clone the [starter kit](https://github.com/akveo/ngx-admin/tree/starter-kit) of this repository.
- Create a login component identical to [Nebular's default `NbLoginComponent`](https://github.com/akveo/nebular/blob/c8273da500bfd6315be42be9427fa9e477e83778/src/framework/auth/components/login/login.component.ts).
- Change the following lines:
```
getConfigValue(key: string): any {
return getDeepFromObject(this.config, key, null);
}
```
to
```
private count: number = 0;

getConfigValue(key: string): any {
this.count++;
console.log(this.count);
return getDeepFromObject(this.config, key, null);
}
```
- Start the application and look at the console:
- Safari 11.1 (12605.1.33.1.3):
![screen shot 2018-04-09 at 17 17 04](https://user-images.githubusercontent.com/37196867/38506520-64219edc-3c1a-11e8-8f29-830d4df0fb66.png)
- Chrome 65.0.3325.181 (Official Build) (64-bit)
![screen shot 2018-04-09 at 17 29 04](https://user-images.githubusercontent.com/37196867/38506953-95a0a6a0-3c1b-11e8-9a95-7ff429e22ffa.png)

And without `pace-js`:
- Safari:
![screen shot 2018-04-09 at 17 44 34](https://user-images.githubusercontent.com/37196867/38508488-a3faebee-3c1f-11e8-8e12-eef2530f601c.png)
- Chrome:
![screen shot 2018-04-09 at 17 43 43](https://user-images.githubusercontent.com/37196867/38508503-aea8a70c-3c1f-11e8-9719-176e25fb4e59.png)

**Related code:**

### Other information:

**npm, node, OS, Browser**
```
node v7.1.0
nom v4.6.1
```

**Angular, Nebular**
```
ngx-admin v2.1.0
```

贡献指南

打开贡献指南

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。