Skip to content

Commit b51b579

Browse files
authored
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 <[email protected]>
1 parent 60c3a08 commit b51b579

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

ios/Video/Features/RCTIMAAdsManager.swift

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,13 @@
3030

3131
func requestAds() {
3232
guard let _video else { return }
33+
// fixes RCTVideo --> RCTIMAAdsManager --> IMAAdsLoader --> IMAAdDisplayContainer --> RCTVideo memory leak.
34+
let adContainerView = UIView(frame: _video.bounds)
35+
adContainerView.backgroundColor = .clear
36+
_video.addSubview(adContainerView)
37+
3338
// Create ad display container for ad rendering.
34-
let adDisplayContainer = IMAAdDisplayContainer(adContainer: _video, viewController: _video.reactViewController())
39+
let adDisplayContainer = IMAAdDisplayContainer(adContainer: adContainerView, viewController: _video.reactViewController())
3540

3641
let adTagUrl = _video.getAdTagUrl()
3742
let contentPlayhead = _video.getContentPlayhead()

0 commit comments

Comments
 (0)