Skip to content

fix(webapp): keep presentation when another screen share stops - #62

Merged
a-wing merged 1 commit into
mainfrom
fix/screen-share-presentation
Nov 24, 2026
Merged

a-wing merged 1 commit into
mainfrom
fix/screen-share-presentation

Conversation

@a-wing

@a-wing a-wing commented Nov 24, 2026 •

Copy link
Copy Markdown
Member

Problem (#47)

The shared screen is lost occasionally, with no stable repro. The captured scene: the sharer's browser is still capturing ("is sharing your screen"), both sides are connected, yet the presentation has vanished entirely.

Root cause

presentationStream was a single global slot, imperatively pushed and cleared by each player component's watcher. Repro sequence:

  1. A starts sharing → slot = A, everyone sees the presentation
  2. B starts sharing too → slot is taken over = B
  3. B stops sharing → B's watcher clears the slot
  4. A is still sharing, but A's watcher deps (screen/stream) never changed, so it never re-fires → the presentation is permanently lost for everyone until A touches a device (camera/mic toggle) which incidentally restores it

Overlapping shares are a necessary condition, hence rare and hard to repro. (The July 2025 version keyed the slot by display name, so a same-named or unnamed participant joining/leaving could clear someone else's presentation — even more fragile. After the React→Vue rewrite only the last-writer-wins class remained.)

Fix

Derive "who is sharing" instead of pushing/clearing imperatively (webapp/store/atoms.ts):

  • presentationCandidates: a registry keyed by streamId (Map, insertion order)
  • Streams register while their screen flag is set and unregister on stop/unmount; the newest registrant takes the stage, and earlier ones still registered resume when it leaves
  • Re-registering an existing id keeps its position, so media refreshes (mic/camera switches) never steal the stage
  • presentationStream becomes a computed — the "clear" operation no longer exists

Player components (whip/whep) only register/unregister themselves and never write the global slot.

Verification

  • New two-browser regression test (A shares → B shares → B stops → assert A's presentation still playing on both sides): RED before the fix (reproduces Some time share screen is lost #47), GREEN after
  • Full e2e suite: 65 passed (including the new test)
  • lint / vue-tsc / biome clean

Fixes #47

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
(#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
@a-wing
a-wing merged commit 301c415 into main Nov 24, 2026
14 checks passed
@a-wing
a-wing deleted the fix/screen-share-presentation branch November 24, 2026 16:50
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.

Some time share screen is lost

1 participant