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

Make mod_persistent_lobby play well with breakout rooms #13939

Closed
wants to merge 2 commits into from

Conversation

dnna
Copy link
Contributor

@dnna dnna commented Oct 11, 2023

mod_persistent_lobby does not currently work well with breakout rooms. If everyone leaves the main room to join breakouts, then the trigger_room_destroy logic is triggered from this plugin. This causes a crash in prosody with a hard-to-trace error like the below:

2023-10-11 21:56:44 meet.nxtlvl.io:muc_breakout_rooms                                error      No main room ([email protected])!
2023-10-11 21:56:44 c2s5615aea47970                                                  error      Traceback[c2s]: /prosody-plugins/mod_muc_breakout_rooms.lua:345: attempt to index a nil value (local 'main_room')
        stack traceback:
        /prosody-plugins/mod_muc_breakout_rooms.lua:345: in field '?'
        /usr/share/lua/5.4/prosody/util/events.lua:81: in function </usr/share/lua/5.4/prosody/util/events.lua:77>
        (...tail calls...)
        /usr/lib/prosody/modules/muc/muc.lib.lua:496: in function </usr/lib/prosody/modules/muc/muc.lib.lua:492>
        (...tail calls...)
        /usr/share/lua/5.4/prosody/util/events.lua:81: in function </usr/share/lua/5.4/prosody/util/events.lua:77>
        (...tail calls...)
        /usr/share/lua/5.4/prosody/core/stanza_router.lua:188: in upvalue 'core_post_stanza'
        /usr/share/lua/5.4/prosody/core/stanza_router.lua:128: in upvalue 'core_process_stanza'
        /usr/lib/prosody/modules/mod_c2s.lua:326: in upvalue 'func'
        /usr/share/lua/5.4/prosody/util/async.lua:144: in function </usr/share/lua/5.4/prosody/util/async.lua:142>

This PR attempts to address this by checking whether there are active breakout rooms in the session, and if not basically letting mod_muc_breakout_rooms do its thing when it comes to closing the conference (see relevant code below):

https://github.com/jitsi/jitsi-meet/blob/stable/jitsi-meet_8960/resources/prosody-plugins/mod_muc_breakout_rooms.lua#L431

If breakout rooms are not active/not used, then mod_persistent_lobby handles destroying the conference as normal when both the lobby and the main room are empty.

@jitsi-jenkins
Copy link

Hi, thanks for your contribution!
If you haven't already done so, could you please make sure you sign our CLA (https://jitsi.org/icla for individuals and https://jitsi.org/ccla for corporations)? We would unfortunately be unable to merge your patch unless we have that piece :(.

saghul
saghul previously approved these changes Oct 11, 2023
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.

LGTM. WDYT @damencho ?

Copy link
Contributor

@shawnchin shawnchin left a comment

Choose a reason for hiding this comment

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

With this change, mod_persistent_lobby no longer breaks breakout rooms, but leaving the room destruction to breakout room module does mean it might prematurely kill main room while lobby still active.

So for full compatibility, breakout room will also need to check if persistent_lobby is enabled and if lobby is empty before triggering room deletion.

But this incompatibility is already the case right now, so should not block this PR. Merely suggesting follow up work for better integration.

resources/prosody-plugins/mod_persistent_lobby.lua Outdated Show resolved Hide resolved
resources/prosody-plugins/mod_persistent_lobby.lua Outdated Show resolved Hide resolved
@dnna
Copy link
Contributor Author

dnna commented Oct 22, 2023

Thanks @shawnchin @saghul for the feedback! I have made the changes requested.

@damencho
Copy link
Member

jenkins, test this please.

@damencho
Copy link
Member

@shawnchin WDYT?

@shawnchin
Copy link
Contributor

@damencho PR looks good with the latest changes. But as mentioned in my comments above, for full compatibility we might want to follow up with a change to update breakout mod so it doesn't kill room if persistent lobby enabled and lobby not empty.

@damencho
Copy link
Member

damencho commented Oct 24, 2023

@dnna mind making that change?
We already have a check for that there:

if (main_room and main_room._data.lobbyroom and main_room:get_members_only()) then

And the check, I think, should go there:

