Skip to content

Commit

Permalink
fix(ios): fix pip memory leak (#3506)
Browse files Browse the repository at this point in the history
* fix(ios): fix pip memory leak

* lint code
  • Loading branch information
KrzysztofMoch authored Jan 30, 2024
1 parent aec7db6 commit 53068dd
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion ios/Video/RCTVideo.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -193,6 +197,7 @@ class RCTVideo: UIView, RCTVideoPlayerViewControllerDelegate, RCTPlayerObserverH
deinit {
NotificationCenter.default.removeObserver(self)
self.removePlayerLayer()
_pip = nil
_playerObserver.clearPlayer()
}

Expand Down

0 comments on commit 53068dd

Please sign in to comment.