Skip to content

Commit e884fb7

Browse files
authored
fix(llc): delay StreamVideo instance disposing (#1112)
* delay streamvideo instance disposing * changelog
1 parent 1815cb0 commit e884fb7

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

packages/stream_video/CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
## Unreleased
2+
3+
🐞 Fixed
4+
- Resolved an issue that could cause the StreamVideo instance to be disposed prematurely before ringing events were fully processed when handling ringing notifications in the terminated state.
5+
16
## 0.11.2
27

38
🐞 Fixed

packages/stream_video/lib/src/stream_video.dart

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -709,6 +709,10 @@ class StreamVideo extends Disposable {
709709
return manager.on<T>(onEvent);
710710
}
711711

712+
/// This method is used to dispose the StreamVideo instance after the ringing event is resolved.
713+
/// It is used primarily for Firebase Messaging background handler where separate isolate is used to handle the message.
714+
///
715+
/// [disposingCallback] is a callback that allows to perform any additional disposing operations after the ringing event is resolved.
712716
StreamSubscription<RingingEvent>? disposeAfterResolvingRinging({
713717
void Function()? disposingCallback,
714718
}) {
@@ -718,8 +722,11 @@ class StreamVideo extends Disposable {
718722
event is ActionCallDecline ||
719723
event is ActionCallTimeout ||
720724
event is ActionCallEnded) {
721-
disposingCallback?.call();
722-
dispose();
725+
// Delay the callback to ensure the call is fully resolved.
726+
Future<void>.delayed(const Duration(seconds: 1), () {
727+
disposingCallback?.call();
728+
dispose();
729+
});
723730
}
724731
},
725732
);

0 commit comments

Comments
 (0)