if main_room and main_room.close_timer then
or on the if above ...

@shawnchin
Copy link
Contributor

We might also need to check if persistent lobby enabled and lobby not empty? Otherwise, there's nothing in place to clean up the room in the case where main room is empty and everyone leaves the breakout room.

Can easily check if persistent lobby is enabled using room._data.persist_lobby == true. Not sure what's the best way to look up has_occupant() of associated lobby room from the breakout module.

@damencho would it be simpler to have breakout module trigger event and let persistent lobby module handle it? E.g. in breakout module

          if main_room and main_room.close_timer then
              if main_room._data.persist_lobby == true then
                 -- hand over deletion responsibility to mod_persistent_lobby
                 prosody.events.fire_event("persistent-lobby-check-occupancy", { room = main_room; });
              else
                  module:log('info', 'Closing conference %s as all left for good.', main_room_jid);
                  main_room:set_persistent(false);
                  main_room:destroy(nil, 'All occupants left.');
              end
          end

Then in persistent lobby module, we can implement the event handler to trigger occupancy check for both main room and lobby room before potentially deleting the room.

@shawnchin
Copy link
Contributor

Untested draft of how the event handler in mod_persistent_lobby might look like:

function handle_persistent_lobby_occupancy_check(event)
    --- Triggers occupancy check of main room and lobby room
    local main_room = event.room;
    local main_room_active = main_room  and (main_room:has_occupant() or main_room._data.breakout_rooms_active);

   -- nothing to do if persistent lobby not enabled or main room still active
    if not has_persistent_lobby(main_room) or main_room_active then
        return;
    end

    local lobby_room_jid = main_room._data.lobbyroom;
    local lobby_room = lobby_muc_service.get_room_from_jid(lobby_room_jid);

    -- if lobby empty (and we already checked that main room inactive) then room can be deleted
    if not lobby_room:has_occupants() then
        trigger_room_destroy(main_room);
    end
   
end


module:hook_global('persistent-lobby-check-occupancy', handle_persistent_lobby_occupancy_check);

@damencho
Copy link
Member

We better not tight them up ... as by default breakout rooms are enabled, but persistent lobby is not.

Its better breakout to fire event to say destroy this room. And breakout will be handling that event by itself, no change in current logic. But in case of persistent lobby can get that event do checks and stop any further propagation of the event so breakout room module will not destroy it.

@dnna
Copy link
Contributor Author

dnna commented Nov 11, 2023

Hey @damencho @shawnchin, sorry for the late response. If it's possible, I'd prefer to split the changes to mod_muc_breakout_rooms into a separate PR and not block this one, as I'm not as comfortable editing it as I was with mod_persistent_lobby and it may take some time.

I think this PR already gives good value, as it resolves a scenario that is likely to occur for anyone who uses mod_persistent_lobby with breakout rooms. The other scenario exists, but to my understanding is more of an edge case (everyone jumps in the breakout rooms and leaves main room empty, while at the same time there is someone in the lobby). I think its fine to resolve at a later time.

@shawnchin
Copy link
Contributor

shawnchin commented Nov 12, 2023

I had a close look at the issue, and it looks like we indeed need to do more to make persistent_lobby play well with breakout rooms, and vice versa. At present, both breakout room and persistent lobby modules attempt to handle lifecycle of main room without being aware of each other.

@dnna Your fix effectively disables persistent lobby the moment a breakout room is created since main_room._data.breakout_rooms_active will always remain true once set. I agree this is better than no fix at all, as long as all are aware breakout room logic takes precedence if both are active.

As for the actual fix, I like @damencho 's suggestion that we trigger an event instead of immediately delete so another module has a chance to override it. But we will need to do this both ways.

P.S. Once a proper fix is in place, we will need to undo this change so persistent lobby will continue to work even if breakout rooms were created

@shawnchin
Copy link
Contributor

shawnchin commented Nov 12, 2023

@dnna can you test this fix and see if it works? -- #14044

If that PR works, we should not merge this PR as it stop persistent lobby from working when breakout rooms are created.

@shawnchin
Copy link
Contributor

shawnchin commented Nov 30, 2023

I believe this PR is superceded by #14044 and can be closed.

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.

5 participants