MuJoCo Web Viewer: Implement parallel chunked model downloading and in-place model reloading.
This change introduces parallel chunked downloading for large model files (.mjb) directly into WASM linear memory, enables model loading without full page reloads and reduces memory overhead. Key changes: - Implement a chunked model endpoint in the Python web server to support range requests. - Add parallel chunked fetching in the frontend with retry logic and a single-fetch fallback. - Increase initial WASM memory to 3 GB to accommodate large models and prevent heap fragmentation. - Support in-place model reloading in the C++ client, including texture cache invalidation when the Filament context is recreated. - Display a model download progress bar and model parsing/loading banner to the UI. - Fixes model drag and drop (caused by typo in sessionId, corrected to session_id). PiperOrigin-RevId: 960249236 Change-Id: Icac89e6a4ca099882aaf9b111744c1b6ab0cc6c1
This commit is contained in:
committed by
Copybara-Service
parent
7fd2061f5c
commit
84950fa371
@@ -174,7 +174,7 @@ class WebViewer(viewer_protocol.Viewer):
|
||||
extra_geoms: List of extra geoms. Internal list is created if None.
|
||||
host: Public interface the server binds to. The default "::" accepts both
|
||||
IPv6 and IPv4 connections (IPv4-only where IPv6 is unavailable).
|
||||
http_port: The single public port: page, WASM, /model.mjb, and the /ui and
|
||||
http_port: The single public port: page, WASM, /model, and the /ui and
|
||||
/state WebSocket paths. None falls back to config.http_port; 0 picks the
|
||||
first free port starting at 8080, so several viewers can run side by
|
||||
side.
|
||||
@@ -256,13 +256,13 @@ class WebViewer(viewer_protocol.Viewer):
|
||||
"""Starts (or restarts) the web server, serving the current model."""
|
||||
self._stop_servers()
|
||||
|
||||
# Serialize the compiled model to MJB bytes (served as /model.mjb).
|
||||
# Serialize the compiled model to MJB bytes (served as /model).
|
||||
buffer = np.empty(mujoco.mj_sizeModel(self.model), np.uint8)
|
||||
mujoco.mj_saveModel(self.model, None, buffer)
|
||||
mjb_data = buffer.tobytes()
|
||||
|
||||
# Identity of the served model, included in every state payload. When it
|
||||
# changes, the browser refetches /model.mjb by reloading the page.
|
||||
# changes, the browser refetches /model by reloading the page.
|
||||
self._model_crc32 = zlib.crc32(mjb_data)
|
||||
|
||||
state_sig = int(mujoco.mjtState.mjSTATE_INTEGRATION)
|
||||
|
||||
Reference in New Issue
Block a user