fix(viewer): make recorded layers deterministic

This commit is contained in:
DCCONSTRUCTIONS
2026-07-23 11:42:19 +03:00
parent 3a64f54dea
commit ee15160862
6 changed files with 222 additions and 34 deletions
@@ -49,6 +49,7 @@ export interface RerunViewportProps {
presentationGate?: RecordedAdmissionPhase;
expectedTimelineStartSeconds?: number;
expectedTimelineEndSeconds?: number;
initialPlaybackStartSeconds?: number;
onStatusChange?: (status: RerunViewportStatus, message?: string) => void;
onSelectionChange?: (selection: RerunSelection | null) => void;
onPlaybackChange?: (state: RerunPlaybackState | null) => void;
@@ -295,12 +296,21 @@ export function createRecordedAutoplayGate(): {
rangeNs: { min: number; max: number } | null,
seekToStart: (startNs: number) => void,
startPlaying: () => void,
preferredStartNs?: number,
) => boolean;
attempted: () => boolean;
} {
let consumed = false;
return {
attempt(viewerStarted, fullyBuffered, presentationReady, rangeNs, seekToStart, startPlaying) {
attempt(
viewerStarted,
fullyBuffered,
presentationReady,
rangeNs,
seekToStart,
startPlaying,
preferredStartNs,
) {
if (
consumed ||
!viewerStarted ||
@@ -309,8 +319,11 @@ export function createRecordedAutoplayGate(): {
!isUsableRecordedPlaybackRange(rangeNs)
) return false;
consumed = true;
const startNs = Number.isFinite(preferredStartNs)
? Math.min(Math.max(preferredStartNs as number, rangeNs.min), rangeNs.max)
: rangeNs.min;
return attemptRecordedAutoplay(
() => seekToStart(rangeNs.min),
() => seekToStart(startNs),
startPlaying,
);
},
@@ -515,7 +528,8 @@ export async function fetchRecordedBlueprintRrd(
custom_color: settings.customColor,
active_view: activeView,
view_reset_generation: viewResetGeneration,
unified_perception: perceptionLayers.enabled,
unified_perception:
perceptionLayers.detections2d || perceptionLayers.segmentation,
show_detections_2d: perceptionLayers.detections2d,
show_segmentation: perceptionLayers.segmentation,
show_cuboids_3d: perceptionLayers.cuboids3d,
@@ -616,6 +630,7 @@ export function RerunViewport({
presentationGate = "ready",
expectedTimelineStartSeconds,
expectedTimelineEndSeconds,
initialPlaybackStartSeconds,
onStatusChange,
onSelectionChange,
onPlaybackChange,
@@ -982,6 +997,9 @@ export function RerunViewport({
() => {
viewer.set_playing(event.recording_id, true);
},
initialPlaybackStartSeconds === undefined
? undefined
: initialPlaybackStartSeconds * 1_000_000_000,
);
if (autoplayStarted) {
playing = true;
@@ -1153,6 +1171,7 @@ export function RerunViewport({
expectedTimelineEndSeconds,
expectedTimelineStartSeconds,
followLive,
initialPlaybackStartSeconds,
onPlaybackChange,
onPlaybackControllerChange,
onSelectionChange,