InputBarAccessoryView icon indicating copy to clipboard operation
InputBarAccessoryView copied to clipboard

iOS 14 Delayed Display

Open JCsplash opened this issue 4 years ago • 6 comments

Bug Description On iOS 14 devices, constraints on InputBarAccessoryView's leftStackView, rightStackView, and inputTextView fail to load immediately.

This is evident in the inputTextView's placeholder and left & right buttons not appearing until well after the view has loaded.

It seems like iOS 14 introduced some sort of layout delay that doesn't play well with how constraints are activated and deactivated in InputBarAccessoryView. This issue doesn't exist on iOS 13.

To Reproduce

Note: For some reason, this bug only happens if there isn't much activity on the main thread. For example, if a tableView has many cells and calls reloadData on viewDidLoad, this input bar loads correctly. However if the tableView has 1 or 2 cells, there's bug appears.

  1. Change the sample projects number of sample messages to zero, such that numberOfRowsInSection returns 0.
    func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return conversation.messages.count
    }
  1. Run the project on an iOS 14 device or simulator and press the iMessage input bar without any customizations. You should see a delay in the loading.

Expected behavior There should not be a delay when loading an InputBarAccessoryView. Behavior should be like iOS 13.

Screenshots bug-report-inputBarAccessoryView

Environment

  • Version: 5.1.0
  • iOS 14 and above
  • Swift 5.3
  • iPhone 12 Pro (iOS 14.2.1), iPhone 7 (iOS 13.4 - No Problem)
  • Is the issue you're experiencing reproducable in the example app? - Yes.

Current Workaround

Make an extra performLayout call on the main thread on iOS 14 devices right after initializing the input bar. Careful not to call this on iOS 13 (and below) devices as it'll produce the same delay as described above for iOS 14 devices. Not sure why. The code below should be a temporary workaround.

if #available(iOS 14, *) {
      let yourStackViewWidth = 52
      DispatchQueue.main.async { self.setRightStackViewWidthConstant(to: yourStackViewWidth, animated: false) }
}

JCsplash avatar Feb 06 '21 10:02 JCsplash

@JCsplash thanks for the walk around for now

yarodevuci avatar Feb 16 '21 01:02 yarodevuci

Same issue for me too, coming from MessageKit (the workaround worked for me though)

bryan-vh avatar Mar 02 '21 21:03 bryan-vh

Issue came back in OS15...

yarodevuci avatar Jan 29 '22 22:01 yarodevuci

@yarodevuci Workaround still works?

Kaspik avatar Feb 03 '22 11:02 Kaspik

@yarodevuci Workaround still works?

@Kaspik nope. Sometimes it does sometimes no

yarodevuci avatar Feb 04 '22 03:02 yarodevuci

I'm not seeing this on iOS 16. @yarodevuci is this issue persisting for you on iOS 15?

nathantannar4 avatar Oct 05 '22 07:10 nathantannar4