From c23d464c076a91ac12891a8ae2f750865bdc9ae6 Mon Sep 17 00:00:00 2001 From: a-wing <1@233.email> Date: Wed, 25 Nov 2026 00:41:16 +0800 Subject: [PATCH] fix(webapp): keep presentation when another screen share stops MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The presentation slot was a single global stream pushed and cleared by each player's watcher. When a second participant started and then stopped sharing, their player cleared the slot while the first participant was still sharing, and no watcher fired to restore it — the presentation disappeared for everyone until the surviving sharer touched a device (https://github.com/binbat/woom/issues/47). Derive the slot from a registry instead: streams register while their screen flag is set and unregister on stop/unmount; the newest registrant takes the stage and earlier ones resume when it leaves. Re-registering an existing id keeps its position so media refreshes never steal the stage. Adds a two-browser regression test that stops the second share and asserts the first presentation is still playing on both sides. Fixes #47 --- tests/media-lifecycle.spec.ts | 48 ++++++++++++++++++++++++ webapp/components/player/whep-player.vue | 26 ++++--------- webapp/components/player/whip-player.vue | 21 +++++------ webapp/store/atoms.ts | 31 ++++++++++++++- 4 files changed, 94 insertions(+), 32 deletions(-) diff --git a/tests/media-lifecycle.spec.ts b/tests/media-lifecycle.spec.ts index e657a44..07206a2 100644 --- a/tests/media-lifecycle.spec.ts +++ b/tests/media-lifecycle.spec.ts @@ -259,4 +259,52 @@ test.describe('device and media lifecycle', () => { await expect(toggle).toHaveAttribute('data-active', 'true') await expect(toggle).toBeEnabled() }) + + // https://github.com/binbat/woom/issues/47 + // A stops sharing while B is still sharing must not lose B's presentation: + // the slot is derived from everyone currently sharing, not last-writer-wins. + test('stopping the second share keeps the first presentation', async ({ + browser, + }) => { + const aliceContext = await browser.newContext() + const bobContext = await browser.newContext() + const alice = await aliceContext.newPage() + const bob = await bobContext.newPage() + try { + await mockDisplayMedia(alice) + await mockDisplayMedia(bob) + const roomId = await createMeeting(alice) + await joinRoom(alice, 'Alice') + await joinMeetingFromWelcome(bob, roomId) + await joinRoom(bob, 'Bob') + + const alicePresentation = alice + .getByTestId('presentation-player') + .getByTestId('video-remote') + const bobPresentation = bob + .getByTestId('presentation-player') + .getByTestId('video-remote') + + const aliceToggle = alice.getByTestId('toggle-screen') + await aliceToggle.click() + await expect(aliceToggle).toHaveAttribute('data-active', 'true') + await expectVideoPlaying(alicePresentation) + await expectVideoPlaying(bobPresentation) + + const bobToggle = bob.getByTestId('toggle-screen') + await bobToggle.click() + await expect(bobToggle).toHaveAttribute('data-active', 'true') + await expectVideoPlaying(alicePresentation) + await expectVideoPlaying(bobPresentation) + + await bobToggle.click() + await expect(bobToggle).toHaveAttribute('data-active', 'false') + await expect(aliceToggle).toHaveAttribute('data-active', 'true') + await expectVideoPlaying(alicePresentation) + await expectVideoPlaying(bobPresentation) + } finally { + await aliceContext.close() + await bobContext.close() + } + }) }) diff --git a/webapp/components/player/whep-player.vue b/webapp/components/player/whep-player.vue index a70dbe7..687a237 100644 --- a/webapp/components/player/whep-player.vue +++ b/webapp/components/player/whep-player.vue @@ -1,7 +1,7 @@