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
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?
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.
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.
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
````swift
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, that seems to work. I was getting the same freeze.
@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 This works so fine. Thanks~
Most helpful comment
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
````swift
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)
}
````