Hero icon indicating copy to clipboard operation
Hero copied to clipboard

navigation transition is delayed by 0.5s

Open kluku opened this issue 3 years ago • 5 comments

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

  • Hero Version: 1.5.0

  • iOS Version(s): 14.0, 14.2

  • Swift Version: 5

  • Devices/Simulators: iPhone 8 Plus (simulator), iPhone Xr iOS 14.0 (device)

  • Reproducible in Examples? (Yes/No): Yes, every time.

Demo Project

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

kluku avatar Dec 09 '20 11:12 kluku

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

hisham93 avatar Feb 22 '21 16:02 hisham93

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

zdurlan avatar Aug 31 '21 05:08 zdurlan

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

disczteam avatar Aug 31 '21 16:08 disczteam

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)
    }

}

sghiassy avatar Sep 04 '21 18:09 sghiassy

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)

jstoppenbach avatar Dec 20 '21 11:12 jstoppenbach