Optimize large scene load responsiveness
This commit is contained in:
parent
51cea16cab
commit
06d0ae0a4d
@ -382,11 +382,11 @@ Scene evidence:
|
||||
and `notModified=5`, so `5` of `7` state polls avoided retransmitting JSON
|
||||
bodies. The adaptive polling check recorded `hash=5/3/0` and
|
||||
`notModified=3` while paused.
|
||||
- Drag coalescing: the paused builder drag check recorded `drag=28/16/27`,
|
||||
meaning `28` pointer moves were reduced to `16` scene pose applications with
|
||||
- Drag coalescing: the paused builder drag check recorded `drag=28/15/27`,
|
||||
meaning `28` pointer moves were reduced to `15` scene pose applications with
|
||||
`27` coalesced/throttled move events.
|
||||
- Control latency: resume backend/DOM sync measured `241ms/56ms`; pause
|
||||
backend/DOM sync measured `59ms/60ms`.
|
||||
- Control latency: resume backend/DOM sync measured `54ms/43ms`; pause
|
||||
backend/DOM sync measured `233ms/56ms`.
|
||||
- Mobile preview: `636 objects / 635 bindings / 30 pixels`
|
||||
- Mobile acceptance: `11 通过 / 0 警告 / 0 失败,共 11 项`
|
||||
- Mobile acceptance telemetry: `0 ms / 11-0-0`
|
||||
@ -535,13 +535,13 @@ Scene evidence:
|
||||
Bundle evidence:
|
||||
|
||||
- JavaScript chunks: `4`
|
||||
- App entry chunk: `215.57 kB raw / 55.26 kB gzip`
|
||||
- App entry chunk: `218.84 kB raw / 56.04 kB gzip`
|
||||
- Largest JavaScript gzip chunk: `140.96 KiB / 170.00 KiB`
|
||||
- Total JavaScript gzip: `218.79 KiB / 230.00 KiB`
|
||||
- Total JavaScript gzip: `219.55 KiB / 230.00 KiB`
|
||||
- Large-scene performance mode: `large-scene`, target `45 fps`,
|
||||
actual idle render rate `0.7 fps`, DPR cap observed at `1.00` in release
|
||||
gate, `preserveDrawingBuffer=false`, `1` explicit readback render, shadows
|
||||
`off`, hover picking throttled to `32ms`, `1096` empty frames
|
||||
`off`, hover picking throttled to `32ms`, `547` 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
|
||||
@ -554,16 +554,16 @@ Bundle evidence:
|
||||
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, `826` no-op loading frames
|
||||
batch cap, `1100` no-op loading frames
|
||||
suppressed during the primary load, `26` browser event-loop yields during
|
||||
scene construction, active state payload `34/602` with `1` reduced frame and
|
||||
`2` incremental body-map merges, semantic poll forwarding `2/2/5`
|
||||
scene construction, active state payload `34/602` with `2` reduced frames and
|
||||
`3` incremental body-map merges, semantic poll forwarding `2/2/5`
|
||||
parsed/forwarded/duplicate-skip,
|
||||
state-hash polling `7/5/0` hash/hash-skip/semantic-skip with `5` real
|
||||
`304 Not Modified` responses, UI physics-profile cache `25/3` hit/miss, UI
|
||||
builder-profile cache `28/1` hit/miss, UI text write gating `105/445`
|
||||
write/skip, text selector cache `504/46` hit/miss, scratch bounds transforms
|
||||
`695`, diagnostics panel throttling `20/3` render/skip, `88/636`
|
||||
`304 Not Modified` responses, UI physics-profile cache `28/3` hit/miss, UI
|
||||
builder-profile cache `31/1` hit/miss, UI text write gating `114/489`
|
||||
write/skip, text selector cache `557/46` hit/miss, scratch bounds transforms
|
||||
`695`, diagnostics panel throttling `22/4` 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 68 updates
|
||||
67` with `state apply 0/skip 67`.
|
||||
@ -786,19 +786,27 @@ Current performance boundaries:
|
||||
first load, Scene Builder compose, share restore, and config import restore
|
||||
still include browser asset creation and scene graph setup time.
|
||||
- The real backend control path is not the observed bottleneck in the current
|
||||
gate: resume visible UI confirmation is `53ms`, pause visible UI confirmation
|
||||
is `51ms`, and repeated compose cache with reset is `55ms`.
|
||||
gate: resume visible UI confirmation is `43ms`, pause visible UI confirmation
|
||||
is `56ms`, and repeated compose cache with reset is `55ms`.
|
||||
- State connection now starts in parallel with browser scene construction. If a
|
||||
real backend frame arrives before all visual objects are built, the frontend
|
||||
reapplies the latest backend frame after `loadManifest()` completes instead
|
||||
of synthesizing any pose locally.
|
||||
- The remaining high-impact optimization area is asset-level rendering and
|
||||
static-scene packaging: the current virtual-root instancing path reduces
|
||||
per-item scene construction (`virtualRoots=568`, `manualRoots=68`), but
|
||||
share/config restore still spends `10-21s` in full browser page load, compose
|
||||
restore, asset setup, and screenshots. The next tier is material reduction,
|
||||
LODs, static asset manifests, and eventually moving repeated fixed inventory
|
||||
into a backend static-state channel.
|
||||
the latest gate still spends `9-10s` end to end in full browser page load,
|
||||
compose restore, asset setup, and screenshots. Internal builder telemetry is
|
||||
lower: share restore reports `telemetry=2970ms`, `compose=321ms`,
|
||||
`preview=2641ms`, `state=7ms`, `stats=0ms`; config import reports
|
||||
`telemetry=3612ms`, `compose=114ms`, `preview=3491ms`, `state=3ms`,
|
||||
`stats=0ms`. The next tier is material reduction, LODs, static asset
|
||||
manifests, and eventually moving repeated fixed inventory into a backend
|
||||
static-state channel.
|
||||
- Runtime stats no longer perform repeated or load-blocking WebGL pixel
|
||||
readback. Pixel proof is scheduled after manifest load, sampled once, and
|
||||
cached; ordinary stats refresh reads the cached value. The latest gate shows
|
||||
the load-path stats render at `1ms` while pixel proof runs in the separate
|
||||
the load-path stats render at `0ms` while pixel proof runs in the separate
|
||||
`pixel` telemetry stage.
|
||||
|
||||
## Handoff Criteria
|
||||
|
||||
@ -1875,7 +1875,7 @@ async function verifyBrowser() {
|
||||
"browser-large-scene-performance-mode",
|
||||
renderPerformance.largeSceneMode === true
|
||||
&& renderPerformance.targetRenderFps === 45
|
||||
&& (renderPerformance.renderPixelRatio ?? Number.POSITIVE_INFINITY) <= 1.25
|
||||
&& (renderPerformance.renderPixelRatio ?? Number.POSITIVE_INFINITY) <= 1
|
||||
&& renderPerformance.preserveDrawingBufferEnabled === false
|
||||
&& (renderPerformance.readbackRenderCount ?? 0) > 0
|
||||
&& renderPerformance.shadowsEnabled === false
|
||||
|
||||
30
src/main.ts
30
src/main.ts
@ -1566,6 +1566,10 @@ function applyRuntimeFrame(frame: PreviewFrame, renderPanels = true): PreviewFra
|
||||
return merged;
|
||||
}
|
||||
|
||||
function latestRuntimeFrame(): PreviewFrame | undefined {
|
||||
return latestFrame;
|
||||
}
|
||||
|
||||
stateClient.onFrame((frame) => {
|
||||
applyRuntimeFrame(frame, false);
|
||||
if (pendingCameraFit && Object.keys(frame.bodies ?? {}).length > 0) {
|
||||
@ -1703,14 +1707,23 @@ async function loadResolvedManifest(manifest: SceneManifest, telemetry?: Builder
|
||||
renderJointControls();
|
||||
renderActuatorControls();
|
||||
renderInputAvailability();
|
||||
const stateConnectStartedAt = performance.now();
|
||||
let stateConnectMs = 0;
|
||||
let stateConnectError: unknown;
|
||||
const stateConnect = stateClient.connect(manifest.state)
|
||||
.then(() => {
|
||||
stateConnectMs = performance.now() - stateConnectStartedAt;
|
||||
})
|
||||
.catch((error: unknown) => {
|
||||
stateConnectMs = performance.now() - stateConnectStartedAt;
|
||||
stateConnectError = error;
|
||||
});
|
||||
const previewLoadStartedAt = performance.now();
|
||||
await previewer.loadManifest(manifest);
|
||||
if (telemetry) {
|
||||
telemetry.previewLoadMs = performance.now() - previewLoadStartedAt;
|
||||
publishBuilderSceneTelemetry(telemetry);
|
||||
}
|
||||
const stateConnectStartedAt = performance.now();
|
||||
const stateConnect = stateClient.connect(manifest.state);
|
||||
const inferredEditableObjectIds = inferDefaultEditableObjectIds(manifest, { requireBody: Boolean(controlUrl) });
|
||||
previewer.setDragOptions({
|
||||
editableObjectIds: inferredEditableObjectIds,
|
||||
@ -1725,8 +1738,19 @@ async function loadResolvedManifest(manifest: SceneManifest, telemetry?: Builder
|
||||
addActivity("activity.manifestLoaded", { count: manifest.objects.length }, "ok");
|
||||
pendingCameraFit = true;
|
||||
await stateConnect;
|
||||
if (stateConnectError) {
|
||||
throw stateConnectError;
|
||||
}
|
||||
const stateFrame = latestRuntimeFrame();
|
||||
if (stateFrame) {
|
||||
applyRuntimeFrame(stateFrame, false);
|
||||
if (Object.keys(stateFrame.bodies ?? {}).length > 0) {
|
||||
pendingCameraFit = false;
|
||||
window.requestAnimationFrame(() => previewer.refitCamera());
|
||||
}
|
||||
}
|
||||
if (telemetry) {
|
||||
telemetry.stateConnectMs = performance.now() - stateConnectStartedAt;
|
||||
telemetry.stateConnectMs = stateConnectMs;
|
||||
}
|
||||
const statsStartedAt = performance.now();
|
||||
renderStats({ forceDiagnostics: true });
|
||||
|
||||
@ -711,7 +711,7 @@ export class UniversalPreviewer {
|
||||
this.largeSceneMode = manifest.objects.length > 300;
|
||||
this.targetRenderIntervalMs = this.largeSceneMode ? 1000 / 45 : 0;
|
||||
this.hoverPickIntervalMs = this.largeSceneMode ? 32 : 0;
|
||||
const pixelRatioCap = this.largeSceneMode ? 1.25 : 2;
|
||||
const pixelRatioCap = this.largeSceneMode ? 1 : 2;
|
||||
this.renderer.setPixelRatio(Math.min(window.devicePixelRatio || 1, pixelRatioCap));
|
||||
this.renderer.shadowMap.enabled = !this.largeSceneMode;
|
||||
this.resize();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user