Skip to content

Returning to the tab reloads the video and can broadcast a spurious play #7

Description

@7akob

Switching away from Skood and back causes a visible stall, and sometimes yanks playback for everyone else in the room.

Two things happening in public/script.js:

  1. The visibilitychange handler (public/script.js:302) fires request_sync on every return to the tab. The server answers with sync_state, and applySync() unconditionally calls loadVideoById() — a full player reload — even when the video hasn't changed and you're only a fraction of a second out. That reload is the lag.

  2. That reload then fires a PLAYING state change. suppressEvents is cleared after a fixed 300ms (resetSuppress(), public/script.js:470), but the reload finishes later than that, so onStateChange treats it as a real user action and emits play. Everyone else gets seeked because you changed tabs.

Fix: applySync() should compare against current state — same videoId and drift under a threshold means do nothing, small drift means seekTo(), only reload when the video actually changed. The fixed 300ms suppression window is fragile in general and would be better tied to the player reaching the expected state than to a timer.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions