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

perf(progress-circle): clean up animation on destroy #617

Merged
merged 1 commit into from
Jun 3, 2016

Conversation

crisbeto
Copy link
Member

@crisbeto crisbeto commented Jun 2, 2016

The indeterminate animation is based on an interval that keeps running, even after the element has been destroyed.
This change cleans up when the element is destroyed.

Also adds an extra null check for performance.now.

@googlebot googlebot added the cla: yes PR author has agreed to Google's Contributor License Agreement label Jun 2, 2016
@jelbourn
Copy link
Member

jelbourn commented Jun 2, 2016

@crisbeto Can you add a unit test for this?

@crisbeto crisbeto force-pushed the perf/circle-cleanup branch 2 times, most recently from 992822e to c008804 Compare June 2, 2016 19:50
@crisbeto
Copy link
Member Author

crisbeto commented Jun 2, 2016

Done @jelbourn, although some of the CI builds are failing because of unrelated issues. (missing requestAnimationFrame, Node errors)

.then((fixture) => {
fixture.detectChanges();
let progressElement = getChildDebugElement(fixture.debugElement, 'md-progress-circle');
expect(progressElement.componentInstance._interdeterminateInterval).toBeTruthy();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can't access the private member here; The field either needs to be changed to /** @internal */ or we need some other proxy for checking that the interval has stopped.

@jelbourn
Copy link
Member

jelbourn commented Jun 2, 2016

Only remaining CI errors are lint

@crisbeto crisbeto force-pushed the perf/circle-cleanup branch 2 times, most recently from c7a6abf to bedbfda Compare June 2, 2016 21:20
@crisbeto
Copy link
Member Author

crisbeto commented Jun 2, 2016

It's updated to use a getter/setter on the interval and resetting it on the setter instead to avoid intervals stacking up. The CI is still throwing a Node ELIFECYCLE error, though.

@jelbourn
Copy link
Member

jelbourn commented Jun 2, 2016

That node error message is just garbage that gets thrown when there's a tslint error. The actual problem is just above:
https://travis-ci.org/angular/material2/jobs/134867948#L264

/** The id of the last requested animation. */
private _lastAnimationId: number = 0;

/** The id of the indeterminate interval. */
private _interdeterminateInterval: number;
get interdeterminateInterval() {
Copy link
Member

@jelbourn jelbourn Jun 2, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be marked as /** @internal */

@crisbeto
Copy link
Member Author

crisbeto commented Jun 2, 2016

There we go. @jelbourn.

EDIT: Regarding wrapping the tests in async, I'll submit another PR that switches all of the progress circle tests so they match the ones in other components.

/** The id of the indeterminate interval. */
/**
* The id of the indeterminate interval.
* @internal
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The @internal actually goes on the public member rather than the private one; this tells TypeScript to omit the property when outputting a .d.ts file so that downstream users can't depend on it.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I'm still not too familiar with all the ng2 concepts. It's updated now.

The indeterminate animation is based on an interval that keeps running, even after the element has been destroyed.
This change cleans up when the element is destroyed.

Also adds an extra null check for `performance.now`.
@jelbourn
Copy link
Member

jelbourn commented Jun 3, 2016

LGTM

@jelbourn jelbourn merged commit 63f43bd into angular:master Jun 3, 2016
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 6, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
cla: yes PR author has agreed to Google's Contributor License Agreement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants