diff --git a/Linphone/UI/Call/CallView.swift b/Linphone/UI/Call/CallView.swift index b4d0e890c..5e0e44be4 100644 --- a/Linphone/UI/Call/CallView.swift +++ b/Linphone/UI/Call/CallView.swift @@ -558,6 +558,10 @@ struct CallView: View { } } .onDisappear { + coreContext.doOnCoreQueue { core in + core.nativeVideoWindow = nil + } + if callViewModel.videoDisplayed { if !callViewModel.isPaused && TelecomManager.shared.callInProgress && !(coreContext.pipViewModel.pipController?.isPictureInPictureActive ?? false) { @@ -585,6 +589,11 @@ struct CallView: View { core.nativePreviewWindow = view } } + .onDisappear { + coreContext.doOnCoreQueue { core in + core.nativePreviewWindow = nil + } + } .aspectRatio(callViewModel.callStatsModel.sentVideoWindow.widthFactor/callViewModel.callStatsModel.sentVideoWindow.heightFactor, contentMode: .fill) .frame(maxWidth: callViewModel.callStatsModel.sentVideoWindow.widthFactor * 256, maxHeight: callViewModel.callStatsModel.sentVideoWindow.heightFactor * 256) @@ -703,6 +712,11 @@ struct CallView: View { core.nativePreviewWindow = view } } + .onDisappear { + coreContext.doOnCoreQueue { core in + core.nativePreviewWindow = nil + } + } .aspectRatio(callViewModel.callStatsModel.sentVideoWindow.widthFactor/callViewModel.callStatsModel.sentVideoWindow.heightFactor, contentMode: .fill) .frame(maxWidth: callViewModel.callStatsModel.sentVideoWindow.widthFactor * 256, maxHeight: callViewModel.callStatsModel.sentVideoWindow.heightFactor * 256) @@ -897,6 +911,9 @@ struct CallView: View { } } .onDisappear { + coreContext.doOnCoreQueue { core in + core.nativeVideoWindow = nil + } if !callViewModel.isPaused && TelecomManager.shared.callInProgress && !(coreContext.pipViewModel.pipController?.isPictureInPictureActive ?? false) { // TODO: Enable PIP in 6.1 @@ -978,6 +995,11 @@ struct CallView: View { core.nativePreviewWindow = view } } + .onDisappear { + coreContext.doOnCoreQueue { core in + core.nativePreviewWindow = nil + } + } .frame(width: angleDegree == 0 ? 120*1.2 : 160*1.2, height: angleDegree == 0 ? 160*1.2 : 120*1.2) .scaledToFill() .clipped() @@ -1143,6 +1165,11 @@ struct CallView: View { core.nativePreviewWindow = view } } + .onDisappear { + coreContext.doOnCoreQueue { core in + core.nativePreviewWindow = nil + } + } .frame(width: angleDegree == 0 ? 120*1.2 : 160*1.2, height: angleDegree == 0 ? 160*1.2 : 120*1.2) .scaledToFill() .clipped() @@ -1362,6 +1389,11 @@ struct CallView: View { core.nativePreviewWindow = view } } + .onDisappear { + coreContext.doOnCoreQueue { core in + core.nativePreviewWindow = nil + } + } .frame( width: 120 * ceil(maxValue / 120), height: 160 * ceil(maxValue / 120) @@ -1598,6 +1630,11 @@ struct CallView: View { core.nativePreviewWindow = view } } + .onDisappear { + coreContext.doOnCoreQueue { core in + core.nativePreviewWindow = nil + } + } .frame( width: 160 * ceil(maxValue / 120), height: 120 * ceil(maxValue / 120) diff --git a/Linphone/UI/Call/ViewModel/CallViewModel.swift b/Linphone/UI/Call/ViewModel/CallViewModel.swift index 0dd86b01f..010300aa3 100644 --- a/Linphone/UI/Call/ViewModel/CallViewModel.swift +++ b/Linphone/UI/Call/ViewModel/CallViewModel.swift @@ -714,10 +714,8 @@ class CallViewModel: ObservableObject { func displayMyVideo() { coreContext.doOnCoreQueue { core in guard let call = self.currentCall else { return } - - let invalidStates: [Call.State] = [.Released, .End, .Error, .Idle] - guard !invalidStates.contains(call.state) else { + guard call.state == .StreamsRunning else { Log.warn("\(CallViewModel.TAG) displayMyVideo called in invalid state: \(call.state), skipping update") return }