From 8b667e6ad7bfc77882c4ca39ea6b3ebffcb5f7ac Mon Sep 17 00:00:00 2001 From: rakadu1 Date: Fri, 28 Nov 2025 16:24:21 +0530 Subject: [PATCH] Throttling the update explorer for the MATLAB style data explorer had unnescessary function calls even when closed. Removed that for 20% perf. boost. --- steps/src/dataExplorer.js | 5 +++++ steps/src/sync.js | 6 ++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/steps/src/dataExplorer.js b/steps/src/dataExplorer.js index 6ff4054..82c4215 100644 --- a/steps/src/dataExplorer.js +++ b/steps/src/dataExplorer.js @@ -31,6 +31,9 @@ let trackGridApi = null; let chartInstance = null; let currentGridData = null; +// --- EXPORTED STATE for Optimization --- +export let isExplorerOpen = false; + // --- AG Grid Configuration --- const gridOptions = { rowData: [], @@ -102,11 +105,13 @@ function createChart(data, label) { function showExplorer() { panel.classList.remove('hidden'); + isExplorerOpen = true; // Update state updateExplorer(); } function hideExplorer() { panel.classList.add('hidden'); + isExplorerOpen = false; // Update state } function switchTab(targetTab) { diff --git a/steps/src/sync.js b/steps/src/sync.js index 6f2787d..cae2058 100644 --- a/steps/src/sync.js +++ b/steps/src/sync.js @@ -15,7 +15,7 @@ import { } from "./dom.js"; import { VIDEO_FPS } from "./constants.js"; import { findRadarFrameIndexForTime, precomputeRadarVideoSync } from "./utils.js"; -import { throttledUpdateExplorer } from "./dataExplorer.js"; +import { throttledUpdateExplorer, isExplorerOpen } from "./dataExplorer.js"; import { debugFlags } from "./debug.js"; // --- [START] MOVED FROM DOM.JS --- @@ -137,7 +137,9 @@ export function updateFrame(frame, forceVideoSeek = false, overrideTime = null) // We no longer call redraw() from here. // --- NEW: Centralized Explorer Update --- - throttledUpdateExplorer(); + if (isExplorerOpen) { + throttledUpdateExplorer(); + } // --- END: Centralized Explorer Update --- const endTime = performance.now(); appState.lastFrameRenderTime = endTime - startTime; // <-- End timer and update state