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

Edge case where animation async event fires after loading was hidden #1100

Conversation

graemefoster
Copy link

Stop the race condition where the loading is hidden, but then the animation frame asynchronously kicks in.

ionic.DomUtil.centerElementByMargin(self.element[0]);
//One frame after it's visible, position it
ionic.requestAnimationFrame(function() {
if (self.isShown === undefined || self.isShown)
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we just do if (self.isShown) { here, and move this.isShown = true; above the requestAnimationFrame?

In reality, this.isShown will always be true inside this function, since requestAnimationFrame is called a few milliseconds later than everything else.

But in our unit tests, requestAnimationFrame is called instantly, so we can move isShown up for the sake of our tests.

@ajoslin
Copy link
Contributor

ajoslin commented Apr 10, 2014

Thanks again @graemefoster - left a couple of comments.

@ajoslin ajoslin self-assigned this Apr 10, 2014
@graemefoster
Copy link
Author

No worries - my laptop has died and I'm off on holiday tomorrow so won't be able to fix this up (sorry bout the line ending style). Feel free to close this and make the change. (I will get one of my pr's up soon!!)

There is a similar race in ionic backdrop. You can call release while the retain animation is running, and have the backdrop get stuck

Cheers

Graeme

Sent from my iPhone

On 10 Apr 2014, at 9:25 pm, "Andy Joslin" <[email protected]mailto:[email protected]> wrote:

Thanks again @graemefosterhttps://github.com/graemefoster - left a couple of comments.

Reply to this email directly or view it on GitHubhttps://github.com//pull/1100#issuecomment-40080587.

@ajoslin
Copy link
Contributor

ajoslin commented Apr 10, 2014

There's probably the same race in popup - I'll fix them all. Thanks and have a fun holiday, and yes we will definitely merge one of your PRs soon :-)

@graemefoster
Copy link
Author

Nice one :) cheers.

Grae

Sent from my iPhone

On 10 Apr 2014, at 9:30 pm, "Andy Joslin" <[email protected]mailto:[email protected]> wrote:

There's probably the same race in popup - I'll fix them all. Thanks and h a fun holiday, and yes we will definitely merge one of your PRs soon :-)

Reply to this email directly or view it on GitHubhttps://github.com//pull/1100#issuecomment-40081304.

@ajoslin ajoslin closed this in eb1dee9 Apr 10, 2014
ajoslin added a commit that referenced this pull request Apr 10, 2014
@robdmoore
Copy link

Hi @ajoslin,

Does the fix that you've committed also fix the race condition for the backdrop that Graeme mentioned above?

I've been working with Graeme so I have a reliable reproduction of the race condition to test this stuff on so I can test out any changes you make. This is currently blocking me from upgrading to the latest ionic (which I badly need to do to get the latest scrolling fixes) hence why I'm keen to follow this up.

Thanks

@ajoslin
Copy link
Contributor

ajoslin commented Apr 10, 2014

Hi @robdmoore,

I don't think backdrop has a race condition - it doesn't wait to add and remove the classes. Although I guess ngAnimate does have its own wait which could cause race conditions ... there is way to fix this though.

Could you post a reproduce case?

@ajoslin
Copy link
Contributor

ajoslin commented Apr 10, 2014

OK, I see the problem from @graemefoster's earlier backdrop PR (which I missed).

So my fix for popup and loading race conditions probably didn't fully work either.

Creating a generic fix.

ajoslin added a commit that referenced this pull request Apr 10, 2014
Addresses #1100.

Fixes race conditions where $animate.{removeClass,hideClass} are
called simultaneously, in addition fixes any blinking that coulld be
caused by showing an element just attached to the dom.
@ajoslin
Copy link
Contributor

ajoslin commented Apr 10, 2014

Ok @robdmoore, I just pushed an abstraction that gets rid of any possible race conditions, and also factors out blinking fixes.

Lemme know how it works once the travis build is done.

@robdmoore
Copy link

Awesome! You guys are great.

I'll grab the latest and let you know how I go :)

@robdmoore
Copy link

Hi @ajoslin,

It's almost perfect now. The race conditions are definitely gone in both the loading and the backdrop which is great!

The only thing now is, if the loading it asked to show and then hide before the delay time passed into the options then what happens is after that delay it shows up briefly (whereas it shouldn't show up at all since it had been asked to be hidden).

@robdmoore
Copy link

The other thing I noticed is that very occasionally the text on the loading modal is off-centre on my iPhone 4S, but it doesn't happen on Chrome.

@ajoslin
Copy link
Contributor

ajoslin commented Apr 11, 2014

raises pitchfork

die, ngAnimate!

ajoslin added a commit that referenced this pull request Apr 11, 2014
@ajoslin
Copy link
Contributor

ajoslin commented Apr 11, 2014

Can you test out the latest changes? Switched to regular old class changes & setTimeouts. Too many issues to deal with for ngAnimate in this case.

@ajoslin ajoslin reopened this Apr 11, 2014
@robdmoore
Copy link

Awesome! Great work on this mate - it seems perfect now :D

@robdmoore
Copy link

Also, hilarious pitchfork image :)

ajoslin added a commit that referenced this pull request Apr 11, 2014
@ajoslin
Copy link
Contributor

ajoslin commented Apr 11, 2014

Awesome :-)

@ajoslin ajoslin closed this Apr 11, 2014
ajoslin added a commit that referenced this pull request Apr 12, 2014
ajoslin added a commit that referenced this pull request Apr 12, 2014
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

Successfully merging this pull request may close these issues.

3 participants