GetStream / stream-video-flutter

Flutter Video SDK - Build your own video app experience using Dart, Flutter and the Stream Video Messaging API.
https://getstream.io/video/docs/flutter/
Other
37 stars 11 forks source link

Call acceptance not updating UI in version 0.3.5 #633

Closed TinhHuynh closed 1 month ago

TinhHuynh commented 1 month ago

Issue Description

After updating to version 0.3.5 of the Stream Video Flutter SDK, I've encountered a problem where the caller's UI does not update to show that the receiver has accepted the call. The receiver does receive the incoming call notification and can tap the 'Answer' button, but the caller's side remains unchanged, and it seems like the call has not been accepted.

Steps to Reproduce

  1. Update to version 0.3.5 of the Stream Video Flutter SDK.

  2. Initiate a call using the following method:

    _callClient!
        .makeCall(callType: video.StreamCallType(), id: const Uuid().v4());
    await call.getOrCreate(
        memberIds: ids, ringing: true);
  3. The receiver receives the incoming call notification and taps on the 'Answer' button.

Expected Behavior

The caller's UI should update to reflect that the receiver has accepted the call.

Actual Behavior

The caller's UI does not update, and it appears as if the receiver has not accepted the call.

Debugging Information

Upon checking state_coordinator_mixin.dart and its coordinatorCallAccepted method, it was found that state.callParticipants is empty. This results in a null participant, and consequently, the status CallStatus.outgoing(acceptedByCallee: true) is never set.

void coordinatorCallAccepted(CoordinatorCallAcceptedEvent event,) {
    final status = state.status;
    if (status is! CallStatusOutgoing) {
        _logger.w(() => '[coordinatorUpdateCallAccepted] rejected (status is not Outgoing)',);
        return;
    }
    // the state.callParticipants is empty now -> participant is null -> CallStatus.outgoing(acceptedByCallee: true) is never be fired 
    final participant = state.callParticipants.firstWhereOrNull((participant) {
        return participant.userId == event.acceptedByUserId;
    });
    if (participant == null) {
        _logger.w(() => '[coordinatorUpdateCallAccepted] rejected (accepted by non-Member)',);
        return;
    }
    state = state.copyWith(
        status: CallStatus.outgoing(acceptedByCallee: true),
    );
}

Additional Context

The application was functioning as expected in version 0.3.4. The issue only emerged after updating to version 0.3.5.

TinhHuynh commented 1 month ago

I've made some progress on troubleshooting the issue and found the cause of the problem. It turns out that calling call.get() after call.getOrCreate() resets the participants list, which was correctly populated by call.getOrCreate() before the call.get() call. This leads to the issue where the participant's acceptance of the call doesn't update the call status as expected because the participant information is lost.

I initially used call.get() to access the custom field of the call object for handling app-specific functionalities, as the call object or its state doesn't provide direct access to this custom data.

Given this scenario, is call.get() intended to be used only after the call has been connected? If so, could you guide the recommended approach to access custom data in the call object for app-specific needs before the call connection is established?

sachinrana028 commented 1 month ago

Hi @TinhHuynh, Have able to fix this issue as I am also facing same issue.

TinhHuynh commented 1 month ago

Hi @TinhHuynh, Have able to fix this issue as I am also facing same issue.

There is a PR fixing the issue: https://github.com/GetStream/stream-video-flutter/pull/634

In the meantime, I deleted the call.get() line and used the response from the call.getOrCreate() to access custom data.

Brazol commented 1 month ago

Hey, the PR mentioned above is now part of the latest SDK version (v0.3.6). It should fix this issue, so I'm closing it now. Feel free to reopen it if the problem still exists. Thank you!