Skip to content

Commit

Permalink
fix: Fix potentially NPE in AgoraVideoView (#2035)
Browse files Browse the repository at this point in the history
If the `AgoraVideoView` is disposed of before the `_initializeTexture`
is completed, it will cause an NPE.
  • Loading branch information
littleGnAl authored Sep 25, 2024
1 parent c1fbd01 commit 2ad4cff
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lib/src/impl/agora_video_view_impl.dart
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ class _AgoraRtcRenderTextureState extends State<AgoraRtcRenderTexture>

if (!_controllerInternal!.isInitialzed) {
_listener ??= () {
_controllerInternal!.removeInitializedCompletedListener(_listener!);
_controllerInternal?.removeInitializedCompletedListener(_listener!);
_listener = null;

_initializeTexture();
Expand All @@ -326,6 +326,10 @@ class _AgoraRtcRenderTextureState extends State<AgoraRtcRenderTexture>
}

Future<void> _initializeTexture() async {
if (_controllerInternal == null) {
return;
}

final oldTextureId = _controllerInternal!.getTextureId();
await _controllerInternal!.initializeRender();
final textureId = _controllerInternal!.getTextureId();
Expand Down

0 comments on commit 2ad4cff

Please sign in to comment.