From 53068ddd41218bb615cd129eba2c36d6347ccf25 Mon Sep 17 00:00:00 2001 From: Krzysztof Moch Date: Tue, 30 Jan 2024 08:33:33 +0100 Subject: [PATCH] fix(ios): fix pip memory leak (#3506) * fix(ios): fix pip memory leak * lint code --- ios/Video/RCTVideo.swift | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/ios/Video/RCTVideo.swift b/ios/Video/RCTVideo.swift index 2fd5db9c..d227e89e 100644 --- a/ios/Video/RCTVideo.swift +++ b/ios/Video/RCTVideo.swift @@ -140,7 +140,11 @@ class RCTVideo: UIView, RCTVideoPlayerViewControllerDelegate, RCTPlayerObserverH _eventDispatcher = eventDispatcher #if os(iOS) - _pip = RCTPictureInPicture(self._onPictureInPictureStatusChanged, self._onRestoreUserInterfaceForPictureInPictureStop) + _pip = RCTPictureInPicture({ [weak self] in + self?._onPictureInPictureStatusChanged() + }, { [weak self] in + self?._onRestoreUserInterfaceForPictureInPictureStop() + }) #endif NotificationCenter.default.addObserver( @@ -193,6 +197,7 @@ class RCTVideo: UIView, RCTVideoPlayerViewControllerDelegate, RCTPlayerObserverH deinit { NotificationCenter.default.removeObserver(self) self.removePlayerLayer() + _pip = nil _playerObserver.clearPlayer() }