Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(prosody-auth): Don't loose initial tracks. #14358

Merged
merged 5 commits into from
Jul 30, 2024

Conversation

hristoterezov
Copy link
Member

During the prosody login cycle the initial GUM tracks were lost causing the user to start the call without local media and audio/video mute buttons staying forever in pending state.


return APP.store.dispatch(initPrejoin(localTracks, errors));
// Note: Not sure if initPrejoin needs to be async. But let's wait for it just to be sure the
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It doesn't need to be. It doesn't even need access to the store so it doesn't even need to be async.

export function initPrejoin(tracks: Object[], errors: Object) {
    return async function(dispatch: IStore['dispatch']) {
        dispatch(setPrejoinDeviceErrors(errors));
        dispatch(prejoinInitialized());

        tracks.forEach(track => dispatch(trackAdded(track)));
    };
}

You could rewrite this to take the store as a parameter and just call it, since it's not really an action. Then in there you can batch-dispatch the actual actions.

@@ -153,6 +158,11 @@ MiddlewareRegistry.register(store => next => action => {
error.recoverable = true;

_handleLogin(store);
} else {
batch(() => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This feeels like the wrong place to be handling this. Authentication should not be handling track stuff.

You can handle this in the media middleware, since the recoverable flag will already be set once you calll next when handling this action.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But then how fo we guarantee that the media middleware will be executed after the authentication one? Aren't they executed in the order of the imports. This doesn't sound like very intuitive solution.

Moreover the whole story is a little bit more complicated. We need to keep the gum promise only for the login dialog and in all other cases we don't need it... IMHO the whole thing doesn't look so bad to be here.

@@ -264,6 +274,11 @@ function _handleLogin({ dispatch, getState }: IStore) {
const videoMuted = isLocalTrackMuted(state['features/base/tracks'], MEDIA_TYPE.VIDEO);

if (!room) {
batch(() => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto.

APP.conference.startConference(jitsiTracks).catch(logger.error);
}
});
.then(() => dispatch(disconnect()));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When will the connection begin again?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see some of the logic got moved to base/conference, but only to the web middleware. When does mobile start connecting again?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we decided with @damencho to remove the reconnect in order not to flood the infrastructure with reconnects. IIRC the UX now will be that the user will see an error and can reload or press the Join button again.

* @param {string} action.type - Type of action.
* @returns {ICommonState}
*/
function _common(state: ICommonState = _COMMON_INITIAL_STATE, action: AnyAction) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generally speaking, base/media has always represented user intent, that is, a muted a flag in here does not necesssarily mean there is a track.

The initial gUM promise is concerned with actual tracks, which fits better in base/tracks.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make sense!

Now the problem is that base/tracks is just an array currently. This will include converting it into some kind of object to keep the tracks and also the promise. And this could potentially lead to a lot of changes.

Do you insist on doing the change as part of this PR or you prefer a follow up PR with the change?

Copy link
Member

@saghul saghul left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd like to see some more details on the commit description too, since I suspect the problem of remaining stuck in a broken state wasn't reproducing all the time, right?

@hristoterezov hristoterezov force-pushed the fix-prosody-auth-local-tracks branch 3 times, most recently from 7f5da25 to 727c442 Compare June 17, 2024 08:10
@hristoterezov
Copy link
Member Author

I'd like to see some more details on the commit description too, since I suspect the problem of remaining stuck in a broken state wasn't reproducing all the time, right?

yes. it happens when the prejoin is not enabled.

@hristoterezov hristoterezov force-pushed the fix-prosody-auth-local-tracks branch 2 times, most recently from 9e276bb to 4f3786c Compare June 25, 2024 12:17
@hristoterezov hristoterezov force-pushed the fix-prosody-auth-local-tracks branch from 4f3786c to 7ab7b68 Compare July 8, 2024 13:46
When the prejoin screen is disabled during the prosody login cycle the initial GUM tracks were lost causing the user to start the call without local media and audio/video mute buttons staying forever in pending state.
Copy link
Member

@saghul saghul left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚀

@hristoterezov hristoterezov merged commit 1b3b949 into master Jul 30, 2024
9 checks passed
@hristoterezov hristoterezov deleted the fix-prosody-auth-local-tracks branch July 30, 2024 12:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants