ConnectyCube / connectycube-flutter-samples

Code samples for Flutter, based on ConnectyCube platform
https://developers.connectycube.com/flutter/
Apache License 2.0
85 stars 90 forks source link

Wrong primary video rendered on the video call #352

Closed radyhaggag closed 2 months ago

radyhaggag commented 3 months ago

Specify the sample to which the issue belongs (use [x]): [] Conference call sample

Platform (use [x]) [] Android [] iOS

Device info Anyone

Describe the bug: When the opponent receive a call notification when the app is killed, and accept it then on the conversation call screen, his camera is appear as the primary video but it should be the other participant, and when click on the minor video to switch the view, nothing is happen, on the other side everything working well.

and is sometimes occur and sometimes is working fine. i think first time working and then not, then working, then not, etc......

Steps to Reproduce:

  1. Start video call with a user, and make sure the app is killed.
  2. Accept the video call.

Actual result: first time the big camera was my screen and the small screen was opponent.

Expected behavior: it should be the opposite.

TatankaConCube commented 3 months ago

will check it later in our sample. have you debugged why it can happen? still the issue reproduces after switching the camera or clicking any buttons?

radyhaggag commented 3 months ago

will check it later in our sample. have you debugged why it can happen? still the issue reproduces after switching the camera or clicking any buttons?

No, i still debugging it, but the code on conversation call screen is too complex on this point, so i still try.

for some reasons, this method return without invoke the update method, so the all conditions on first if statement is satsified.

void updatePrimaryUser( int userId, bool force, int currentUserId, MapEntry<int, RTCVideoRenderer>? primaryRenderer, Map<int, RTCVideoRenderer> minorRenderers, Map<int, Map<String, bool>> participantsMediaConfigs, { required Function(MapEntry<int, RTCVideoRenderer>? primaryRenderer, Map<int, RTCVideoRenderer> minorRenderers)? onRenderersUpdated, }) { final userEnableCamera = getUserWithEnabledVideo( minorRenderers, currentUserId, participantsMediaConfigs, ); logger.i("userEnableCamera $userEnableCamera"); logger.i( "!minorRenderers.containsKey(userId) ${!minorRenderers.containsKey(userId)}", ); logger.i("userId == primaryRenderer?.key ${userId == primaryRenderer?.key}"); logger.i( "(userId == currentUserId && !force) ${(userId == currentUserId && !force)}", ); logger.i("userEnableCamera == null ${userEnableCamera == null}"); if (!minorRenderers.containsKey(userId) || userId == primaryRenderer?.key || (userId == currentUserId && !force) || userEnableCamera == null) { logger.i("updatePrimaryUser Has failed on the conditions"); return; }

if (primaryRenderer?.key != userId) { minorRenderers.addEntries([primaryRenderer!]); }

primaryRenderer = MapEntry(userId, minorRenderers.remove(userId)!);

onRenderersUpdated?.call(primaryRenderer, minorRenderers); }

radyhaggag commented 3 months ago

int? getUserWithEnabledVideo(Map<int, RTCVideoRenderer> renderers, int currentUserId, Map<int, Map<String, bool>> config) { var resultUserId = -1;

renderers.forEach((userId, renderer) { if ((resultUserId == -1 || resultUserId == currentUserId) && canShowVideo(userId, renderer.srcObject, config)) { resultUserId = userId; } });

return resultUserId == -1 ? null : resultUserId; }

This method return resultUserId with -1 in this case always, and you cannot switch the video.

radyhaggag commented 3 months ago

Can you please tell me a reason or expectation for this problem and i will debug it? because i didn't know if it from the code or from the remote data source or anyting about it.

also i tried 7 times and it didn't occur then on the try no 8 its occur, after that its occur many times?!

radyhaggag commented 3 months ago

@TatankaConCube ?

radyhaggag commented 3 months ago

After many tries i think the problem is with this method onRemoteStreamTrackReceived, sometimes the camera is working on other side but when see the primary render and minor render, the primary render media is not fetched so the problem occur.

@TatankaConCube