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
+61 -1
View File
@@ -12,6 +12,7 @@ from pathlib import Path
import pytest
import k1link.device_plugins.xgrids_k1.rrd_export as export_module
import k1link.viewer.recorded as viewer_recorded_module
from k1link.device_plugins.xgrids_k1.mqtt.capture import (
CAPTURE_CLOCK_FILENAME,
FRAME_HEADER,
@@ -299,6 +300,39 @@ def test_zero_accumulation_uses_latest_frame_instead_of_empty_time_range() -> No
assert point_components == {"Points3D:radii"}
def test_cuboids_are_overlaid_on_the_stable_spatial_view_without_unifying_video() -> None:
baseline = viewer_recorded_blueprint(
RerunSceneSettings(accumulation_seconds=12.0),
include_initial_playback_state=False,
unified_perception=False,
show_cuboids_3d=False,
)
blueprint = viewer_recorded_blueprint(
RerunSceneSettings(accumulation_seconds=12.0),
include_initial_playback_state=False,
unified_perception=False,
show_cuboids_3d=True,
)
spatial_view = blueprint.root_container.contents[0]
assert spatial_view.id == baseline.root_container.contents[0].id
assert spatial_view.visualizer_overrides[
"/world/perception"
].visible.as_arrow_array().to_pylist() == [True]
assert spatial_view.visualizer_overrides[
"/world/perception/lidar"
].visible.as_arrow_array().to_pylist() == [False]
assert spatial_view.visualizer_overrides[
"/world/perception/support"
].visible.as_arrow_array().to_pylist() == [False]
assert spatial_view.visualizer_overrides[
"/world/perception/semantic_points"
].visible.as_arrow_array().to_pylist() == [False]
assert spatial_view.visualizer_overrides[
"/world/perception/boxes3d"
].visible.as_arrow_array().to_pylist() == [True]
def test_dynamic_blueprint_reuses_scene_ids_without_playback_mutation() -> None:
first = _recorded_blueprint(
RerunSceneSettings(show_points=False, show_trajectory=True),
@@ -416,7 +450,26 @@ def test_viewer_blueprint_reset_is_bounded_and_recreates_render_views() -> None:
assert perception_behavior.visible.as_arrow_array().to_pylist() == [False]
def test_recorded_blueprint_layer_updates_preserve_store_until_explicit_reset() -> None:
def test_recorded_blueprint_layer_updates_preserve_store_until_explicit_reset(
monkeypatch: pytest.MonkeyPatch,
) -> None:
activations: list[tuple[object, bool, bool]] = []
send_blueprint = viewer_recorded_module.bindings.send_blueprint
def capture_activation(
storage: object,
make_active: bool,
make_default: bool,
recording: object,
) -> None:
activations.append((storage, make_active, make_default))
send_blueprint(storage, make_active, make_default, recording)
monkeypatch.setattr(
viewer_recorded_module.bindings,
"send_blueprint",
capture_activation,
)
session_id = "b" * 32
initial = viewer_recorded_blueprint_rrd(
RerunSceneSettings(accumulation_seconds=12.0),
@@ -452,6 +505,13 @@ def test_recorded_blueprint_layer_updates_preserve_store_until_explicit_reset()
assert layer_store_ids == initial_store_ids
assert len(reset_store_ids) == 1
assert reset_store_ids.isdisjoint(initial_store_ids)
assert [activation[1:] for activation in activations] == [
(True, False),
(True, False),
(True, False),
]
assert activations[0][0] is activations[1][0]
assert activations[2][0] is not activations[0][0]
assert len(initial) < 350_000
assert len(layers_enabled) < 350_000
assert len(reset) < 350_000