UINavigationController.popToViewController with animation results in wrong view controller stack

Number:rdar://FB8739379 Date Originated:2020-09-24
Status:Open Resolved:
Product:UIKit Product Version:Xcode 12.0 (12A7209)
Classification:Bug Reproducible:true
With UIKit version shipped with Xcode 12.0 (12A7209), calling `UINavigationController.popToViewController(vc, animated: true)` results in the `viewControllers` property containing unexpected controllers. Specifically, if the starting stack has controller

[a, b, c, d]

`.popToController(b, animated: true)` would result in the incorrect controller stack after the animation.

Expected result:

`.viewControllers` property contains [a, b]

Actual result:

`.viewControllers` property contains [d, a, b]

It’s weird. This problem was discovered and discussed here https://developer.apple.com/forums/thread/656524

In that thread it’s supposed to have been reported as FB8626373 as well. Consider this report a duplicate if that’s the case.


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!