mirror of
https://github.com/divkit/divkit.git
synced 2026-06-06 20:07:59 +00:00
Fix reentrancy in UICollectionView update
commit_hash:ce4744a962b2a9288486a90a5e67f6ea3c9f61a6
This commit is contained in:
@@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user