From da5ef064c675f1a2da91ab49aa2fafb78c8a4ce7 Mon Sep 17 00:00:00 2001 From: booster Date: Thu, 23 Apr 2026 16:55:28 +0300 Subject: [PATCH] Fix reentrancy in UICollectionView update commit_hash:ce4744a962b2a9288486a90a5e67f6ea3c9f61a6 --- .../VideoBlock+UIViewRenderableBlock.swift | 20 ++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/client/ios/LayoutKit/LayoutKit/UI/Blocks/VideoBlock+UIViewRenderableBlock.swift b/client/ios/LayoutKit/LayoutKit/UI/Blocks/VideoBlock+UIViewRenderableBlock.swift index 29629ab60..930a9bf5d 100644 --- a/client/ios/LayoutKit/LayoutKit/UI/Blocks/VideoBlock+UIViewRenderableBlock.swift +++ b/client/ios/LayoutKit/LayoutKit/UI/Blocks/VideoBlock+UIViewRenderableBlock.swift @@ -58,9 +58,9 @@ private final class VideoBlockView: BlockView, VisibleBoundsTrackingContainer { ) playerSignal = player?.signal.addObserver { [weak self] event in - onMainThread { - guard let self else { return } + guard let self else { return } + let action = { switch event { case let .currentTimeUpdate(time): self.model.elapsedTime?.value = Int(time) @@ -90,6 +90,16 @@ private final class VideoBlockView: BlockView, VisibleBoundsTrackingContainer { self.model.duration?.value = duration } } + + if window == nil { + onMainThread { + action() + } + } else { + onMainThreadAsync { + action() + } + } } player.flatMap { videoView?.attach(player: $0) } @@ -243,9 +253,9 @@ extension [String: Any] { extension VideoScale { fileprivate var previewContentMode: UIView.ContentMode { switch self { - case .fill: return .scaleAspectFill - case .fit: return .scaleAspectFit - case .noScale: return .center + case .fill: .scaleAspectFill + case .fit: .scaleAspectFit + case .noScale: .center } } }