fix(syncplay): report latency pings for timely commands
Continuous Integration / build_web (push) Failing after 0s
Continuous Integration / build (macos-latest) (push) Skipped
Continuous Integration / build (ubuntu-22.04) (push) Skipped
Continuous Integration / build (windows-11-arm) (push) Skipped
Continuous Integration / build (windows-latest) (push) Skipped
Continuous Integration / nightly_release (push) Skipped

SyncPlay expects Ping as a latency in milliseconds, not a timestamp. Date.now() was clamped to 10s and delayed scheduled unpause/seek commands. Send a 50 ms latency every 3 seconds while in a group.
This commit is contained in:
1xDed committed 2026-11-29 08:41:08 +03:00
1 parent 31826f1098
commit e89932fc7d
2 files changed
+27 -1

No files matched your search

+14 -1
View File
@@ -1,7 +1,10 @@
import { useNavigate } from "@tanstack/react-router";
import React, { useEffect } from "react";
import { getLocalPlayback } from "@/utils/methods/localPlayback";
import { reportSyncPlayReady } from "@/utils/methods/syncPlay";
import {
pingSyncPlayGroup,
reportSyncPlayReady,
} from "@/utils/methods/syncPlay";
import { useApiInContext } from "@/utils/store/api";
import { useCentralStore } from "@/utils/store/central";
import useSyncPlayStore from "@/utils/store/syncPlay";
@@ -28,6 +31,16 @@ const SyncPlayController = () => {
});
}, [pendingNavigation, setPendingNavigation, navigate]);
// SyncPlay uses pings to estimate latency and schedule unpause commands.
useEffect(() => {
if (!api || !group?.GroupId) return;
void pingSyncPlayGroup(api);
const timer = window.setInterval(() => {
void pingSyncPlayGroup(api);
}, 3000);
return () => window.clearInterval(timer);
}, [api, group?.GroupId]);
// While a group is waiting, keep telling the server this player is ready.
// Some clients miss the one-shot Ready after a queue update; retrying is
// harmless and lets the server release the group as soon as it can.