Skip duplicate semantic state frames
This commit is contained in:
parent
1a87c9bad3
commit
6a34137fa9
@ -432,6 +432,12 @@ Scene evidence:
|
||||
at `2000ms` or slower. Direct control confirmation still uses compact
|
||||
`/state?compact=1`, so pause/resume latency stays independent of the
|
||||
background paused poll cadence.
|
||||
- Semantic duplicate-state elision: `/state` frames are parsed into a semantic
|
||||
signature that ignores volatile transport telemetry such as `server_time`.
|
||||
When the signature is unchanged, the state client counts the poll but does
|
||||
not forward the frame to the Three.js preview, avoiding body merge, binding
|
||||
traversal, matrix checks, diagnostics writes, and render dirties for repeated
|
||||
paused-state frames.
|
||||
- Incremental body-state merge: active-state frames mutate the retained body map
|
||||
by payload key instead of spreading/copying the full `602`-body map on every
|
||||
poll, reducing steady-state allocation and GC pressure while preserving full
|
||||
@ -472,13 +478,13 @@ Scene evidence:
|
||||
Bundle evidence:
|
||||
|
||||
- JavaScript chunks: `4`
|
||||
- App entry chunk: `202.06 kB raw / 52.24 kB gzip`
|
||||
- App entry chunk: `204.21 kB raw / 52.76 kB gzip`
|
||||
- Largest JavaScript gzip chunk: `140.96 KiB / 170.00 KiB`
|
||||
- Total JavaScript gzip: `215.84 KiB / 230.00 KiB`
|
||||
- Total JavaScript gzip: `217.58 KiB / 230.00 KiB`
|
||||
- Large-scene performance mode: `large-scene`, target `45 fps`,
|
||||
actual idle render rate `0.9 fps`, DPR cap observed at `1.00` in release
|
||||
actual idle render rate `0.8 fps`, DPR cap observed at `1.00` in release
|
||||
gate, `preserveDrawingBuffer=false`, `1` explicit readback render, shadows
|
||||
`off`, hover picking throttled to `32ms`, `255` empty frames
|
||||
`off`, hover picking throttled to `32ms`, `693` empty frames
|
||||
skipped, `135` static visual nodes frozen, `568` instanced local-pose nodes
|
||||
elided, `59` remaining mesh clones using
|
||||
pre-frozen source state, `627` repeated spin scans skipped, `568` repeated
|
||||
@ -487,17 +493,18 @@ Bundle evidence:
|
||||
frustum culling plus static instance matrices, `7` primitive geometry shapes
|
||||
cached, `51` mesh source assets retained, `24/51` mesh cache hit/miss in the
|
||||
primary large scene, `636` cached object bounds, `627` fast pick-target
|
||||
bounds from `51` cached source bounds, real hover proof `hoverProxy 1` with
|
||||
bounds from `51` cached source bounds, real hover proof `hoverProxy 2` with
|
||||
cached bounds and `fallback 0`, with `0` camera-fit traversals, `4/84`
|
||||
progressive scene root batches under the computed `84` root cap and `5`
|
||||
batch cap, `273` no-op loading frames
|
||||
batch cap, `327` no-op loading frames
|
||||
suppressed during the primary load, `26` browser event-loop yields during
|
||||
scene construction, active state payload `34/602` with `2` reduced frames and
|
||||
`3` incremental body-map merges,
|
||||
UI physics-profile cache `30/3` hit/miss, UI builder-profile cache `33/1`
|
||||
hit/miss, UI text write gating `107/521` write/skip, text selector cache
|
||||
`582/46` hit/miss, scratch bounds transforms `1263`, diagnostics panel
|
||||
throttling `22/5` render/skip, `88/636`
|
||||
scene construction, active state payload `34/602` with `1` reduced frame and
|
||||
`2` incremental body-map merges, semantic poll forwarding `6/2/4`
|
||||
parsed/forwarded/duplicate-skip,
|
||||
UI physics-profile cache `24/3` hit/miss, UI builder-profile cache `27/1`
|
||||
hit/miss, UI text write gating `101/418` write/skip, text selector cache
|
||||
`473/46` hit/miss, scratch bounds transforms `1263`, diagnostics panel
|
||||
throttling `19/3` render/skip, `88/636`
|
||||
hover targets over cached bounds used for bounds-only ray tests,
|
||||
and a stable paused backend state cache reported `manual roots 636 updates
|
||||
67` with `state apply 0/skip 67`.
|
||||
@ -516,6 +523,10 @@ Bundle evidence:
|
||||
real paused poll and checks running/paused poll telemetry, proving the
|
||||
browser uses a low-latency active stream while running and a slower cadence
|
||||
after pausing.
|
||||
- Semantic duplicate-state gate: the same browser gate also requires parsed
|
||||
poll frames to exceed forwarded frames and requires the duplicate-skip counter
|
||||
to increase, proving repeated paused state is stopped before it reaches the
|
||||
renderer and UI panels.
|
||||
- UI refresh gate: `browser-large-scene-performance-mode` now checks duplicate
|
||||
text-write skips, stable text-selector cache hits, and diagnostics-panel
|
||||
refresh skips, proving high-frequency `/state` polling does not force
|
||||
|
||||
@ -692,6 +692,9 @@ async function readBrowserStats(page) {
|
||||
statePollRequestCount: numberData("statePollRequestCount"),
|
||||
stateActivePollRequestCount: numberData("stateActivePollRequestCount"),
|
||||
statePausedPollRequestCount: numberData("statePausedPollRequestCount"),
|
||||
stateParsedPollFrameCount: numberData("stateParsedPollFrameCount"),
|
||||
stateForwardedPollFrameCount: numberData("stateForwardedPollFrameCount"),
|
||||
stateSkippedDuplicatePollFrameCount: numberData("stateSkippedDuplicatePollFrameCount"),
|
||||
batchedSceneRootCount: numberData("batchedSceneRootCount"),
|
||||
sceneRootBatchCount: numberData("sceneRootBatchCount"),
|
||||
objectPhysicsProfileCacheHitCount: numberData("objectPhysicsProfileCacheHitCount"),
|
||||
@ -751,20 +754,26 @@ async function waitForStableBodyStateCache(page) {
|
||||
async function waitForAdaptiveStatePolling(page) {
|
||||
const before = await readBrowserStats(page);
|
||||
const beforePausedPolls = before.renderPerformance?.statePausedPollRequestCount ?? 0;
|
||||
await page.waitForFunction(([previousPausedPolls]) => {
|
||||
const beforeDuplicateSkips = before.renderPerformance?.stateSkippedDuplicatePollFrameCount ?? 0;
|
||||
await page.waitForFunction(([previousPausedPolls, previousDuplicateSkips]) => {
|
||||
const data = document.documentElement.dataset;
|
||||
const base = Number(data.stateBasePollIntervalMs ?? "0");
|
||||
const paused = Number(data.statePausedPollIntervalMs ?? "0");
|
||||
const scheduled = Number(data.stateLastScheduledPollIntervalMs ?? "0");
|
||||
const activePolls = Number(data.stateActivePollRequestCount ?? "0");
|
||||
const pausedPolls = Number(data.statePausedPollRequestCount ?? "0");
|
||||
const parsedFrames = Number(data.stateParsedPollFrameCount ?? "0");
|
||||
const forwardedFrames = Number(data.stateForwardedPollFrameCount ?? "0");
|
||||
const skippedDuplicates = Number(data.stateSkippedDuplicatePollFrameCount ?? "0");
|
||||
return base > 0
|
||||
&& base <= 80
|
||||
&& paused >= 2000
|
||||
&& scheduled >= paused
|
||||
&& activePolls > 0
|
||||
&& pausedPolls > previousPausedPolls;
|
||||
}, [beforePausedPolls], { polling: 100, timeout: 7000 });
|
||||
&& pausedPolls > previousPausedPolls
|
||||
&& skippedDuplicates > previousDuplicateSkips
|
||||
&& parsedFrames > forwardedFrames;
|
||||
}, [beforePausedPolls, beforeDuplicateSkips], { polling: 100, timeout: 10000 });
|
||||
const stats = await readBrowserStats(page);
|
||||
const perf = stats.renderPerformance ?? {};
|
||||
return {
|
||||
@ -772,10 +781,12 @@ async function waitForAdaptiveStatePolling(page) {
|
||||
&& (perf.statePausedPollIntervalMs ?? 0) >= 2000
|
||||
&& (perf.stateLastScheduledPollIntervalMs ?? 0) >= (perf.statePausedPollIntervalMs ?? Number.POSITIVE_INFINITY)
|
||||
&& (perf.stateActivePollRequestCount ?? 0) > 0
|
||||
&& (perf.statePausedPollRequestCount ?? 0) > beforePausedPolls,
|
||||
&& (perf.statePausedPollRequestCount ?? 0) > beforePausedPolls
|
||||
&& (perf.stateSkippedDuplicatePollFrameCount ?? 0) > beforeDuplicateSkips
|
||||
&& (perf.stateParsedPollFrameCount ?? 0) > (perf.stateForwardedPollFrameCount ?? 0),
|
||||
before,
|
||||
stats,
|
||||
detail: `poll=${perf.stateBasePollIntervalMs ?? "-"}/${perf.statePausedPollIntervalMs ?? "-"}/${perf.stateLastScheduledPollIntervalMs ?? "-"}ms requests=${perf.statePollRequestCount ?? "-"}/${perf.stateActivePollRequestCount ?? "-"}/${perf.statePausedPollRequestCount ?? "-"} beforePaused=${beforePausedPolls}`,
|
||||
detail: `poll=${perf.stateBasePollIntervalMs ?? "-"}/${perf.statePausedPollIntervalMs ?? "-"}/${perf.stateLastScheduledPollIntervalMs ?? "-"}ms requests=${perf.statePollRequestCount ?? "-"}/${perf.stateActivePollRequestCount ?? "-"}/${perf.statePausedPollRequestCount ?? "-"} semantic=${perf.stateParsedPollFrameCount ?? "-"}/${perf.stateForwardedPollFrameCount ?? "-"}/${perf.stateSkippedDuplicatePollFrameCount ?? "-"} before=${beforePausedPolls}/${beforeDuplicateSkips}`,
|
||||
};
|
||||
}
|
||||
|
||||
@ -1788,6 +1799,8 @@ async function verifyBrowser() {
|
||||
&& (renderPerformance.stateBasePollIntervalMs ?? Number.POSITIVE_INFINITY) <= 80
|
||||
&& (renderPerformance.statePausedPollIntervalMs ?? 0) >= 2000
|
||||
&& (renderPerformance.stateActivePollRequestCount ?? 0) > 0
|
||||
&& (renderPerformance.stateSkippedDuplicatePollFrameCount ?? 0) > 0
|
||||
&& (renderPerformance.stateParsedPollFrameCount ?? 0) > (renderPerformance.stateForwardedPollFrameCount ?? 0)
|
||||
&& (renderPerformance.batchedSceneRootCount ?? Number.POSITIVE_INFINITY) <= maxInstancedSceneRoots
|
||||
&& (renderPerformance.sceneRootBatchCount ?? 0) > 1
|
||||
&& (renderPerformance.sceneRootBatchCount ?? Number.POSITIVE_INFINITY) <= maxProgressiveSceneRootBatches
|
||||
@ -1807,7 +1820,7 @@ async function verifyBrowser() {
|
||||
&& (renderPerformance.hoverPickTargetCount ?? Number.POSITIVE_INFINITY) <= maxHoverPickTargets
|
||||
&& (renderPerformance.skippedBodyStateCount ?? 0) > 0
|
||||
&& desktopStats.diagnostics.renderPerformance.includes("large-scene"),
|
||||
`mode=${renderPerformance.largeSceneMode} fps=${renderPerformance.targetRenderFps ?? "-"} statsRefresh=${renderPerformance.statsRefreshIntervalMs ?? "-"}ms ${renderPerformance.statsRefreshRenderCount ?? "-"}/${renderPerformance.statsRefreshSkipCount ?? "-"} dpr=${renderPerformance.renderPixelRatio ?? "-"} buffer=${renderPerformance.preserveDrawingBufferEnabled} readback=${renderPerformance.readbackRenderCount ?? "-"} shadows=${renderPerformance.shadowsEnabled} hover=${renderPerformance.hoverPickIntervalMs ?? "-"} skipped=${renderPerformance.renderSkipCount ?? "-"} frozen=${renderPerformance.frozenStaticObjectCount ?? "-"} prefrozen=${renderPerformance.preFrozenMeshCloneCount ?? "-"} spinSkip=${renderPerformance.spinningScanSkippedCount ?? "-"} instanced=${renderPerformance.instancedMeshObjectCount ?? "-"}/${renderPerformance.instancedMeshBatchCount ?? "-"}/${renderPerformance.instancedMeshDrawCount ?? "-"} matrices=${renderPerformance.instancedMeshMatrixUpdateCount ?? "-"} cull=${renderPerformance.instancedMeshFrustumCulledCount ?? "-"} static=${renderPerformance.instancedMeshStaticMatrixCount ?? "-"} elidedLocal=${renderPerformance.instancedLocalObjectElisionCount ?? "-"} manualRoots=${renderPerformance.manualMatrixRootCount ?? "-"} manualUpdates=${renderPerformance.manualMatrixUpdateCount ?? "-"} primitiveGeometries=${renderPerformance.primitiveGeometryCount ?? "-"} meshCache=${renderPerformance.meshCacheSourceCount ?? "-"} hit=${renderPerformance.meshCacheHitCount ?? "-"} miss=${renderPerformance.meshCacheMissCount ?? "-"} retained=${renderPerformance.retainedMeshGeometryCount ?? "-"}g/${renderPerformance.retainedMeshMaterialCount ?? "-"}m bounds=${renderPerformance.sceneObjectBoundsCount ?? "-"} fast=${renderPerformance.fastPickProxyBoundsCount ?? "-"} scratch=${renderPerformance.pickBoundsScratchTransformCount ?? "-"} source=${renderPerformance.meshSourceBoundsCount ?? "-"} hoverProxy=${renderPerformance.hoverProxyBoundsHitCount ?? "-"} cached=${renderPerformance.hoverCachedBoundsHitCount ?? "-"}/fallback=${renderPerformance.hoverRootBoundsFallbackCount ?? "-"} cameraTraversals=${renderPerformance.cameraFitTraversalCount ?? "-"} sceneBatches=${renderPerformance.sceneRootBatchCount ?? "-"}/${renderPerformance.batchedSceneRootCount ?? "-"} maxSceneRoots=${maxInstancedSceneRoots} maxBatches=${maxProgressiveSceneRootBatches} suppressed=${renderPerformance.sceneLoadSuppressedRenderCount ?? "-"} yields=${renderPerformance.sceneBuildYieldCount ?? "-"} statePayload=${renderPerformance.statePayloadBodyCount ?? "-"}/${renderPerformance.mergedBodyStateCount ?? "-"} reduced=${renderPerformance.reducedStateFrameCount ?? "-"} incremental=${renderPerformance.incrementalBodyMergeCount ?? "-"} poll=${renderPerformance.stateBasePollIntervalMs ?? "-"}/${renderPerformance.statePausedPollIntervalMs ?? "-"}/${renderPerformance.stateLastScheduledPollIntervalMs ?? "-"}ms ${renderPerformance.statePollRequestCount ?? "-"}/${renderPerformance.stateActivePollRequestCount ?? "-"}/${renderPerformance.statePausedPollRequestCount ?? "-"} uiCache=physics ${renderPerformance.objectPhysicsProfileCacheHitCount ?? "-"}/${renderPerformance.objectPhysicsProfileCacheMissCount ?? "-"} builder ${renderPerformance.builderPhysicsProfileCacheHitCount ?? "-"}/${renderPerformance.builderPhysicsProfileCacheMissCount ?? "-"} text ${renderPerformance.textWriteCount ?? "-"}/${renderPerformance.textWriteSkipCount ?? "-"} selector ${renderPerformance.textSelectorCacheHitCount ?? "-"}/${renderPerformance.textSelectorCacheMissCount ?? "-"} diagnostics ${renderPerformance.diagnosticsPanelRenderCount ?? "-"}/${renderPerformance.diagnosticsPanelSkipCount ?? "-"} builderPanels=${renderPerformance.builderPanelRenderCount ?? "-"}/${renderPerformance.builderPanelDeferredRenderCount ?? "-"}/${renderPerformance.builderPanelCoalescedRenderCount ?? "-"} pickTargets=${renderPerformance.hoverPickTargetCount ?? "-"}/${renderPerformance.pickProxyCount ?? "-"} hoverBudget=${maxHoverPickTargets} stateApply=${renderPerformance.appliedBodyStateCount ?? "-"}/skip=${renderPerformance.skippedBodyStateCount ?? "-"} unchanged=${renderPerformance.unchangedFrameCount ?? "-"} released=${renderPerformance.releasedGeometryCount ?? "-"}g/${renderPerformance.releasedMaterialCount ?? "-"}m/${renderPerformance.releasedTextureCount ?? "-"}t; ${desktopStats.diagnostics.renderPerformance}`,
|
||||
`mode=${renderPerformance.largeSceneMode} fps=${renderPerformance.targetRenderFps ?? "-"} statsRefresh=${renderPerformance.statsRefreshIntervalMs ?? "-"}ms ${renderPerformance.statsRefreshRenderCount ?? "-"}/${renderPerformance.statsRefreshSkipCount ?? "-"} dpr=${renderPerformance.renderPixelRatio ?? "-"} buffer=${renderPerformance.preserveDrawingBufferEnabled} readback=${renderPerformance.readbackRenderCount ?? "-"} shadows=${renderPerformance.shadowsEnabled} hover=${renderPerformance.hoverPickIntervalMs ?? "-"} skipped=${renderPerformance.renderSkipCount ?? "-"} frozen=${renderPerformance.frozenStaticObjectCount ?? "-"} prefrozen=${renderPerformance.preFrozenMeshCloneCount ?? "-"} spinSkip=${renderPerformance.spinningScanSkippedCount ?? "-"} instanced=${renderPerformance.instancedMeshObjectCount ?? "-"}/${renderPerformance.instancedMeshBatchCount ?? "-"}/${renderPerformance.instancedMeshDrawCount ?? "-"} matrices=${renderPerformance.instancedMeshMatrixUpdateCount ?? "-"} cull=${renderPerformance.instancedMeshFrustumCulledCount ?? "-"} static=${renderPerformance.instancedMeshStaticMatrixCount ?? "-"} elidedLocal=${renderPerformance.instancedLocalObjectElisionCount ?? "-"} manualRoots=${renderPerformance.manualMatrixRootCount ?? "-"} manualUpdates=${renderPerformance.manualMatrixUpdateCount ?? "-"} primitiveGeometries=${renderPerformance.primitiveGeometryCount ?? "-"} meshCache=${renderPerformance.meshCacheSourceCount ?? "-"} hit=${renderPerformance.meshCacheHitCount ?? "-"} miss=${renderPerformance.meshCacheMissCount ?? "-"} retained=${renderPerformance.retainedMeshGeometryCount ?? "-"}g/${renderPerformance.retainedMeshMaterialCount ?? "-"}m bounds=${renderPerformance.sceneObjectBoundsCount ?? "-"} fast=${renderPerformance.fastPickProxyBoundsCount ?? "-"} scratch=${renderPerformance.pickBoundsScratchTransformCount ?? "-"} source=${renderPerformance.meshSourceBoundsCount ?? "-"} hoverProxy=${renderPerformance.hoverProxyBoundsHitCount ?? "-"} cached=${renderPerformance.hoverCachedBoundsHitCount ?? "-"}/fallback=${renderPerformance.hoverRootBoundsFallbackCount ?? "-"} cameraTraversals=${renderPerformance.cameraFitTraversalCount ?? "-"} sceneBatches=${renderPerformance.sceneRootBatchCount ?? "-"}/${renderPerformance.batchedSceneRootCount ?? "-"} maxSceneRoots=${maxInstancedSceneRoots} maxBatches=${maxProgressiveSceneRootBatches} suppressed=${renderPerformance.sceneLoadSuppressedRenderCount ?? "-"} yields=${renderPerformance.sceneBuildYieldCount ?? "-"} statePayload=${renderPerformance.statePayloadBodyCount ?? "-"}/${renderPerformance.mergedBodyStateCount ?? "-"} reduced=${renderPerformance.reducedStateFrameCount ?? "-"} incremental=${renderPerformance.incrementalBodyMergeCount ?? "-"} poll=${renderPerformance.stateBasePollIntervalMs ?? "-"}/${renderPerformance.statePausedPollIntervalMs ?? "-"}/${renderPerformance.stateLastScheduledPollIntervalMs ?? "-"}ms ${renderPerformance.statePollRequestCount ?? "-"}/${renderPerformance.stateActivePollRequestCount ?? "-"}/${renderPerformance.statePausedPollRequestCount ?? "-"} semantic=${renderPerformance.stateParsedPollFrameCount ?? "-"}/${renderPerformance.stateForwardedPollFrameCount ?? "-"}/${renderPerformance.stateSkippedDuplicatePollFrameCount ?? "-"} uiCache=physics ${renderPerformance.objectPhysicsProfileCacheHitCount ?? "-"}/${renderPerformance.objectPhysicsProfileCacheMissCount ?? "-"} builder ${renderPerformance.builderPhysicsProfileCacheHitCount ?? "-"}/${renderPerformance.builderPhysicsProfileCacheMissCount ?? "-"} text ${renderPerformance.textWriteCount ?? "-"}/${renderPerformance.textWriteSkipCount ?? "-"} selector ${renderPerformance.textSelectorCacheHitCount ?? "-"}/${renderPerformance.textSelectorCacheMissCount ?? "-"} diagnostics ${renderPerformance.diagnosticsPanelRenderCount ?? "-"}/${renderPerformance.diagnosticsPanelSkipCount ?? "-"} builderPanels=${renderPerformance.builderPanelRenderCount ?? "-"}/${renderPerformance.builderPanelDeferredRenderCount ?? "-"}/${renderPerformance.builderPanelCoalescedRenderCount ?? "-"} pickTargets=${renderPerformance.hoverPickTargetCount ?? "-"}/${renderPerformance.pickProxyCount ?? "-"} hoverBudget=${maxHoverPickTargets} stateApply=${renderPerformance.appliedBodyStateCount ?? "-"}/skip=${renderPerformance.skippedBodyStateCount ?? "-"} unchanged=${renderPerformance.unchangedFrameCount ?? "-"} released=${renderPerformance.releasedGeometryCount ?? "-"}g/${renderPerformance.releasedMaterialCount ?? "-"}m/${renderPerformance.releasedTextureCount ?? "-"}t; ${desktopStats.diagnostics.renderPerformance}`,
|
||||
);
|
||||
check(
|
||||
"browser-debug-capture-png",
|
||||
|
||||
11
src/main.ts
11
src/main.ts
@ -225,6 +225,9 @@ interface RuntimeDiagnostics {
|
||||
statePollRequestCount: number;
|
||||
stateActivePollRequestCount: number;
|
||||
statePausedPollRequestCount: number;
|
||||
stateParsedPollFrameCount: number;
|
||||
stateForwardedPollFrameCount: number;
|
||||
stateSkippedDuplicatePollFrameCount: number;
|
||||
batchedSceneRootCount: number;
|
||||
sceneRootBatchCount: number;
|
||||
objectPhysicsProfileCacheHitCount: number;
|
||||
@ -2709,6 +2712,9 @@ function currentRuntimeDiagnostics(
|
||||
statePollRequestCount: stateStats.pollRequestCount,
|
||||
stateActivePollRequestCount: stateStats.activePollRequestCount,
|
||||
statePausedPollRequestCount: stateStats.pausedPollRequestCount,
|
||||
stateParsedPollFrameCount: stateStats.parsedPollFrameCount,
|
||||
stateForwardedPollFrameCount: stateStats.forwardedPollFrameCount,
|
||||
stateSkippedDuplicatePollFrameCount: stateStats.skippedDuplicatePollFrameCount,
|
||||
batchedSceneRootCount: stats.batchedSceneRootCount,
|
||||
sceneRootBatchCount: stats.sceneRootBatchCount,
|
||||
objectPhysicsProfileCacheHitCount,
|
||||
@ -2785,7 +2791,7 @@ function currentDiagnosticsReport(): string {
|
||||
function renderPerformanceLabel(stats: RuntimeDiagnostics["stats"]): string {
|
||||
const mode = stats.largeSceneMode ? "large-scene" : "standard";
|
||||
const shadows = stats.shadowsEnabled ? "shadows on" : "shadows off";
|
||||
return `${mode}; target ${stats.targetRenderFps} fps; actual ${stats.actualRenderFps.toFixed(1)} fps; stats refresh ${stats.statsRefreshIntervalMs}ms ${stats.statsRefreshRenderCount}/${stats.statsRefreshSkipCount}; dpr ${stats.renderPixelRatio.toFixed(2)}; buffer preserved ${stats.preserveDrawingBufferEnabled}; readback renders ${stats.readbackRenderCount}; ${shadows}; skipped ${stats.renderSkipCount}; hover ${stats.hoverPickIntervalMs}ms; frozen ${stats.frozenStaticObjectCount} prefrozen ${stats.preFrozenMeshCloneCount} spinSkip ${stats.spinningScanSkippedCount}; instanced ${stats.instancedMeshObjectCount}/${stats.instancedMeshBatchCount}/${stats.instancedMeshDrawCount} matrices ${stats.instancedMeshMatrixUpdateCount} cull ${stats.instancedMeshFrustumCulledCount} static ${stats.instancedMeshStaticMatrixCount} elidedLocal ${stats.instancedLocalObjectElisionCount}; manual roots ${stats.manualMatrixRootCount} updates ${stats.manualMatrixUpdateCount}; primitive geometries ${stats.primitiveGeometryCount}; mesh cache ${stats.meshCacheSourceCount} sources ${stats.meshCacheHitCount}/${stats.meshCacheMissCount} hit/miss retained ${stats.retainedMeshGeometryCount}g/${stats.retainedMeshMaterialCount}m; bounds cache ${stats.sceneObjectBoundsCount} fast ${stats.fastPickProxyBoundsCount} scratch ${stats.pickBoundsScratchTransformCount} source ${stats.meshSourceBoundsCount} hoverProxy ${stats.hoverProxyBoundsHitCount} cached ${stats.hoverCachedBoundsHitCount}/fallback ${stats.hoverRootBoundsFallbackCount} camera traversals ${stats.cameraFitTraversalCount}; scene batches ${stats.sceneRootBatchCount}/${stats.batchedSceneRootCount} suppressed ${stats.sceneLoadSuppressedRenderCount} yields ${stats.sceneBuildYieldCount}; state payload ${stats.statePayloadBodyCount}/${stats.mergedBodyStateCount} reduced ${stats.reducedStateFrameCount} incremental ${stats.incrementalBodyMergeCount} poll ${stats.stateBasePollIntervalMs}/${stats.statePausedPollIntervalMs}/${stats.stateLastScheduledPollIntervalMs}ms ${stats.statePollRequestCount}/${stats.stateActivePollRequestCount}/${stats.statePausedPollRequestCount}; ui cache physics ${stats.objectPhysicsProfileCacheHitCount}/${stats.objectPhysicsProfileCacheMissCount} builder ${stats.builderPhysicsProfileCacheHitCount}/${stats.builderPhysicsProfileCacheMissCount} text ${stats.textWriteCount}/${stats.textWriteSkipCount} selector ${stats.textSelectorCacheHitCount}/${stats.textSelectorCacheMissCount} diagnostics ${stats.diagnosticsPanelRenderCount}/${stats.diagnosticsPanelSkipCount} builderPanels ${stats.builderPanelRenderCount}/${stats.builderPanelDeferredRenderCount}/${stats.builderPanelCoalescedRenderCount}; pick targets ${stats.hoverPickTargetCount}/${stats.pickProxyCount}; state apply ${stats.appliedBodyStateCount}/skip ${stats.skippedBodyStateCount}; unchanged frames ${stats.unchangedFrameCount}; released ${stats.releasedGeometryCount}g/${stats.releasedMaterialCount}m/${stats.releasedTextureCount}t`;
|
||||
return `${mode}; target ${stats.targetRenderFps} fps; actual ${stats.actualRenderFps.toFixed(1)} fps; stats refresh ${stats.statsRefreshIntervalMs}ms ${stats.statsRefreshRenderCount}/${stats.statsRefreshSkipCount}; dpr ${stats.renderPixelRatio.toFixed(2)}; buffer preserved ${stats.preserveDrawingBufferEnabled}; readback renders ${stats.readbackRenderCount}; ${shadows}; skipped ${stats.renderSkipCount}; hover ${stats.hoverPickIntervalMs}ms; frozen ${stats.frozenStaticObjectCount} prefrozen ${stats.preFrozenMeshCloneCount} spinSkip ${stats.spinningScanSkippedCount}; instanced ${stats.instancedMeshObjectCount}/${stats.instancedMeshBatchCount}/${stats.instancedMeshDrawCount} matrices ${stats.instancedMeshMatrixUpdateCount} cull ${stats.instancedMeshFrustumCulledCount} static ${stats.instancedMeshStaticMatrixCount} elidedLocal ${stats.instancedLocalObjectElisionCount}; manual roots ${stats.manualMatrixRootCount} updates ${stats.manualMatrixUpdateCount}; primitive geometries ${stats.primitiveGeometryCount}; mesh cache ${stats.meshCacheSourceCount} sources ${stats.meshCacheHitCount}/${stats.meshCacheMissCount} hit/miss retained ${stats.retainedMeshGeometryCount}g/${stats.retainedMeshMaterialCount}m; bounds cache ${stats.sceneObjectBoundsCount} fast ${stats.fastPickProxyBoundsCount} scratch ${stats.pickBoundsScratchTransformCount} source ${stats.meshSourceBoundsCount} hoverProxy ${stats.hoverProxyBoundsHitCount} cached ${stats.hoverCachedBoundsHitCount}/fallback ${stats.hoverRootBoundsFallbackCount} camera traversals ${stats.cameraFitTraversalCount}; scene batches ${stats.sceneRootBatchCount}/${stats.batchedSceneRootCount} suppressed ${stats.sceneLoadSuppressedRenderCount} yields ${stats.sceneBuildYieldCount}; state payload ${stats.statePayloadBodyCount}/${stats.mergedBodyStateCount} reduced ${stats.reducedStateFrameCount} incremental ${stats.incrementalBodyMergeCount} poll ${stats.stateBasePollIntervalMs}/${stats.statePausedPollIntervalMs}/${stats.stateLastScheduledPollIntervalMs}ms ${stats.statePollRequestCount}/${stats.stateActivePollRequestCount}/${stats.statePausedPollRequestCount} semantic ${stats.stateParsedPollFrameCount}/${stats.stateForwardedPollFrameCount}/${stats.stateSkippedDuplicatePollFrameCount}; ui cache physics ${stats.objectPhysicsProfileCacheHitCount}/${stats.objectPhysicsProfileCacheMissCount} builder ${stats.builderPhysicsProfileCacheHitCount}/${stats.builderPhysicsProfileCacheMissCount} text ${stats.textWriteCount}/${stats.textWriteSkipCount} selector ${stats.textSelectorCacheHitCount}/${stats.textSelectorCacheMissCount} diagnostics ${stats.diagnosticsPanelRenderCount}/${stats.diagnosticsPanelSkipCount} builderPanels ${stats.builderPanelRenderCount}/${stats.builderPanelDeferredRenderCount}/${stats.builderPanelCoalescedRenderCount}; pick targets ${stats.hoverPickTargetCount}/${stats.pickProxyCount}; state apply ${stats.appliedBodyStateCount}/skip ${stats.skippedBodyStateCount}; unchanged frames ${stats.unchangedFrameCount}; released ${stats.releasedGeometryCount}g/${stats.releasedMaterialCount}m/${stats.releasedTextureCount}t`;
|
||||
}
|
||||
|
||||
function renderDiagnosticsPanel(
|
||||
@ -2878,6 +2884,9 @@ function renderDiagnosticsPanel(
|
||||
data.statePollRequestCount = String(diagnostics.stats.statePollRequestCount);
|
||||
data.stateActivePollRequestCount = String(diagnostics.stats.stateActivePollRequestCount);
|
||||
data.statePausedPollRequestCount = String(diagnostics.stats.statePausedPollRequestCount);
|
||||
data.stateParsedPollFrameCount = String(diagnostics.stats.stateParsedPollFrameCount);
|
||||
data.stateForwardedPollFrameCount = String(diagnostics.stats.stateForwardedPollFrameCount);
|
||||
data.stateSkippedDuplicatePollFrameCount = String(diagnostics.stats.stateSkippedDuplicatePollFrameCount);
|
||||
data.batchedSceneRootCount = String(diagnostics.stats.batchedSceneRootCount);
|
||||
data.sceneRootBatchCount = String(diagnostics.stats.sceneRootBatchCount);
|
||||
data.objectPhysicsProfileCacheHitCount = String(diagnostics.stats.objectPhysicsProfileCacheHitCount);
|
||||
|
||||
@ -10,6 +10,9 @@ export interface StateClientStats {
|
||||
pollRequestCount: number;
|
||||
activePollRequestCount: number;
|
||||
pausedPollRequestCount: number;
|
||||
parsedPollFrameCount: number;
|
||||
forwardedPollFrameCount: number;
|
||||
skippedDuplicatePollFrameCount: number;
|
||||
lastFramePaused?: boolean;
|
||||
}
|
||||
|
||||
@ -33,6 +36,9 @@ export class StateClient {
|
||||
private pollRequestCount = 0;
|
||||
private activePollRequestCount = 0;
|
||||
private pausedPollRequestCount = 0;
|
||||
private parsedPollFrameCount = 0;
|
||||
private forwardedPollFrameCount = 0;
|
||||
private skippedDuplicatePollFrameCount = 0;
|
||||
private lastFramePaused: boolean | undefined;
|
||||
|
||||
onFrame(listener: StateListener): void {
|
||||
@ -60,6 +66,9 @@ export class StateClient {
|
||||
pollRequestCount: this.pollRequestCount,
|
||||
activePollRequestCount: this.activePollRequestCount,
|
||||
pausedPollRequestCount: this.pausedPollRequestCount,
|
||||
parsedPollFrameCount: this.parsedPollFrameCount,
|
||||
forwardedPollFrameCount: this.forwardedPollFrameCount,
|
||||
skippedDuplicatePollFrameCount: this.skippedDuplicatePollFrameCount,
|
||||
lastFramePaused: this.lastFramePaused,
|
||||
};
|
||||
}
|
||||
@ -107,6 +116,9 @@ export class StateClient {
|
||||
this.pollRequestCount = 0;
|
||||
this.activePollRequestCount = 0;
|
||||
this.pausedPollRequestCount = 0;
|
||||
this.parsedPollFrameCount = 0;
|
||||
this.forwardedPollFrameCount = 0;
|
||||
this.skippedDuplicatePollFrameCount = 0;
|
||||
this.lastFramePaused = undefined;
|
||||
if (this.socket) {
|
||||
this.socket.close();
|
||||
@ -158,6 +170,7 @@ export class StateClient {
|
||||
let hasInitialFullFrame = false;
|
||||
let activePollUrl: string | undefined;
|
||||
let lastPollUsedActiveUrl = false;
|
||||
let lastForwardedSemanticSignature: string | undefined;
|
||||
const pollUrl = () => {
|
||||
if (!source.activeBodiesAfterInitial || !hasInitialFullFrame) {
|
||||
lastPollUsedActiveUrl = false;
|
||||
@ -207,10 +220,18 @@ export class StateClient {
|
||||
return;
|
||||
}
|
||||
const frame = (await response.json()) as PreviewFrame;
|
||||
this.parsedPollFrameCount += 1;
|
||||
this.lastFramePaused = frame.paused;
|
||||
if (frame.paused === true) {
|
||||
this.pausedPollRequestCount += 1;
|
||||
}
|
||||
const semanticSignature = semanticFrameSignature(frame);
|
||||
if (semanticSignature === lastForwardedSemanticSignature) {
|
||||
this.skippedDuplicatePollFrameCount += 1;
|
||||
return;
|
||||
}
|
||||
lastForwardedSemanticSignature = semanticSignature;
|
||||
this.forwardedPollFrameCount += 1;
|
||||
if (frame.bodies && !hasInitialFullFrame) {
|
||||
hasInitialFullFrame = true;
|
||||
}
|
||||
@ -260,3 +281,20 @@ export class StateClient {
|
||||
this.statusListener?.(message);
|
||||
}
|
||||
}
|
||||
|
||||
function semanticFrameSignature(frame: PreviewFrame): string {
|
||||
return JSON.stringify({
|
||||
step: frame.step,
|
||||
time: frame.time,
|
||||
paused: frame.paused,
|
||||
running: frame.running,
|
||||
command: frame.command,
|
||||
bodyPayload: frame.bodyPayload,
|
||||
bodies: frame.bodies,
|
||||
joints: frame.joints,
|
||||
actuators: frame.actuators,
|
||||
dof_pos: frame.dof_pos,
|
||||
dof_vel: frame.dof_vel,
|
||||
actuator_ctrls: frame.actuator_ctrls,
|
||||
});
|
||||
}
|
||||
|
||||
@ -184,6 +184,9 @@ export interface PreviewFrame {
|
||||
joints?: Record<string, { pos: number; vel?: number; range?: [number, number]; index?: number }>;
|
||||
actuators?: Record<string, { ctrl: number; range?: [number, number]; index?: number; targetName?: string }>;
|
||||
command?: [number, number, number];
|
||||
dof_pos?: number[];
|
||||
dof_vel?: number[];
|
||||
actuator_ctrls?: number[];
|
||||
bodies?: Record<string, BodyState>;
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user