fix(prejoin): disposed track was added to the conference

It is not 100% clear to me when it happens, but I think it could happen
in some race condition where a track is unmuted when it's being disposed
or something around those lines.

The fact is that any muted tracks are disposed by replaceLocalTrack(track.jitsiTrack, null) and they should not be used anymore.

Supposedly fixes a crash:

Failed to add local track to conference Track has been already disposed
This commit is contained in:
Pawel Domas 2021-07-27 10:38:02 -05:00 committed by Paweł Domas
parent 643340c4a6
commit 907b51925d
1 changed files with 7 additions and 1 deletions

View File

@ -33,7 +33,7 @@ MiddlewareRegistry.register(store => next => async action => {
const { getState, dispatch } = store; const { getState, dispatch } = store;
const state = getState(); const state = getState();
const { userSelectedSkipPrejoin } = state['features/prejoin']; const { userSelectedSkipPrejoin } = state['features/prejoin'];
const localTracks = getLocalTracks(state['features/base/tracks']); let localTracks = getLocalTracks(state['features/base/tracks']);
const { options } = action; const { options } = action;
options && store.dispatch(updateConfig(options)); options && store.dispatch(updateConfig(options));
@ -48,6 +48,12 @@ MiddlewareRegistry.register(store => next => async action => {
await dispatch(replaceLocalTrack(track.jitsiTrack, null)); await dispatch(replaceLocalTrack(track.jitsiTrack, null));
} }
} }
// Re-fetch the local tracks after muted tracks have been removed above.
// This is needed, because the tracks are effectively disposed by the replaceLocalTrack and should not be used
// anymore.
localTracks = getLocalTracks(getState()['features/base/tracks']);
const jitsiTracks = localTracks.map(t => t.jitsiTrack); const jitsiTracks = localTracks.map(t => t.jitsiTrack);
dispatch(setPrejoinPageVisibility(false)); dispatch(setPrejoinPageVisibility(false));