From 850a4e62ed95305ae12c4cf47b7a1f5ea840baac Mon Sep 17 00:00:00 2001 From: Krzysztof Moch Date: Mon, 29 Jan 2024 12:49:30 +0100 Subject: [PATCH 1/2] fix(ios): fix pip memory leak --- ios/Video/RCTVideo.swift | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/ios/Video/RCTVideo.swift b/ios/Video/RCTVideo.swift index 2fd5db9ce5..15cd885f79 100644 --- a/ios/Video/RCTVideo.swift +++ b/ios/Video/RCTVideo.swift @@ -140,7 +140,14 @@ 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 +200,7 @@ class RCTVideo: UIView, RCTVideoPlayerViewControllerDelegate, RCTPlayerObserverH deinit { NotificationCenter.default.removeObserver(self) self.removePlayerLayer() + _pip = nil _playerObserver.clearPlayer() } From 56764fb8403d3aee67fdcc55e2dbfddd672546fc Mon Sep 17 00:00:00 2001 From: Krzysztof Moch Date: Mon, 29 Jan 2024 13:15:24 +0100 Subject: [PATCH 2/2] lint code --- ios/Video/RCTVideo.swift | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/ios/Video/RCTVideo.swift b/ios/Video/RCTVideo.swift index 15cd885f79..d227e89e0c 100644 --- a/ios/Video/RCTVideo.swift +++ b/ios/Video/RCTVideo.swift @@ -140,14 +140,11 @@ class RCTVideo: UIView, RCTVideoPlayerViewControllerDelegate, RCTPlayerObserverH _eventDispatcher = eventDispatcher #if os(iOS) - _pip = RCTPictureInPicture( - { [weak self] in - self?._onPictureInPictureStatusChanged() - }, - { [weak self] in - self?._onRestoreUserInterfaceForPictureInPictureStop() - } - ) + _pip = RCTPictureInPicture({ [weak self] in + self?._onPictureInPictureStatusChanged() + }, { [weak self] in + self?._onRestoreUserInterfaceForPictureInPictureStop() + }) #endif NotificationCenter.default.addObserver(