fix(ios): fix pip memory leak (#3506)

* fix(ios): fix pip memory leak

* lint code
This commit is contained in:
Krzysztof Moch 2024-01-30 08:33:33 +01:00 committed by GitHub
parent aec7db6390
commit 53068ddd41
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -140,7 +140,11 @@ class RCTVideo: UIView, RCTVideoPlayerViewControllerDelegate, RCTPlayerObserverH
_eventDispatcher = eventDispatcher _eventDispatcher = eventDispatcher
#if os(iOS) #if os(iOS)
_pip = RCTPictureInPicture(self._onPictureInPictureStatusChanged, self._onRestoreUserInterfaceForPictureInPictureStop) _pip = RCTPictureInPicture({ [weak self] in
self?._onPictureInPictureStatusChanged()
}, { [weak self] in
self?._onRestoreUserInterfaceForPictureInPictureStop()
})
#endif #endif
NotificationCenter.default.addObserver( NotificationCenter.default.addObserver(
@ -193,6 +197,7 @@ class RCTVideo: UIView, RCTVideoPlayerViewControllerDelegate, RCTPlayerObserverH
deinit { deinit {
NotificationCenter.default.removeObserver(self) NotificationCenter.default.removeObserver(self)
self.removePlayerLayer() self.removePlayerLayer()
_pip = nil
_playerObserver.clearPlayer() _playerObserver.clearPlayer()
} }