From c9e4d5b042fffcdcc2437a231017ba64a1548608 Mon Sep 17 00:00:00 2001 From: Ilias Pavlidakis Date: Tue, 16 Jan 2024 18:34:14 +0200 Subject: [PATCH] Only access the reused view when the view is presented --- .../StreamVideoSwiftUI/CallView/VideoParticipantsView.swift | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Sources/StreamVideoSwiftUI/CallView/VideoParticipantsView.swift b/Sources/StreamVideoSwiftUI/CallView/VideoParticipantsView.swift index 6f53e8d6c..5bc22055e 100644 --- a/Sources/StreamVideoSwiftUI/CallView/VideoParticipantsView.swift +++ b/Sources/StreamVideoSwiftUI/CallView/VideoParticipantsView.swift @@ -327,6 +327,8 @@ public struct VideoCallParticipantView: View { var customData: [String: RawJSON] var call: Call? + @State private var isVisible = false + public init( participant: CallParticipant, id: String? = nil, @@ -350,7 +352,7 @@ public struct VideoCallParticipantView: View { id: id, size: availableFrame.size, contentMode: contentMode, - showVideo: showVideo, + showVideo: showVideo && isVisible, handleRendering: { [weak call] view in guard call != nil else { return } view.handleViewRendering(for: participant) { size, participant in @@ -360,6 +362,8 @@ public struct VideoCallParticipantView: View { } } ) + .onAppear { isVisible = true } + .onDisappear { isVisible = false } .opacity(showVideo ? 1 : 0) .edgesIgnoringSafeArea(edgesIgnoringSafeArea) .accessibility(identifier: "callParticipantView")