Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Commit

Permalink
Handle Jitsi Meet crashes more gracefully (#8541)
Browse files Browse the repository at this point in the history
  • Loading branch information
robintown authored May 9, 2022
1 parent 333dd59 commit 19efa09
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/stores/VideoChannelStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,10 @@ export default class VideoChannelStore extends AsyncStoreWithClient<null> {
messaging.on(`action:${ElementWidgetActions.UnmuteAudio}`, this.onUnmuteAudio);
messaging.on(`action:${ElementWidgetActions.MuteVideo}`, this.onMuteVideo);
messaging.on(`action:${ElementWidgetActions.UnmuteVideo}`, this.onUnmuteVideo);
// Empirically, it's possible for Jitsi Meet to crash instantly at startup,
// sending a hangup event that races with the rest of this method, so we also
// need to add the hangup listener now rather than later
messaging.once(`action:${ElementWidgetActions.HangupCall}`, this.onHangup);

this.emit(VideoChannelEvent.StartConnect, roomId);

Expand Down Expand Up @@ -186,14 +190,14 @@ export default class VideoChannelStore extends AsyncStoreWithClient<null> {
messaging.off(`action:${ElementWidgetActions.UnmuteAudio}`, this.onUnmuteAudio);
messaging.off(`action:${ElementWidgetActions.MuteVideo}`, this.onMuteVideo);
messaging.off(`action:${ElementWidgetActions.UnmuteVideo}`, this.onUnmuteVideo);
messaging.off(`action:${ElementWidgetActions.HangupCall}`, this.onHangup);

this.emit(VideoChannelEvent.Disconnect, roomId);

throw new Error(`Failed to join call in room ${roomId}: ${e}`);
}

this.connected = true;
messaging.once(`action:${ElementWidgetActions.HangupCall}`, this.onHangup);
this.matrixClient.getRoom(roomId).on(RoomEvent.MyMembership, this.onMyMembership);
window.addEventListener("beforeunload", this.setDisconnected);

Expand Down Expand Up @@ -258,6 +262,9 @@ export default class VideoChannelStore extends AsyncStoreWithClient<null> {

private onHangup = async (ev: CustomEvent<IWidgetApiRequest>) => {
this.ack(ev);
// In case this hangup is caused by Jitsi Meet crashing at startup,
// wait for the connection event in order to avoid racing
if (!this.connected) await waitForEvent(this, VideoChannelEvent.Connect);
await this.setDisconnected();
};

Expand Down

0 comments on commit 19efa09

Please sign in to comment.