Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove leaked renderers appeared on camera switch #507

Merged
merged 3 commits into from
Oct 27, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion Sources/LiveKit/Views/VideoView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -705,17 +705,24 @@ extension VideoView: VideoRenderer {
}
self._secondaryRenderer = nil
}

let previousPrimaryRendered = self._primaryRenderer
let completion: (Bool) -> Void = { _ in
previousPrimaryRendered?.removeFromSuperview()
}

// Currently only for iOS
#if os(iOS)
let (mode, duration, position) = _state.read { ($0.transitionMode, $0.transitionDuration, $0.captureDevice?.facingPosition) }
if let transitionOption = mode.toAnimationOption(fromPosition: position) {
UIView.transition(with: self, duration: duration, options: transitionOption, animations: block, completion: nil)
UIView.transition(with: self, duration: duration, options: transitionOption, animations: block, completion: completion)
} else {
block()
completion(true)
}
#else
block()
completion(true)
#endif
}
}
Expand Down
Loading