Hero icon indicating copy to clipboard operation
Hero copied to clipboard

pan quickly and app seems dead

Open mahomealex opened this issue 9 years ago • 7 comments

When we add panGesture to custom transaction progress to a single UIImageView, that's a probablity app seems dead if you pan fast. It happens like 10% in my 7PLUS. Your can try this on your demo: enter ImageViewController and just pan. By using Facebook's FLEX to move views away, and add some log, I found the problem and solved it. Here is the fixed code: open func animate() { // fullScreenSnapshot is general and add to subview. need to remove. guard let _ = toViewController, let _ = fromViewController else { fullScreenSnapshot?.removeFromSuperview() complete(finished: true) return } guard state == .starting else { return } state = .animating

mahomealex avatar Aug 31 '17 07:08 mahomealex

Can you confirm what you are seeing here? Sometimes my app appears to completely freeze, although it doesn't crash. It is unrecoverable, and impossible to replicate. From what I can gather from your code above, it creates a fullscreen snapshot that in some circumstances isn't being removed?

leeprobert avatar Sep 27 '17 08:09 leeprobert

Yep, it's the same situation I discribed. Add FLEX. to check what's happenning. Or just copy my code at the right pisition and u will see problem solved.

mahomealex avatar Sep 28 '17 11:09 mahomealex

I implemented your code and added a breakpoint with a log. I've caught a few potential freezes so I can confirm that this is an issue with interactive transitions. Fast swipes still behave strangely however; sometimes my next view appears complete without any animation. At least it isn't crashing though.

leeprobert avatar Oct 05 '17 09:10 leeprobert

I'm also having this issue, freezes if i do a quick pan, like a flick. Seems like Hero.shared.finish() is getting called too quickly by a quick pan and freezes when the internal state is .starting. if the internal state is .animating it doesn't freeze.

seems like calling complete() too early doesn't clean up the transition properly.

for now, i'm using the following hacky workaround to finish the animation when panning very quickly

    func endHero(finish: Bool) {
       // Wait for the state to be .animating, If the .state is starting will freeze
        if Hero.shared.state == .animating || Hero.shared.state == .possible {
            if finish {
                Hero.shared.finish(animate: true)
            } else {
                Hero.shared.cancel(animate: true)
            }
            
        } else {
            Hero.shared.update(finish ? 1 : 0)
            DispatchQueue.main.asyncAfter(deadline: .now() + 0.01) {
                self.endHero(finish: finish)
            }
        }
    }

hiroshihorie avatar Dec 30 '17 15:12 hiroshihorie

@HiroshiHorie, that seems to work. I was getting the same freeze.

bradphilips avatar Apr 02 '18 23:04 bradphilips

@bradphilips Yes, but it's a really hacky(not-recommended) workaround. I hope this issue gets fixed so I don't have to use this workaround.

hiroshihorie avatar Apr 03 '18 09:04 hiroshihorie

@HiroshiHorie This works so fine. Thanks~

pnecas avatar May 26 '18 17:05 pnecas