Skip to content

Conversation

@danxuliu
Copy link
Member

Fixes a regression introduced in #6707 (specifically, in 802d1d2)

When the HPB is not used and the same conversation is joined in another tab a conflict response is returned by the internal signaling server* in the first tab, which causes a duplicate-session-detected event to be triggered and this in turn causes a redirection to the duplicate-session page.

*If a long polling request fails with an internal error, for example if SQLite is used and the database is locked due to concurrent access, when the next polling gets again the session it will already use the session set by the second tab, so it will be the valid one and no conflict will be reported. But an internal error should not happen during the long polling, so this is such a corner case that, unless there is an easy fix, it should be fine to ignore, at least for now.

However, if the HPB is used there is no conflict response; in the past a disinvite message was sent to the first session, which caused the UI to show a Conversation does not exist page (it should have shown the duplicated session page, but I do not know if that ever worked). However, the disinvite message is no longer sent for registered users since 802d1d2. Due to that when the same conversation is joined in another tab the UI in the original one is still active, so further actions in the first tab mess with the session in the second tab. For example, if the conversation is switched in the first tab while the second tab is in a call the participant will leave the call and stay in it at the same time. To solve that, the disinvite message is now sent again for regular users too, but only when removing a duplicated session.

But, if the session of the second tab leaves the conversation, why was the call still active? The problem is the order in which the events are handled. When the conversation is left an event to leave the call is triggered, but the event is triggered once the conversation is left already. When the event is handled the session of the event is checked against the sessions in the conversation, but as the conversation was already left no session is found, so the message sent to the HPB is empty and therefore the HPB does not cause the call to be left.

To solve that now, when a conversation is left, if there is an active call it is first explicitly left and then the conversation is left. Note, however, that the RTCPeerConnections will be reconnected after some time, because the WebUI will try to leave the call but fail and, once the connection also fails, the handler to reconnect it will run despite no longer being in the call; that is fixed in #7799

The scenario 1 below can be tested only without the second commit, as the second commit fixes a precondition (being able to join the same conversation in another tab without leaving the conversation in the first tab). Nevertheless, even if the scenario 1 will no longer happen the first commit should still be applied.

How to test (scenario 1)

  • Setup the HPB
  • Log in as a user
  • Create a conversation
  • Open the same conversation in another tab
  • In that new tab, join the call
  • In the original tab, change to another conversation (so you leave the other one, but note that closing the tab does not trigger the issue)

Result with first commit of this pull request

The call is left in the second tab

Note that without #7799 the connections will be established again after some time (even if the UI still appears as not in the call)

Result without this pull request

The call is not left in the second tab (although there is a chat message saying that you left the call)

How to test (scenario 2)

  • Setup the HPB
  • Log in as a user
  • Create a conversation
  • Open the same conversation in another tab

Result with this pull request

The conversation is left in the first tab

Note that no conflict warning is shown in the second tab because since #4374 this is done only when the previous session is in a call

Result without this pull request

The conversation is not left in the first tab

When a call is left a message is sent to the external signaling server.
However, that message is based on the sessions of the participants in
the conversation. When a conversation is left and the participant was in
a call in that conversation the call is also left, but the event was
emitted after leaving the conversation. Due to that, when the message to
be sent to the external signaling server was generated the participant
was no longer in the conversation, and therefore it was not included in
the message, so the call was not left from the point of view of the
external signaling server. To solve that now the call is left and, once
that is done, the conversation is left.

Signed-off-by: Daniel Calviño Sánchez <[email protected]>
@danxuliu danxuliu added 3. to review bug regression feature: signaling 📶 Internal and external signaling backends labels Aug 26, 2022
@danxuliu danxuliu added this to the 💚 Next Beta (25) milestone Aug 26, 2022
@danxuliu
Copy link
Member Author

/backport to stable24

@danxuliu
Copy link
Member Author

/backport to stable23

Copy link
Member

@nickvergessen nickvergessen left a comment

Choose a reason for hiding this comment

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

Works as expected

@nickvergessen
Copy link
Member

Please squash

When the same room is joined again from the same PHP session the room is
left with the previous Nextcloud session before joining with the new
one. However, "disinvite" messages were not sent to the external signaling
server for regular users, so their UI was not updated to show that the
previous Nextcloud session was kicked out from the conversation.

Note, however, that as a "disinvite" message is now sent the UI will
show a "conversation not found" message rather than a "duplicated
session" state.

Signed-off-by: Daniel Calviño Sánchez <[email protected]>
@danxuliu danxuliu force-pushed the fix-leaving-room-in-one-session-causing-call-to-be-partially-left-in-another-session branch from 6f23b7b to 85f73b0 Compare August 26, 2022 10:20
@nickvergessen nickvergessen merged commit 4482bea into master Aug 26, 2022
@nickvergessen nickvergessen deleted the fix-leaving-room-in-one-session-causing-call-to-be-partially-left-in-another-session branch August 26, 2022 14:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

3. to review bug feature: signaling 📶 Internal and external signaling backends regression

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants