Skip to content

[spinner @alpha 9] AoT compilation causes high CPU use via requestAnimationFrame() #1570

@RoxKilly

Description

@RoxKilly

Bug, feature request, or proposal:

Bug

What is the expected behavior?

  • md-spinner should not use more CPU when app is AoT compiled than when it is JiT compiled
  • md-spinner should not use CPU resources once it is taken out of the DOM

What is the current behavior?

App uses AoT compilation (JiT is not affected) and has <md-spinner> in the template

  • High CPU usage even once the spinner is removed from the DOM
  • Zonetask.invoke calls window.requestAnimationFrame in an infinite loop, choking the CPU
  • Minimizing the browser brings CPU utilization down. Restoring does the opposite

What are the steps to reproduce?

app.component.html

<md-card-content *ngIf="loading">
    <md-spinner></md-spinner>
</md-card-content>
<md-card-content *ngIf="!loading">
    Content goes here
</md-card-content>

loading===true when AppComponent loads, so the spinner is shown. In ngOnInit, after data fetched from the server is received, loading=false. The spinner disappears but CPU utilization remains high. This only affects AoT app (not in-browser compiled JiT app).

I replaced

<md-spinner></md-spinner>

with...

<md-progress-bar mode="indeterminate"></md-progress-bar>

and I no longer experience the problem.

What is the use-case or motivation for changing an existing behavior?

This makes md-spinner too costly to use with AoT compilation

Which versions of Angular, Material, OS, browsers are affected?

Tested on Angular 2.0.1, @angular/compiler-cli 0.6.4, Material 9-3, Firefox 49, Chrome 54, Windows 7 x64

Is there anything else we should know?

Get more details from this issue

Metadata

Metadata

Assignees

Labels

P3An issue that is relevant to core functions, but does not impede progress. Important, but not urgent

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions