diff --git a/android/src/main/java/io/agora/agora_rtc_ng/VideoViewController.java b/android/src/main/java/io/agora/agora_rtc_ng/VideoViewController.java index 968a263a8..adc5a95df 100644 --- a/android/src/main/java/io/agora/agora_rtc_ng/VideoViewController.java +++ b/android/src/main/java/io/agora/agora_rtc_ng/VideoViewController.java @@ -232,5 +232,6 @@ private long getLong(Object value) { public void dispose() { methodChannel.setMethodCallHandler(null); + disposeAllRenderers(); } } diff --git a/example/ios/Flutter/AppFrameworkInfo.plist b/example/ios/Flutter/AppFrameworkInfo.plist index 9625e105d..7c5696400 100644 --- a/example/ios/Flutter/AppFrameworkInfo.plist +++ b/example/ios/Flutter/AppFrameworkInfo.plist @@ -21,6 +21,6 @@ CFBundleVersion 1.0 MinimumOSVersion - 11.0 + 12.0 diff --git a/example/ios/Podfile b/example/ios/Podfile index 062114f3a..070fb68e2 100644 --- a/example/ios/Podfile +++ b/example/ios/Podfile @@ -1,5 +1,5 @@ # Uncomment this line to define a global platform for your project -platform :ios, '11.0' +platform :ios, '12.0' # CocoaPods analytics sends network stats synchronously affecting flutter build latency. ENV['COCOAPODS_DISABLE_STATS'] = 'true' diff --git a/example/ios/Runner.xcodeproj/project.pbxproj b/example/ios/Runner.xcodeproj/project.pbxproj index bb4699101..ac0c729dd 100644 --- a/example/ios/Runner.xcodeproj/project.pbxproj +++ b/example/ios/Runner.xcodeproj/project.pbxproj @@ -251,7 +251,7 @@ 97C146E61CF9000F007C117D /* Project object */ = { isa = PBXProject; attributes = { - LastUpgradeCheck = 1430; + LastUpgradeCheck = 1510; ORGANIZATIONNAME = ""; TargetAttributes = { 71BBA3B728AB50E2007B0DBC = { @@ -488,7 +488,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 11.0; + IPHONEOS_DEPLOYMENT_TARGET = 12.0; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = iphoneos; SUPPORTED_PLATFORMS = iphoneos; @@ -543,7 +543,7 @@ INFOPLIST_FILE = ScreenSharing/Info.plist; INFOPLIST_KEY_CFBundleDisplayName = ScreenSharing; INFOPLIST_KEY_NSHumanReadableCopyright = ""; - IPHONEOS_DEPLOYMENT_TARGET = 11.0; + IPHONEOS_DEPLOYMENT_TARGET = 12.0; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", @@ -580,7 +580,7 @@ INFOPLIST_FILE = ScreenSharing/Info.plist; INFOPLIST_KEY_CFBundleDisplayName = ScreenSharing; INFOPLIST_KEY_NSHumanReadableCopyright = ""; - IPHONEOS_DEPLOYMENT_TARGET = 11.0; + IPHONEOS_DEPLOYMENT_TARGET = 12.0; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", @@ -616,7 +616,7 @@ INFOPLIST_FILE = ScreenSharing/Info.plist; INFOPLIST_KEY_CFBundleDisplayName = ScreenSharing; INFOPLIST_KEY_NSHumanReadableCopyright = ""; - IPHONEOS_DEPLOYMENT_TARGET = 11.0; + IPHONEOS_DEPLOYMENT_TARGET = 12.0; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", @@ -680,7 +680,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 11.0; + IPHONEOS_DEPLOYMENT_TARGET = 12.0; MTL_ENABLE_DEBUG_INFO = YES; ONLY_ACTIVE_ARCH = YES; SDKROOT = iphoneos; @@ -729,7 +729,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 11.0; + IPHONEOS_DEPLOYMENT_TARGET = 12.0; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = iphoneos; SUPPORTED_PLATFORMS = iphoneos; diff --git a/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme b/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme index a6b826db2..5e31d3d34 100644 --- a/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme +++ b/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme @@ -1,6 +1,6 @@ *registrar; +- (void) dispose; + @end @implementation AgoraRtcNgPlugin @@ -57,4 +59,20 @@ - (void)handleMethodCall:(FlutterMethodCall*)call result:(FlutterResult)result { } } +- (void)detachFromEngineForRegistrar:(NSObject *)registrar { + [self dispose]; +} + +- (void) dispose { + if (self.videoViewController) { + [self.videoViewController dispose]; + self.videoViewController = NULL; + } +} + +- (void)dealloc +{ + [self dispose]; +} + @end diff --git a/shared/darwin/TextureRenderer.mm b/shared/darwin/TextureRenderer.mm index 52de2b031..00e3a4bc8 100644 --- a/shared/darwin/TextureRenderer.mm +++ b/shared/darwin/TextureRenderer.mm @@ -64,7 +64,7 @@ void OnVideoFrameReceived(const void *videoFrame, } dispatch_semaphore_signal(renderer.lock); - if (renderer.isDirtyBuffer) { + if (renderer.textureRegistry && renderer.isDirtyBuffer) { [renderer.textureRegistry textureFrameAvailable:renderer.textureId]; } } @@ -126,13 +126,19 @@ - (void)updateData:(NSNumber *)uid channelId:(NSString *)channelId videoSourceTy } - (void)dispose { - self.irisRtcRendering->RemoveVideoFrameObserverDelegate(self.delegateId); + if (self.irisRtcRendering) { + self.irisRtcRendering->RemoveVideoFrameObserverDelegate(self.delegateId); + self.irisRtcRendering = NULL; + } if (self.delegate) { delete self.delegate; self.delegate = NULL; } - [self.textureRegistry unregisterTexture:self.textureId]; - if (self.isDirtyBuffer) { + if (self.textureRegistry) { + [self.textureRegistry unregisterTexture:self.textureId]; + self.textureRegistry = NULL; + } + if (self.buffer_cache && self.isDirtyBuffer) { CVPixelBufferRelease(self.buffer_cache); self.buffer_cache = NULL; } diff --git a/shared/darwin/VideoViewController.h b/shared/darwin/VideoViewController.h index a2924f5ab..05df1b796 100644 --- a/shared/darwin/VideoViewController.h +++ b/shared/darwin/VideoViewController.h @@ -28,6 +28,8 @@ - (BOOL)destroyTextureRender:(int64_t)textureId; +- (void)dispose; + @end diff --git a/shared/darwin/VideoViewController.mm b/shared/darwin/VideoViewController.mm index aafeab18f..74a6ca43d 100644 --- a/shared/darwin/VideoViewController.mm +++ b/shared/darwin/VideoViewController.mm @@ -132,8 +132,6 @@ @interface VideoViewController () @property(nonatomic) PlatformRenderPool* platformRenderPool; @property(nonatomic, strong) FlutterMethodChannel *methodChannel; - -- (void)dispose; @end @implementation VideoViewController