Page MenuHomePhabricator

iOS 13 [Bug] Move setup code from traitCollectionDidChange
Closed, ResolvedPublic

Description

in iOS 13, traitCollectionDidChange might not be called when view is added to to the view hierarchy. In some places, we use traitCollectionDidChange to set fonts. If traitCollectionDidChange isn't called on setup, the initial state of the layout will be off. We should make sure we run additional setup code once in layoutSubviews as recommended by Apple in the release notes.

Context:

The traitCollectionDidChange(_:) method is only called when the value of a trait changes. Importantly, because the trait collection is now initialized to a prediction of the ultimate traits in the destination hierarchy, when the initial predicted traits match the ultimate traits in the hierarchy, traitCollectionDidChange(_:) will not be called when the trait environment is added to the hierarchy. Because traitCollectionDidChange(_:) is intended to be an invalidation callback to notify you that one or more traits changed, audit your existing implementations of this method, as well as the UIContentContainer method willTransition(to:with:), for places where you might have been relying on it to trigger initial setup. The best place to lazily perform work that uses the traitCollection is inside one of the layoutSubviews methods discussed above, but remember that these layout methods are called any time layout occurs so be sure to avoid repeating work when you don’t need to.

https://developer.apple.com/documentation/ios_ipados_release_notes/ios_ipados_13_beta_6_release_notes

Event Timeline

LGoto triaged this task as Medium priority.Aug 19 2019, 6:47 PM
LGoto moved this task from Needs Triage to Engineering Backlog on the Wikipedia-iOS-App-Backlog board.

@NHarateh_WMF - Are there any specific steps to reproduce this one? Thanks