@@ -25,9 +25,6 @@ class GlobalVideoViewControllerIO extends GlobalVideoViewControllerPlatfrom {
25
25
@override
26
26
int get irisRtcRenderingHandle => _irisRtcRenderingHandle;
27
27
28
- final Map <int , Completer <void >> _destroyTextureRenderCompleters = {};
29
- bool _isDetachVFBMing = false ;
30
-
31
28
void _hotRestartListener (Object ? message) {
32
29
assert (() {
33
30
// Free `IrisRtcRendering` when hot restart
@@ -64,34 +61,28 @@ class GlobalVideoViewControllerIO extends GlobalVideoViewControllerPlatfrom {
64
61
return ;
65
62
}
66
63
64
+ final irisRtcRenderingHandle = _irisRtcRenderingHandle;
65
+ _irisRtcRenderingHandle = 0 ;
66
+
67
67
irisMethodChannel.removeHotRestartListener (_hotRestartListener);
68
68
69
- _isDetachVFBMing = true ;
70
-
71
- // Need wait for all `destroyTextureRender` functions are called completed before
72
- // `FreeIrisVideoFrameBufferManager`, if not, the `destroyTextureRender`(call
73
- // `IrisVideoFrameBufferManager.DisableVideoFrameBuffer` in native side) and
74
- // `FreeIrisVideoFrameBufferManager` will be called parallelly, which will cause crash.
75
- for (final completer in _destroyTextureRenderCompleters.values) {
76
- if (! completer.isCompleted) {
77
- await completer.future;
78
- }
79
- }
80
- _destroyTextureRenderCompleters.clear ();
69
+ await methodChannel.invokeMethod ('dispose' );
81
70
82
71
await irisMethodChannel.invokeMethod (IrisMethodCall (
83
72
'FreeIrisRtcRendering' ,
84
73
jsonEncode ({
85
74
'irisRtcEngineNativeHandle' : irisRtcEngineIntPtr,
86
- 'irisRtcRenderingHandle' : _irisRtcRenderingHandle ,
75
+ 'irisRtcRenderingHandle' : irisRtcRenderingHandle ,
87
76
}),
88
77
));
89
- _irisRtcRenderingHandle = 0 ;
90
78
}
91
79
92
80
@override
93
81
Future <int > createTextureRender (int uid, String channelId,
94
82
int videoSourceType, int videoViewSetupMode) async {
83
+ if (_irisRtcRenderingHandle == 0 ) {
84
+ return kTextureNotInit;
85
+ }
95
86
final textureId =
96
87
await methodChannel.invokeMethod <int >('createTextureRender' , {
97
88
'irisRtcRenderingHandle' : _irisRtcRenderingHandle,
@@ -106,16 +97,11 @@ class GlobalVideoViewControllerIO extends GlobalVideoViewControllerPlatfrom {
106
97
/// Call `IrisVideoFrameBufferManager.DisableVideoFrameBuffer` in the native side
107
98
@override
108
99
Future <void > destroyTextureRender (int textureId) async {
109
- _destroyTextureRenderCompleters.putIfAbsent (
110
- textureId, () => Completer <void >());
100
+ if (_irisRtcRenderingHandle == 0 ) {
101
+ return ;
102
+ }
111
103
112
104
await methodChannel.invokeMethod ('destroyTextureRender' , textureId);
113
-
114
- _destroyTextureRenderCompleters[textureId]? .complete (null );
115
-
116
- if (! _isDetachVFBMing) {
117
- _destroyTextureRenderCompleters.remove (textureId);
118
- }
119
105
}
120
106
121
107
/// Decrease the ref count of the native view(`UIView` in iOS) of the `platformViewId` .
0 commit comments