HeroTransitions / Hero

Elegant transition library for iOS & tvOS
https://HeroTransitions.github.io/Hero/
MIT License
22.06k stars 1.73k forks source link

navigation transition is delayed by 0.5s #689

Open kluku opened 3 years ago

kluku commented 3 years ago

What did you do?

I'm pushing a new view controller with Hero, nothing special. Going from the Home module to Search by tapping on the search field; the search field should move to the top.

navigationController.hero.isEnabled = true
navigationController.heroNavigationAnimationType = .fade
navigationController.pushViewController(searchModuleVC, animated: true)

In my Home module, I have the following configuration:

searchTextField.hero.id = UIConstants.HeroIDs.searchTextFieldId
searchTextField.hero.modifiers = [.translate()]

And in the search module just this:

searchTextField.hero.id = UIConstants.HeroIDs.searchTextFieldId

What did you expect to happen?

Well, the transition should happen.

What happened instead?

... and it does, but with a noticeable delay of 0.5s. I logged everything on the console and this is how it looks like:

2020-12-09 12:01:47.261124+0100 delegate called (textFieldShouldBeginEditing)
2020-12-09 12:01:47.261862+0100 showSearch will call push
2020-12-09 12:01:47.262464+0100 showSearch did call push
2020-12-09 12:01:47.796420+0100 [API] dead reply from commit sync

Note the delay of 0.53s and the last line. Before the console shows this line, nothing happens. It seems that the transition animation starts precisely when this line is printed on the console. Unfortunately, a quick google search for this log message doesn't show anything. When I disable Hero transition, there is no delay and no dead reply from commit sync line in the logs (just an ordinary "push" animation).

General Information

Demo Project

Unfortunately not allowed, maybe I'll create one from scratch later.

hisham93 commented 3 years ago

Try to use the following: searchTextField.hero.modifiers = [.useLayerRenderSnapshot] It solve the problem for me

zdurlan commented 3 years ago

Hey! I am experiencing the same issue, [.useLayerRenderSnapshot] did not work.

disczteam commented 3 years ago

I'm also experiencing this but searchTextField.hero.modifiers = [.useLayerRenderSnapshot] didn't seem to work for me

sghiassy commented 3 years ago

I'm experiencing the same thing. Here's a gif and a sample project in case it helps

fe65fd14-d8a3-4a52-a633-db6205fde48e

Sample App

HeroTestApp.zip

Code

The Sample App is basically a new stock Xcode project with just 1 ViewController with a ctr

import UIKit
import Hero

class ViewController: UIViewController {

    static var ctr = 1

    override func viewDidLoad() {
        super.viewDidLoad()
        self.isHeroEnabled = true
        self.view.backgroundColor = .white
        addButton()
    }

    func addButton() {
        let button = UIButton(frame: self.view.frame)
        button.hero.id = "daButton"
        self.view.addSubview(button)
        button.setTitleColor(.blue, for: .normal)
        button.setTitle("Button \(ViewController.ctr)", for: .normal)
        ViewController.ctr += 1
        button.addTarget(self, action: #selector(didTap), for: .touchUpInside)
    }

    @objc func didTap() {
        let nextVC = ViewController()
        nextVC.hero.modalAnimationType = .fade
        nextVC.isHeroEnabled = true
        self.present(nextVC, animated: true)
    }

}
jstoppenbach commented 2 years ago

I can add to this discussion that for me the delay is only noticeable when the new ViewController is presented modally. There is no delay when the new ViewController is added to the navigation stack via self.navigationController?.push. And I see the delay only on devices with iOS >= 15.

After some more evaluation I could narrow down the delay to the circumstance that the statusbar is being hidden in the modal view (triggered from its viewWillAppear)