fix: avoid memory leak on iOS (#4355)

* fix: avoid memory leak on iOS

---------

Co-authored-by: Vladimir Vlasov <crivlaldo@gmail.com>
This commit is contained in:
Vladimir 2025-01-04 13:47:22 +01:00 committed by GitHub
parent d31c72fc04
commit 424f4eedde
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -6,33 +6,31 @@
import Foundation
public class ReactNativeVideoManager: RNVPlugin {
private let expectedMaxVideoCount = 10
private let expectedMaxVideoCount = 2
// create a private initializer
private init() {}
public static let shared: ReactNativeVideoManager = .init()
var instanceList: [RCTVideo] = Array()
var pluginList: [RNVPlugin] = Array()
private var instanceCount = 0
private var pluginList: [RNVPlugin] = Array()
/**
* register a new ReactExoplayerViewManager in the managed list
* register a new view
*/
func registerView(newInstance: RCTVideo) {
if instanceList.count > expectedMaxVideoCount {
func registerView(newInstance _: RCTVideo) {
if instanceCount > expectedMaxVideoCount {
DebugLog("multiple Video displayed ?")
}
instanceList.append(newInstance)
instanceCount += 1
}
/**
* unregister existing ReactExoplayerViewManager in the managed list
* unregister existing view
*/
func unregisterView(newInstance: RCTVideo) {
if let i = instanceList.firstIndex(of: newInstance) {
instanceList.remove(at: i)
}
func unregisterView(newInstance _: RCTVideo) {
instanceCount -= 1
}
/**