@@ -150,26 +150,13 @@ async def get_state(self, timeout: float) -> PersistedViewerStateV1:
150150 Capture the current viewer state and return it as a
151151 :class:`PersistedViewerStateV1`.
152152
153- The frontend round trip (:meth:`_get_runtime_state_async`) remains the
154- only source for everything the browser owns — UI panels, unit, the
155- display toggles, camera, cross-section and the per-variable ranges.
156- **Per-part state is not taken from it.** The dataset registry is the
157- server-side authority for that, so ``scene.dataset_states`` is replaced
158- wholesale with the registry's own runtime state before the persisted
159- mapping runs. The browser is no longer consulted for per-part state.
160-
161- The registry is read under ``_vtk_lock`` and each dataset state is
162- deep-copied out of it. The registry hands out its live
163- ``RuntimeDatasetState`` objects by reference, and the per-part setters
164- mutate the records they contain in place from the trame daemon thread;
165- without the snapshot the persist mapper would be an unlocked reader of
166- records that are being written concurrently. The lock is taken *after*
167- the ``await`` has completed and released before the mapping, so it is
168- never held across an ``await``. Named cost: this is the only place a
169- coroutine acquires ``_vtk_lock``, so a save issued while a long
170- main-thread VTK call holds the lock waits for that call. It cannot
171- deadlock: the outbound bridge call made under the lock reaches
172- ``loop.call_later`` and returns without waiting on the event loop.
153+ The frontend round trip remains the only source for everything the browser owns.
154+ Per-part state is not: ``scene.dataset_states`` is replaced with the registry's
155+ own runtime state before the persisted mapping runs.
156+
157+ The registry hands out live ``RuntimeDatasetState`` objects that the per-part
158+ setters mutate from teh trame daemon thread, so each one is deep-copied under
159+ ``_vtk_lock``. The lock is taken after the ``await`` and never held across one.
173160 """
174161 runtime_state = await self ._get_runtime_state_async (timeout )
175162
@@ -203,13 +190,8 @@ def apply_state(self, state: PersistedViewerStateV1):
203190 # Transform the frontend PersistedViewerStateV1 -> RuntimeAppState
204191 runtime_app_state = self ._state_mapper .persisted_to_runtime (state )
205192
206- # Restore per-part state server-side: write the registry, then apply
207- # every part to this process's VTK pipeline. The browser is not
208- # asked to do this, and is not trusted to have done it.
209193 self ._restore_part_states_from_runtime (runtime_app_state )
210194
211- # Renderer-specific: flush VTK window and notify frontend (wasm), or
212- # push camera to vtkCamera (RCA), or no-op (headless).
213195 self ._apply_runtime_state_to_render (runtime_app_state )
214196
215197 # Note: There is intentionally no wasm flush here: the bridge call is fire-and-forget, so a flush
0 commit comments