Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Fix a potential crash in AgoraVideoView when the app is force quit #2055

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -232,5 +232,6 @@ private long getLong(Object value) {

public void dispose() {
methodChannel.setMethodCallHandler(null);
disposeAllRenderers();
}
}
2 changes: 1 addition & 1 deletion example/ios/Flutter/AppFrameworkInfo.plist
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@
<key>CFBundleVersion</key>
<string>1.0</string>
<key>MinimumOSVersion</key>
<string>11.0</string>
<string>12.0</string>
</dict>
</plist>
2 changes: 1 addition & 1 deletion example/ios/Podfile
Original file line number Diff line number Diff line change
@@ -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'
Expand Down
14 changes: 7 additions & 7 deletions example/ios/Runner.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@
97C146E61CF9000F007C117D /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 1430;
LastUpgradeCheck = 1510;
ORGANIZATIONNAME = "";
TargetAttributes = {
71BBA3B728AB50E2007B0DBC = {
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1430"
LastUpgradeVersion = "1510"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
2 changes: 1 addition & 1 deletion example/ios/Runner/AppDelegate.swift
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import UIKit
import Flutter

@UIApplicationMain
@main
@objc class AppDelegate: FlutterAppDelegate {
override func application(
_ application: UIApplication,
Expand Down
18 changes: 18 additions & 0 deletions ios/Classes/AgoraRtcNgPlugin.m
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ @interface AgoraRtcNgPlugin ()

@property(nonatomic) NSObject<FlutterPluginRegistrar> *registrar;

- (void) dispose;

@end

@implementation AgoraRtcNgPlugin
Expand Down Expand Up @@ -57,4 +59,20 @@ - (void)handleMethodCall:(FlutterMethodCall*)call result:(FlutterResult)result {
}
}

- (void)detachFromEngineForRegistrar:(NSObject<FlutterPluginRegistrar> *)registrar {
[self dispose];
}

- (void) dispose {
if (self.videoViewController) {
[self.videoViewController dispose];
self.videoViewController = NULL;
}
}

- (void)dealloc
{
[self dispose];
}

@end
14 changes: 10 additions & 4 deletions shared/darwin/TextureRenderer.mm
Original file line number Diff line number Diff line change
Expand Up @@ -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];
}
}
Expand Down Expand Up @@ -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;
}
Expand Down
2 changes: 2 additions & 0 deletions shared/darwin/VideoViewController.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@

- (BOOL)destroyTextureRender:(int64_t)textureId;

- (void)dispose;

@end


Expand Down
2 changes: 0 additions & 2 deletions shared/darwin/VideoViewController.mm
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,6 @@ @interface VideoViewController ()
@property(nonatomic) PlatformRenderPool* platformRenderPool;

@property(nonatomic, strong) FlutterMethodChannel *methodChannel;

- (void)dispose;
@end

@implementation VideoViewController
Expand Down
Loading