Skip to content

feat: add scene content stats to the Current Scene debug widget - #9457

Draft
dalkia wants to merge 3 commits into
devfrom
feat/current-scene-content-stats-debug
Draft

feat: add scene content stats to the Current Scene debug widget#9457
dalkia wants to merge 3 commits into
devfrom
feat/current-scene-content-stats-debug

Conversation

@dalkia

@dalkia dalkia commented Jul 21, 2026

Copy link
Copy Markdown
Collaborator

Pull Request Description

What does this PR change?

Adds per-scene content statistics to the "Current scene" debug widget so creators and devs can see, at a glance, how close the scene they are standing in is to its limits. Nine new rows appear at the top of the widget, each formatted current / maxcap (pct%) and colored green (< 80%), yellow (80–99%) or red (≥ 100%):

  • Entities — live CRDT entities (EntitiesMap.Count)
  • Triangles — summed from primitive mesh renderers + GLTF container renderers
  • Meshes (bodies) — renderer count (primitive + GLTF)
  • Geometries — unique Mesh instances
  • Materials / Textures — unique instances, deduped across SDK materials and GLTF-embedded materials (textures probed from common shader properties)
  • Colliders — primitive colliders + GLTF invisible/decoded-visible colliders
  • Content size — runtime memory of the scene's unique meshes + textures (Profiler.GetRuntimeMemorySizeLong); there is no per-scene downloaded-bytes accumulator, so deployed size is not knowable at runtime
  • External content — media streams not served from the content server + NFT shapes

Caps are hardcoded from the documented Decentraland scene limitations, scaled by parcel count n: triangles n×10000, entities n×200, bodies n×300, materials log2(n+1)×20, textures log2(n+1)×10, geometries log2(n+1)×200, content size 15MB×n. Colliders (n×300) and external content (10) have no documented limit, so they use project-chosen constants. All caps live in one constants block in DebugViewCurrentSceneSystem.Formatting.cs.

Architecture: a new scene-world system (SceneContentStatsSystem, SyncedPresentationSystemGroup) counts every 30 frames and writes into a new SceneContentStats payload on SceneRuntimeMetrics (now exposed to scene-world systems via ECSWorldInstanceSharedDependencies). The global DebugViewCurrentSceneSystem sets a CollectionRequested demand flag only while the widget is expanded on the current scene — with the debug panel closed or disabled, the scene system does a single bool check per frame and nothing else. Counting is allocation-free (reused HashSets / scratch list, non-alloc GetSharedMaterials).

Test Instructions

Steps (standard run):

metaforge explorer run 9457

Expected result:
The "Current scene" debug widget shows the nine new stat rows with colored current / max (pct%) values for the scene you are standing in.

Steps (fresh account):

metaforge account create --clear
metaforge explorer run 9457

Expected result:
Same as above after finishing onboarding.

Automation (if applicable):
N/A

Prerequisites

  • Run with the debug panel available (editor play mode or a build with --debug)

Test Steps

  1. Enter any world/scene and open the debug panel
  2. Expand the "Current scene" widget
  3. Rows show "—" for up to ~1 second, then populate with current / max (pct%) values colored green/yellow/red
  4. Walk into a neighboring scene — values reset and repopulate for the new scene, and caps change with the scene's parcel count
  5. Collapse the widget or close the panel — values freeze (collection stops); reopen and they refresh within a second
  6. Visit a heavy scene (e.g. Genesis Plaza) and verify triangle/material counts move into yellow/red

Additional Testing Notes

  • "Content size" measures runtime memory of unique meshes + textures, not the deployed bundle size — the 15MB/parcel cap is indicative
  • GLTF stats only count containers in Finished state, so values grow while a scene streams in
  • Empty/loading scenes show "—" until the first collection pass
  • No SDK behavior changes — this is debug-panel-only

Quality Checklist

  • Changes have been tested locally
  • Documentation has been updated (if required)
  • Performance impact has been considered
  • For SDK features: Test scene is included

Code Review Reference

Please review our Branch & PR Standards before submitting. It explains the automated review flow, QA/DEV approval requirements, and what each label does — especially useful for first-time contributors.

🤖 Generated with Claude Code

Adds per-scene content statistics (entities, triangles, meshes/bodies,
geometries, materials, textures, colliders, runtime content size and
external content) to the "Current scene" debug widget, shown as
current / maxcap (pct%) colored green/yellow/red against hardcoded
caps derived from the scene's parcel count.

Counting runs in a new scene-world system (SceneContentStatsSystem)
gated by a demand flag the widget sets only while expanded, so it
costs a single bool check per frame when the debug panel is closed
or disabled.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

badge

New build in progress, come back later!

@dalkia dalkia self-assigned this Jul 21, 2026
@dalkia dalkia added the force-build Used to trigger a build on draft PR label Jul 23, 2026
@github-actions

github-actions Bot commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

badge

Lint ratchet not evaluated for this run.

@github-actions

Copy link
Copy Markdown
Contributor

Tests: 23922 passed, 0 failed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

force-build Used to trigger a build on draft PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant