diff --git a/Signal/src/ViewControllers/GifPicker/GifPickerCell.swift b/Signal/src/ViewControllers/GifPicker/GifPickerCell.swift index 99109c8670..7ad5cd99d9 100644 --- a/Signal/src/ViewControllers/GifPicker/GifPickerCell.swift +++ b/Signal/src/ViewControllers/GifPicker/GifPickerCell.swift @@ -166,6 +166,7 @@ class GifPickerCell: UICollectionViewCell { assetDescription: previewAssetDescription, priority: .low, success: { [weak self] assetRequest, asset in + AssertIsOnMainThread() guard let self = self else { return } guard assetRequest == self.previewAssetRequest else { owsFailDebug("Obsolete request callback.") @@ -176,6 +177,7 @@ class GifPickerCell: UICollectionViewCell { self.ensureViewState() }, failure: { [weak self] assetRequest in + AssertIsOnMainThread() guard let self = self else { return } guard assetRequest == self.previewAssetRequest else { owsFailDebug("Obsolete request callback.") @@ -187,6 +189,8 @@ class GifPickerCell: UICollectionViewCell { } private func ensureViewState() { + AssertIsOnMainThread() + guard isCellVisible, let asset = previewAsset else { // Nothing to show, clearViewState() @@ -216,6 +220,8 @@ class GifPickerCell: UICollectionViewCell { } private func clearViewState() { + AssertIsOnMainThread() + imageView.image = nil imageView.isHidden = true mp4View.video = nil diff --git a/SignalMessaging/Views/ManualLayoutView.swift b/SignalMessaging/Views/ManualLayoutView.swift index 6b9b8318fb..b8443cc76f 100644 --- a/SignalMessaging/Views/ManualLayoutView.swift +++ b/SignalMessaging/Views/ManualLayoutView.swift @@ -113,6 +113,8 @@ open class ManualLayoutView: UIView { } func viewSizeDidChange() { + AssertIsOnMainThread() + layoutSubviews() } @@ -151,6 +153,8 @@ open class ManualLayoutView: UIView { // MARK: - Reset open func reset() { + AssertIsOnMainThread() + removeAllSubviews() layoutBlocks.removeAll() diff --git a/SignalMessaging/Views/ManualStackView.swift b/SignalMessaging/Views/ManualStackView.swift index 605ba447bd..07b1bfd993 100644 --- a/SignalMessaging/Views/ManualStackView.swift +++ b/SignalMessaging/Views/ManualStackView.swift @@ -98,8 +98,10 @@ open class ManualStackView: ManualLayoutView { // We cache the resolved layout of the subviews. private var arrangement: Arrangement? { didSet { - invalidateIntrinsicContentSize() - setNeedsLayout() + if arrangement != nil { + invalidateIntrinsicContentSize() + setNeedsLayout() + } } } @@ -111,8 +113,6 @@ open class ManualStackView: ManualLayoutView { public func invalidateArrangement() { arrangement = nil - invalidateIntrinsicContentSize() - setNeedsLayout() } public override func sizeThatFits(_ size: CGSize) -> CGSize { @@ -587,6 +587,8 @@ open class ManualStackView: ManualLayoutView { } open override func reset() { + AssertIsOnMainThread() + super.reset() alignment = .fill