fix(ios): retain cycle and memory leak involving the RCTVideo instance when using Google IMA ads in react-native-video. (#4574)
Co-authored-by: Varuzhan Khachatryan <varuzhan.khachatryan23@gmail.com>
This commit is contained in:
@@ -30,8 +30,13 @@
|
|||||||
|
|
||||||
func requestAds() {
|
func requestAds() {
|
||||||
guard let _video else { return }
|
guard let _video else { return }
|
||||||
|
// fixes RCTVideo --> RCTIMAAdsManager --> IMAAdsLoader --> IMAAdDisplayContainer --> RCTVideo memory leak.
|
||||||
|
let adContainerView = UIView(frame: _video.bounds)
|
||||||
|
adContainerView.backgroundColor = .clear
|
||||||
|
_video.addSubview(adContainerView)
|
||||||
|
|
||||||
// Create ad display container for ad rendering.
|
// Create ad display container for ad rendering.
|
||||||
let adDisplayContainer = IMAAdDisplayContainer(adContainer: _video, viewController: _video.reactViewController())
|
let adDisplayContainer = IMAAdDisplayContainer(adContainer: adContainerView, viewController: _video.reactViewController())
|
||||||
|
|
||||||
let adTagUrl = _video.getAdTagUrl()
|
let adTagUrl = _video.getAdTagUrl()
|
||||||
let contentPlayhead = _video.getContentPlayhead()
|
let contentPlayhead = _video.getContentPlayhead()
|
||||||
|
|||||||
Reference in New Issue
Block a user