-
Notifications
You must be signed in to change notification settings - Fork 17
feat: scene content stats — debug widget, creator Scene Stats panel & MCP tools #9457
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 36 commits
Commits
Show all changes
44 commits
Select commit
Hold shift + click to select a range
6255d94
feat: add scene content stats to the Current Scene debug widget
dalkia 5d6dd64
Merge branch 'dev' into feat/current-scene-content-stats-debug
dalkia 275428b
Merge branch 'dev' into feat/current-scene-content-stats-debug
dalkia 4f30841
feat: remove content size stat from Current Scene widget
dalkia 22e8c4b
feat: align content stat caps with documented scene limitations
dalkia 61d307f
feat: add scene metrics panel to the scene debug menu
dalkia 124d412
feat: expose scene content stats through an MCP tool
dalkia b4483cc
feat: add per-model content breakdown MCP tool (demo)
dalkia 92a8c1f
feat: add materials and draw-call estimate to the content breakdown
dalkia de98d33
feat: split content stats into their own Scene content debug widget
dalkia fdb47df
feat: per-POV visibility columns in the content breakdown
dalkia 1746336
feat: add get_performance_stats MCP tool
dalkia 448efed
fix: qualify UnityEngine.Time in GetPerformanceStatsTool
dalkia 2cd854a
Merge remote-tracking branch 'origin/dev' into feat/current-scene-con…
dalkia 8190dcb
feat: redesign Scene Stats creator panel
dalkia 051f251
feat: use a 2x2 grid glyph for the Scene Stats sidebar button
dalkia c711381
feat: use info.png as the Scene Stats sidebar button icon
dalkia c896ac6
feat: count shader variants in scene content stats
dalkia 9f53073
feat: use dedicated stats-chart icon for the Scene Stats sidebar button
dalkia 19e4831
Merge branch 'dev' into feat/current-scene-content-stats-debug
dalkia e230057
feat: restyle Scene Stats panel with banded rows and warning percentages
dalkia f876e62
feat: remove the Scene Stats panel close button
dalkia a74caf0
feat: make the Scene Stats panel background near-opaque for readability
dalkia 2232d38
chore: soften Scene Stats panel background to 90% opacity
dalkia da3e2f9
chore: rename External content widget row to Videos
dalkia 5ce04ae
feat: count video/media players instead of external content + NFTs
dalkia 5810e65
chore: label the media-player row External Videos/Audios
dalkia 59b4458
chore: drop the materials cap, show it as an informative count
dalkia f710d92
Merge branch 'dev' into feat/current-scene-content-stats-debug
dalkia d5b4aee
feat: per-metric hover tooltips in the Scene Stats panel
dalkia 534a6c1
chore: group capped stat rows above the uncapped ones
dalkia cf96039
fix: unsubscribe metrics button click handler in OnDisable
dalkia cb040fe
feat: use InfoIcn sprite for scene stats info marker
dalkia 637014f
chore: move SceneStats icon into the UI sprite atlas
dalkia b127293
chore: assign sprite id to icon-scene-stats on reimport
dalkia 13dfeb1
refactor: address MCP content-stats tool review feedback
dalkia bdda35d
fix: divide scene-tick average by contributing samples only
dalkia ae29b7f
fix: align MCP scene-tick stats with the render sampling window
dalkia 9272863
fix: use the client-wide hiccup definition in get_performance_stats
dalkia c6ae84e
fix: measure content-stats poll timeout against the wall clock
dalkia f6fe7a7
fix: refcount MCP content-stats demand so overlapping calls don't can…
dalkia 4dbe4ce
test: cover MCP performance and content-stats tools via injectable waits
dalkia 5f42d52
chore: resolve low-risk lint findings in branch-touched files
dalkia c6e1800
fix: declare an OutputSchema for get_scene_content_breakdown
dalkia File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
85 changes: 85 additions & 0 deletions
85
Explorer/Assets/DCL/McpServer/Tests/GetSceneContentBreakdownToolShould.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,85 @@ | ||
| using DCL.McpServer.Core; | ||
| using DCL.McpServer.Tools; | ||
| using DCL.Profiling; | ||
| using DCL.Utilities; | ||
| using ECS.SceneLifeCycle; | ||
| using Newtonsoft.Json.Linq; | ||
| using NSubstitute; | ||
| using NUnit.Framework; | ||
| using SceneRunner.Scene; | ||
| using System.Collections.Generic; | ||
| using System.Threading; | ||
| using UnityEngine; | ||
|
|
||
| namespace DCL.McpServer.Tests | ||
| { | ||
| public class GetSceneContentBreakdownToolShould | ||
| { | ||
| private IScenesCache scenesCache = null!; | ||
| private ISceneFacade scene = null!; | ||
| private SceneRuntimeMetrics runtimeMetrics = null!; | ||
|
|
||
| [SetUp] | ||
| public void Setup() | ||
| { | ||
| runtimeMetrics = new SceneRuntimeMetrics(); | ||
|
|
||
| ISceneData sceneData = Substitute.For<ISceneData>(); | ||
| sceneData.Parcels.Returns(new List<Vector2Int> { new (0, 0), new (0, 1) }); | ||
|
|
||
| scene = Substitute.For<ISceneFacade>(); | ||
| scene.SceneData.Returns(sceneData); | ||
| scene.RuntimeMetrics.Returns(runtimeMetrics); | ||
|
|
||
| scenesCache = Substitute.For<IScenesCache>(); | ||
| scenesCache.CurrentScene.Returns(new ReactiveProperty<ISceneFacade?>(scene)); | ||
| } | ||
|
|
||
| [Test] | ||
| public void ErrorWhenNoSceneIsLoaded() | ||
| { | ||
| // Arrange | ||
| scenesCache.CurrentScene.Returns(new ReactiveProperty<ISceneFacade?>(null)); | ||
| var tool = new GetSceneContentBreakdownTool(scenesCache, collectionTimeoutMs: 0); | ||
|
|
||
| // Act | ||
| McpToolResult result = Execute(tool); | ||
|
|
||
| // Assert | ||
| Assert.That(result.Payload["isError"]!.Value<bool>(), Is.True); | ||
| } | ||
|
|
||
| [Test] | ||
| public void ClearBothDemandFlagsWhenNoPassArrives() | ||
| { | ||
| // Arrange — the zero timeout skips the wait, so no fresh pass lands and the tool errors; | ||
| // the cleanup finally must still reset both the breakdown request and the MCP demand flag. | ||
| var tool = new GetSceneContentBreakdownTool(scenesCache, collectionTimeoutMs: 0); | ||
|
|
||
| // Act | ||
| McpToolResult result = Execute(tool); | ||
|
|
||
| // Assert | ||
| Assert.That(result.Payload["isError"]!.Value<bool>(), Is.True); | ||
| Assert.That(runtimeMetrics.ContentStats.BreakdownRequested, Is.False); | ||
| Assert.That(runtimeMetrics.ContentStats.RequestedByMcp, Is.False); | ||
| } | ||
|
|
||
| [Test] | ||
| public void DeclareLimitAndSortByInTheInputSchema() | ||
| { | ||
| // Arrange | ||
| var tool = new GetSceneContentBreakdownTool(scenesCache); | ||
|
|
||
| // Act | ||
| var properties = (JObject)tool.InputSchema["properties"]!; | ||
|
|
||
| // Assert | ||
| Assert.That(properties["limit"], Is.Not.Null); | ||
| Assert.That(properties["sortBy"], Is.Not.Null); | ||
| } | ||
|
|
||
| private static McpToolResult Execute(GetSceneContentBreakdownTool tool) => | ||
| tool.ExecuteAsync(new JObject(), CancellationToken.None).GetAwaiter().GetResult(); | ||
| } | ||
| } |
11 changes: 11 additions & 0 deletions
11
Explorer/Assets/DCL/McpServer/Tests/GetSceneContentBreakdownToolShould.cs.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
117 changes: 117 additions & 0 deletions
117
Explorer/Assets/DCL/McpServer/Tests/GetSceneContentStatsToolShould.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,117 @@ | ||
| using DCL.McpServer.Core; | ||
| using DCL.McpServer.Tools; | ||
| using DCL.Profiling; | ||
| using DCL.Utilities; | ||
| using ECS.SceneLifeCycle; | ||
| using Newtonsoft.Json.Linq; | ||
| using NSubstitute; | ||
| using NUnit.Framework; | ||
| using SceneRunner.Scene; | ||
| using System.Collections.Generic; | ||
| using System.Threading; | ||
| using UnityEngine; | ||
|
|
||
| namespace DCL.McpServer.Tests | ||
| { | ||
| public class GetSceneContentStatsToolShould | ||
| { | ||
| private IScenesCache scenesCache = null!; | ||
| private ISceneFacade scene = null!; | ||
| private SceneRuntimeMetrics runtimeMetrics = null!; | ||
|
|
||
| [SetUp] | ||
| public void Setup() | ||
| { | ||
| runtimeMetrics = new SceneRuntimeMetrics(); | ||
|
|
||
| ISceneData sceneData = Substitute.For<ISceneData>(); | ||
| sceneData.Parcels.Returns(new List<Vector2Int> { new (0, 0), new (0, 1) }); | ||
|
|
||
| scene = Substitute.For<ISceneFacade>(); | ||
| scene.SceneData.Returns(sceneData); | ||
| scene.RuntimeMetrics.Returns(runtimeMetrics); | ||
|
|
||
| scenesCache = Substitute.For<IScenesCache>(); | ||
| scenesCache.CurrentScene.Returns(new ReactiveProperty<ISceneFacade?>(scene)); | ||
| } | ||
|
|
||
| [Test] | ||
| public void ErrorWhenNoSceneIsLoaded() | ||
| { | ||
| // Arrange | ||
| scenesCache.CurrentScene.Returns(new ReactiveProperty<ISceneFacade?>(null)); | ||
| var tool = new GetSceneContentStatsTool(scenesCache, collectionTimeoutMs: 0); | ||
|
|
||
| // Act | ||
| McpToolResult result = Execute(tool); | ||
|
|
||
| // Assert | ||
| Assert.That(result.Payload["isError"]!.Value<bool>(), Is.True); | ||
| } | ||
|
|
||
| [Test] | ||
| public void ErrorWhenTheSceneNeverProducedStats() | ||
| { | ||
| // Arrange — HasData stays false and the zero timeout skips waiting for a pass | ||
| var tool = new GetSceneContentStatsTool(scenesCache, collectionTimeoutMs: 0); | ||
|
|
||
| // Act | ||
| McpToolResult result = Execute(tool); | ||
|
|
||
| // Assert | ||
| Assert.That(result.Payload["isError"]!.Value<bool>(), Is.True); | ||
| Assert.That(runtimeMetrics.ContentStats.RequestedByMcp, Is.False); | ||
| } | ||
|
|
||
| [Test] | ||
| public void ReportStatsWithCapsMatchingTheOutputSchema() | ||
| { | ||
| // Arrange | ||
| SceneContentStats stats = runtimeMetrics.ContentStats; | ||
| stats.HasData = true; | ||
| stats.Entities = 10; | ||
| stats.Triangles = 5200; | ||
| stats.Bodies = 12; | ||
| stats.Geometries = 7; | ||
| stats.Materials = 5; | ||
| stats.Textures = 3; | ||
| stats.ShaderVariants = 2; | ||
| stats.Colliders = 2; | ||
| stats.Videos = 1; | ||
|
|
||
| var tool = new GetSceneContentStatsTool(scenesCache, collectionTimeoutMs: 0); | ||
|
|
||
| // Act | ||
| var structured = (JObject)Execute(tool).Payload["structuredContent"]!; | ||
|
|
||
| // Assert | ||
| McpSchemaAssert.KeysMatch(tool.OutputSchema, structured); | ||
| Assert.That(structured["parcelCount"]!.Value<int>(), Is.EqualTo(2)); | ||
| Assert.That(structured["fresh"]!.Value<bool>(), Is.False); | ||
| Assert.That(structured["entities"]!.Value<int>(), Is.EqualTo(10)); | ||
| Assert.That(structured["entitiesCap"]!.Value<int>(), Is.EqualTo(400)); | ||
| Assert.That(structured["triangles"]!.Value<long>(), Is.EqualTo(5200)); | ||
| Assert.That(structured["trianglesCap"]!.Value<long>(), Is.EqualTo(20000)); | ||
| Assert.That(structured["geometries"]!.Value<int>(), Is.EqualTo(7)); | ||
| Assert.That(structured["shaderVariants"]!.Value<int>(), Is.EqualTo(2)); | ||
| Assert.That(structured["videos"]!.Value<int>(), Is.EqualTo(1)); | ||
| } | ||
|
|
||
| [Test] | ||
| public void ClearTheDemandFlagAfterReporting() | ||
| { | ||
| // Arrange | ||
| runtimeMetrics.ContentStats.HasData = true; | ||
| var tool = new GetSceneContentStatsTool(scenesCache, collectionTimeoutMs: 0); | ||
|
|
||
| // Act | ||
| Execute(tool); | ||
|
|
||
| // Assert | ||
| Assert.That(runtimeMetrics.ContentStats.RequestedByMcp, Is.False); | ||
| } | ||
|
|
||
| private static McpToolResult Execute(GetSceneContentStatsTool tool) => | ||
| tool.ExecuteAsync(new JObject(), CancellationToken.None).GetAwaiter().GetResult(); | ||
| } | ||
| } | ||
11 changes: 11 additions & 0 deletions
11
Explorer/Assets/DCL/McpServer/Tests/GetSceneContentStatsToolShould.cs.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.