Skip to content

Commit 654410b

Browse files
authored
Fix VideoView.isHidden crash (#681)
Resolves #678 Follow-up of #679 I managed to reproduce the issue, steps: - open example app on iPhone (non-sample buffer mode) - join from e.g. macOS - publish/unpublish camera track on mac The diagnosis was correct - logs are coming via unsafe `UIView`/`NSObject` territory, so main actor isolated props are listed from bg threads. The last one was `isHidden`. I also overrode the `description` string, just in case... for every descendant of `NativeView` (that may inherit the description). <img width="1483" alt="Screenshot 2025-04-22 at 10 40 14 AM" src="https://github.com/user-attachments/assets/441d9bd8-6ecd-4b45-93b0-34517c6dab2b" />
1 parent 820c3d0 commit 654410b

File tree

3 files changed

+27
-2
lines changed

3 files changed

+27
-2
lines changed

.nanpa/video-view-hidden-crash.kdl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
patch type="fixed" "Fixed crash in VideoView.isHidden property access"

Sources/LiveKit/Extensions/CustomStringConvertible.swift

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,14 @@ extension Livekit_SignalResponse: CustomStringConvertible {
157157
}
158158
}
159159

160+
// MARK: - NativeView
161+
162+
public extension VideoView {
163+
override var description: String {
164+
"VideoView(track: \(String(describing: track)))"
165+
}
166+
}
167+
160168
extension VideoView.RenderMode: CustomStringConvertible {
161169
public var description: String {
162170
switch self {
@@ -167,6 +175,20 @@ extension VideoView.RenderMode: CustomStringConvertible {
167175
}
168176
}
169177

178+
extension SampleBufferVideoRenderer {
179+
override var description: String {
180+
"SampleBufferVideoRenderer"
181+
}
182+
}
183+
184+
extension TextView {
185+
override var description: String {
186+
"TextView"
187+
}
188+
}
189+
190+
// MARK: - LKRTC
191+
170192
extension LKRTCRtpEncodingParameters {
171193
func toDebugString() -> String {
172194
"RTCRtpEncodingParameters(" +

Sources/LiveKit/Views/VideoView.swift

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,11 +120,13 @@ public class VideoView: NativeView, Loggable {
120120
}
121121

122122
@objc
123-
override public var isHidden: Bool {
123+
override public nonisolated var isHidden: Bool {
124124
get { _state.isHidden }
125125
set {
126126
_state.mutate { $0.isHidden = newValue }
127-
super.isHidden = newValue
127+
Task { @MainActor in
128+
super.isHidden = newValue
129+
}
128130
}
129131
}
130132

0 commit comments

Comments
 (0)