Hero: Freezing screen after navigating back and forth between screens

Created on 13 Jan 2019  路  16Comments  路  Source: HeroTransitions/Hero

I create transaction from tableView to ViewController with animation some images from cell to view.
After fore of five transactions to and back, transaction freezing. It's look like viewcontroller dismissed but snapshot view still showing.
I guess my view controller closed before animation is completed.
Usually I close viewcontoller self.dismiss(animated: true, completion: nil)

All 16 comments

i faced Same issue @Maxim-Zakopaylov did you find any solution?

screenshot 2019-01-29 at 3 53 58 pm
i close Controller using hero.dismissViewController()

Unfortunately not. I really hope on this ticket.

I have the same problem(

Same problem, dude

Have you tried to call dismiss function in main thread ?
DispatchQueue.main.async { self.dismiss(animated: true, completion: nil) }

I had the same issue when using a UIPanGestureRecognizer synced with Hero and main thread fixed it.

@jeffjfk Yes, I tried but it did not help(

have the same problem but, setting false to animated solve the problem with no animation. self.navigationController?.pushViewController(vc, animated: false)

Hi @Maxim-Zakopaylov ! Any updates?

Hi @alexanderkhitev did you use any layoutIfNeeded()

@alexanderkhitev Unfortunately not. I started use another project (https://github.com/CosmicMind/Motion)

@Maxim-Zakopaylov thanks for answer

Hi @jensonjohn001 no, I don't use layoutIfNeeded in close function

@jensonjohn001 My problem is that I have two modal UIVIewControllers, they have modalPresentationStyle = .overFullScreen and in one of the scenarios I need to hide them without animation at once

reproduced the same issue with the official sample, List to Grid, switch to grid mode, then swipe down the large image view, fast and frequently.

Calling finish and cancel like this solved the problem for me:

extension HeroTransition {
    func cancelOnMain(animate: Bool = true) {
        DispatchQueue.main.async {
            Hero.shared.cancel(animate: animate)
        }
    }

    func finishOnMain(animate: Bool = true) {
        DispatchQueue.main.async {
            Hero.shared.finish(animate: animate)
        }
    }
}

I was already calling them on the main thread (tested) so it must have been this async that helped...

I also have the same problem with navigation controller push and pop transition.
It will not be solved by finish and cancel in the main thread.

Was this page helpful?
0 / 5 - 0 ratings