FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

fix(animation): remove throw and fix promise handling by NathanWalker · Pull Request #5861 · NativeScript/NativeScript · GitHub

fix(animation): remove throw and fix promise handling - #5861

Merged
vakrilov merged 1 commit into
NativeScript:masterfrom
NathanWalker:fix-animation-another-throw
May 31, 2018
Merged

vakrilov merged 1 commit into
NativeScript:masterfrom
NathanWalker:fix-animation-another-throw

Conversation

NathanWalker commented May 24, 2018 •
edited
Loading

Copy link
Copy Markdown
Contributor

PR Checklist

What is the current behavior?

Usage of throw destabilizes apps during animation handling.

What is the new behavior?

Promise rejection is now removed around keyframe handling since there was no valid way to handle. With tracing enabled developers can now have meaningful and productive debug sessions.

NativeScript/nativescript-angular#431

ghost added the ♥ community PR label May 24, 2018
NathanWalker force-pushed the fix-animation-another-throw branch from d80bb16 to 78d58a9 Compare May 24, 2018 14:59

mid787 commented May 26, 2018

Copy link
Copy Markdown

@NathanWalker There is another place which should be fixed ( imho) :

Stack also shows it :

NathanWalker force-pushed the fix-animation-another-throw branch from 78d58a9 to 8d4277f Compare May 27, 2018 05:10

Copy link
Copy Markdown
Contributor Author

@RoyiNamir in your case above, anytime you use animation.play() it'd be best practice to wire up the success and error callbacks, ie:

animation.play(options).then(success => {
  //...
}, error => {
  //...
});

mid787 commented May 28, 2018 •
edited
Loading

Copy link
Copy Markdown

@NathanWalker Not only. In my case ^ it was when I added a class ( which contains as single animation-name with 1 iteration) and then removed that class.
Error appeared also.

Something like :

[ngClass]='{loadingClass:isLoading}'

So basically when isLoadingLogic finished , it removed that class , and caused this error.

Copy link
Copy Markdown
Contributor Author

@RoyiNamir good to know. Nice one and valid use case. Will update PR to handle that as well, thank you for clarifying.

NathanWalker force-pushed the fix-animation-another-throw branch 2 times, most recently from bf6aa97 to 00bc630 Compare May 30, 2018 02:37

Copy link
Copy Markdown
Contributor Author

@RoyiNamir There really should never be a rejection in keyframe animation handling since there's no proper way to handle it therefore this removes rejections altogether. Will solve your case and many others that have been reported over time around this. You may try the changes seen in this PR in your project and report back the results for you.

NathanWalker changed the title fix(animation): handle promise rejection and avoid throw fix(animation): remove throw and fix promise handling May 30, 2018

Copy link
Copy Markdown
Contributor

test

animation.play().then(() => {
this.animate(view, index + 1, iterations);
}, (error: any) => {
traceWrite(typeof error === "string" ? error : error.message, traceCategories.Animation, traceType.warn);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Just wondering - do you need both error callback and .catch()?

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

@vakrilov Why not ? if this.animate(view, index + 1, iterations); will throw ( for some reason) , it won't be cached in the callback of , (error: any) =>.
But - it will be catched in the catch.

http://jsbin.com/zujibirese/1/edit?html,js,output

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Due to number of reports around instability here I was keeping for assurance it was stopped.
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/catch
Technically the error callback appears preferred as catch internally calls rejected. I would presume an error callback is better everywhere instead of a catch based on way docs have it stated.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Although as @RoyiNamir points out I believe there are others cases that having both may provide utmost resiliency against.

ghost assigned vakrilov May 30, 2018
ghost added in progress and removed ♥ community PR labels May 30, 2018

Copy link
Copy Markdown
Contributor

test

NathanWalker force-pushed the fix-animation-another-throw branch from b9f1c0b to 39b41b4 Compare May 30, 2018 20:56
vakrilov merged commit 9308bab into NativeScript:master May 31, 2018
ghost removed the in progress label May 31, 2018

lock Bot commented Aug 26, 2019

Copy link
Copy Markdown

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

lock Bot locked and limited conversation to collaborators Aug 26, 2019
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants


Back | FazBrowse Home | New Git URL