Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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 Jul 21, 2026
5d6dd64
Merge branch 'dev' into feat/current-scene-content-stats-debug
dalkia Jul 24, 2026
275428b
Merge branch 'dev' into feat/current-scene-content-stats-debug
dalkia Aug 3, 2026
4f30841
feat: remove content size stat from Current Scene widget
dalkia Aug 3, 2026
22e8c4b
feat: align content stat caps with documented scene limitations
dalkia Aug 3, 2026
61d307f
feat: add scene metrics panel to the scene debug menu
dalkia Aug 3, 2026
124d412
feat: expose scene content stats through an MCP tool
dalkia Aug 3, 2026
b4483cc
feat: add per-model content breakdown MCP tool (demo)
dalkia Aug 3, 2026
92a8c1f
feat: add materials and draw-call estimate to the content breakdown
dalkia Aug 3, 2026
de98d33
feat: split content stats into their own Scene content debug widget
dalkia Aug 4, 2026
fdb47df
feat: per-POV visibility columns in the content breakdown
dalkia Aug 4, 2026
1746336
feat: add get_performance_stats MCP tool
dalkia Aug 4, 2026
448efed
fix: qualify UnityEngine.Time in GetPerformanceStatsTool
dalkia Aug 4, 2026
2cd854a
Merge remote-tracking branch 'origin/dev' into feat/current-scene-con…
dalkia Aug 4, 2026
8190dcb
feat: redesign Scene Stats creator panel
dalkia Aug 4, 2026
051f251
feat: use a 2x2 grid glyph for the Scene Stats sidebar button
dalkia Aug 4, 2026
c711381
feat: use info.png as the Scene Stats sidebar button icon
dalkia Aug 4, 2026
c896ac6
feat: count shader variants in scene content stats
dalkia Aug 4, 2026
9f53073
feat: use dedicated stats-chart icon for the Scene Stats sidebar button
dalkia Aug 4, 2026
19e4831
Merge branch 'dev' into feat/current-scene-content-stats-debug
dalkia Aug 5, 2026
e230057
feat: restyle Scene Stats panel with banded rows and warning percentages
dalkia Aug 5, 2026
f876e62
feat: remove the Scene Stats panel close button
dalkia Aug 5, 2026
a74caf0
feat: make the Scene Stats panel background near-opaque for readability
dalkia Aug 5, 2026
2232d38
chore: soften Scene Stats panel background to 90% opacity
dalkia Aug 5, 2026
da3e2f9
chore: rename External content widget row to Videos
dalkia Aug 5, 2026
5ce04ae
feat: count video/media players instead of external content + NFTs
dalkia Aug 5, 2026
5810e65
chore: label the media-player row External Videos/Audios
dalkia Aug 5, 2026
59b4458
chore: drop the materials cap, show it as an informative count
dalkia Aug 5, 2026
f710d92
Merge branch 'dev' into feat/current-scene-content-stats-debug
dalkia Aug 5, 2026
d5b4aee
feat: per-metric hover tooltips in the Scene Stats panel
dalkia Aug 5, 2026
534a6c1
chore: group capped stat rows above the uncapped ones
dalkia Aug 5, 2026
cf96039
fix: unsubscribe metrics button click handler in OnDisable
dalkia Aug 5, 2026
cb040fe
feat: use InfoIcn sprite for scene stats info marker
dalkia Aug 5, 2026
637014f
chore: move SceneStats icon into the UI sprite atlas
dalkia Aug 5, 2026
b127293
chore: assign sprite id to icon-scene-stats on reimport
dalkia Aug 5, 2026
13dfeb1
refactor: address MCP content-stats tool review feedback
dalkia Aug 5, 2026
bdda35d
fix: divide scene-tick average by contributing samples only
dalkia Aug 7, 2026
ae29b7f
fix: align MCP scene-tick stats with the render sampling window
dalkia Aug 7, 2026
9272863
fix: use the client-wide hiccup definition in get_performance_stats
dalkia Aug 7, 2026
c6ae84e
fix: measure content-stats poll timeout against the wall clock
dalkia Aug 7, 2026
f6fe7a7
fix: refcount MCP content-stats demand so overlapping calls don't can…
dalkia Aug 7, 2026
4dbe4ce
test: cover MCP performance and content-stats tools via injectable waits
dalkia Aug 7, 2026
5f42d52
chore: resolve low-risk lint findings in branch-touched files
dalkia Aug 7, 2026
c6e1800
fix: declare an OutputSchema for get_scene_content_breakdown
dalkia Aug 7, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1005,7 +1005,8 @@ await MapRendererContainer
bootstrapContainer.DiagnosticsContainer,
staticContainer.InputBlock,
assetsProvisioner,
debugBuilder
debugBuilder,
staticContainer.ScenesCache
));

if (!localSceneDevelopment)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,7 @@ public UniTask InitializeAsync(StaticSettings settings, CancellationToken ct)
new AssetsCollidersPlugin(sharedDependencies),
new AvatarShapePlugin(globalWorld, componentsContainer.ComponentPoolsRegistry, launchMode, useRemoteAssetBundles),
new PrimitivesRenderingPlugin(sharedDependencies),
new SceneContentStatsPlugin(),
new VisibilityPlugin(),
new AudioSourcesPlugin(sharedDependencies, container.WebRequestsContainer.WebRequestController, container.CacheCleaner, container.assetsProvisioner),
new AudioAnalysisPlugin(sharedDependencies),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ public SceneInstanceDependencies(
/* Pass dependencies here if they are needed by the systems */
ecsWorldSharedDependencies = new ECSWorldInstanceSharedDependencies(sceneData, partitionProvider, ecsToCRDTWriter, entitiesMap,
ExceptionsHandler, EntityCollidersCache, SceneStateProvider, entityEventsBuilder, ecsMultiThreadSync,
systemGroupThrottler, systemsUpdateGate);
systemGroupThrottler, systemsUpdateGate, RuntimeMetrics);

ECSWorldFacade = ecsWorldFactory.CreateWorld(new ECSWorldFactoryArgs(ecsWorldSharedDependencies, systemGroupThrottler, sceneData));
CRDTWorldSynchronizer = new CRDTWorldSynchronizer(ECSWorldFacade.EcsWorld, sdkComponentsRegistry, entityFactory, entitiesMap);
Expand Down
15 changes: 15 additions & 0 deletions Explorer/Assets/DCL/McpServer/Core/McpJsonSchema.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,21 @@ public McpJsonSchema Object(string name, McpJsonSchema schema, string? descripti
return AddField(name, field, isRequired);
}

/// <summary>Adds an array field whose items are objects described by their own <paramref name="itemSchema" /> builder.</summary>
public McpJsonSchema ObjectArray(string name, McpJsonSchema itemSchema, string? description = null, bool isRequired = false)
{
var field = new JObject
{
["type"] = "array",
["items"] = itemSchema.Build(),
};

if (description != null)
field["description"] = description;

return AddField(name, field, isRequired);
}

/// <summary>Adds an array field whose items are all integers.</summary>
public McpJsonSchema IntegerArray(string name, string? description = null, bool isRequired = false)
{
Expand Down
3 changes: 3 additions & 0 deletions Explorer/Assets/DCL/McpServer/Systems/McpServerPlugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,9 @@ public void InjectToWorld(ref ArchSystemsWorldBuilder<Arch.Core.World> builder,
.Add(screenshotTool)
.Add(new GetPlayerStateTool(globalWorld, arguments.PlayerEntity, exposedCameraData, currentSceneInfo))
.Add(new GetSceneStateTool(scenesCache, currentSceneInfo, loadingStatus, localSceneDevelopment))
.Add(new GetSceneContentStatsTool(scenesCache))
.Add(new GetSceneContentBreakdownTool(scenesCache))
.Add(new GetPerformanceStatsTool(scenesCache))
.Add(new GetSceneLogsTool(logBuffer))
.Add(new TeleportTool(chatMessagesBus, scenesCache, loadingStatus))
.Add(new MoveToTool(globalWorldActions, globalWorld, arguments.PlayerEntity))
Expand Down
178 changes: 178 additions & 0 deletions Explorer/Assets/DCL/McpServer/Tests/GetPerformanceStatsToolShould.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,178 @@
using Cysharp.Threading.Tasks;
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.Threading;

namespace DCL.McpServer.Tests
{
public class GetPerformanceStatsToolShould
{
private IScenesCache scenesCache = null!;
private ISceneFacade scene = null!;
private SceneRuntimeMetrics runtimeMetrics = null!;
private ReactiveProperty<ISceneFacade?> currentScene = null!;

[SetUp]
public void Setup()
{
runtimeMetrics = new SceneRuntimeMetrics { TargetFps = 30 };

scene = Substitute.For<ISceneFacade>();
scene.RuntimeMetrics.Returns(runtimeMetrics);

currentScene = new ReactiveProperty<ISceneFacade?>(scene);
scenesCache = Substitute.For<IScenesCache>();
scenesCache.CurrentScene.Returns(currentScene);
}

[Test]
public void ReportRenderStatsFromTheSampledWindow()
{
// Arrange — 100 frames totalling 2 s: 20 ms average spanning 10–50 ms, 3 above the hiccup bar
var tool = new GetPerformanceStatsTool(scenesCache, (_, _, _) =>
UniTask.FromResult(new GetPerformanceStatsTool.FrameWindow(100, 2000f, 10f, 50f, 3)));

// Act
var structured = (JObject)Execute(tool).Payload["structuredContent"]!;

// Assert
McpSchemaAssert.KeysMatch(tool.OutputSchema!, structured);
Assert.That(structured["framesSampled"]!.Value<int>(), Is.EqualTo(100));
Assert.That(structured["averageFps"]!.Value<float>(), Is.EqualTo(50f));
Assert.That(structured["minFps"]!.Value<float>(), Is.EqualTo(20f));
Assert.That(structured["maxFps"]!.Value<float>(), Is.EqualTo(100f));
Assert.That(structured["averageFrameMs"]!.Value<float>(), Is.EqualTo(20f));
Assert.That(structured["maxFrameMs"]!.Value<float>(), Is.EqualTo(50f));
Assert.That(structured["hiccupFrames"]!.Value<int>(), Is.EqualTo(3));
}

[Test]
public void ReportSceneTickStatsOnlyFromTicksInsideTheWindow()
{
// Arrange — stale pre-window 100 ms ticks would read as 10 fps if they leaked into the window
for (var i = 0; i < 10; i++)
runtimeMetrics.TickTimesNs.Add(100_000_000);

var tool = new GetPerformanceStatsTool(scenesCache, (_, _, _) =>
{
for (var i = 0; i < 4; i++)
runtimeMetrics.TickTimesNs.Add(25_000_000); // 40 fps during the window

return UniTask.FromResult(SteadyWindow());
});

// Act
var structured = (JObject)Execute(tool).Payload["structuredContent"]!;
var sceneTick = (JObject)structured["sceneTick"]!;

// Assert
McpSchemaAssert.KeysMatch(tool.OutputSchema!, structured);
Assert.That(sceneTick["averageFps"]!.Value<float>(), Is.EqualTo(40f));
Assert.That(sceneTick["minFps"]!.Value<float>(), Is.EqualTo(40f));
Assert.That(sceneTick["maxFps"]!.Value<float>(), Is.EqualTo(40f));
Assert.That(sceneTick["targetFps"]!.Value<int>(), Is.EqualTo(30));
}

[Test]
public void ReportNullSceneTickWhenNoTicksLandDuringTheWindow()
{
// Arrange — the ring holds only stale pre-window ticks, as when the scene is paused
for (var i = 0; i < 10; i++)
runtimeMetrics.TickTimesNs.Add(100_000_000);

var tool = new GetPerformanceStatsTool(scenesCache, (_, _, _) => UniTask.FromResult(SteadyWindow()));

// Act
var structured = (JObject)Execute(tool).Payload["structuredContent"]!;

// Assert
Assert.That(structured["sceneTick"]!.Type, Is.EqualTo(JTokenType.Null));
}

[Test]
public void ReportNullSceneTickWhenTheSceneChangesMidSample()
{
// Arrange — the current scene flips during the window, so its ticks describe a mixed window
var tool = new GetPerformanceStatsTool(scenesCache, (_, _, _) =>
{
runtimeMetrics.TickTimesNs.Add(25_000_000);
currentScene.Value = null;
return UniTask.FromResult(SteadyWindow());
});

// Act
var structured = (JObject)Execute(tool).Payload["structuredContent"]!;

// Assert
Assert.That(structured["sceneTick"]!.Type, Is.EqualTo(JTokenType.Null));
}

[Test]
public void ClampSampleSecondsBeforeSampling()
{
// Arrange
var receivedSeconds = 0f;

var tool = new GetPerformanceStatsTool(scenesCache, (seconds, _, _) =>
{
receivedSeconds = seconds;
return UniTask.FromResult(SteadyWindow());
});

// Act
var structured = (JObject)Execute(tool, new JObject { ["sampleSeconds"] = 100 }).Payload["structuredContent"]!;

// Assert
Assert.That(receivedSeconds, Is.EqualTo(10f));
Assert.That(structured["sampleSeconds"]!.Value<float>(), Is.EqualTo(10f));
}

[Test]
public void SampleHiccupsAgainstTheClientWideThreshold()
{
// Arrange
var receivedThresholdMs = 0f;

var tool = new GetPerformanceStatsTool(scenesCache, (_, thresholdMs, _) =>
{
receivedThresholdMs = thresholdMs;
return UniTask.FromResult(SteadyWindow());
});

// Act
var structured = (JObject)Execute(tool).Payload["structuredContent"]!;

// Assert
float expected = Profiler.EffectiveHiccupThresholdNs() / 1_000_000f;
Assert.That(receivedThresholdMs, Is.EqualTo(expected));
Assert.That(structured["hiccupThresholdMs"], Is.Not.Null);
}

[Test]
public void ErrorWhenNoFramesWereSampled()
{
// Arrange
var tool = new GetPerformanceStatsTool(scenesCache, (_, _, _) =>
UniTask.FromResult(new GetPerformanceStatsTool.FrameWindow(0, 0f, 0f, 0f, 0)));

// Act
McpToolResult result = Execute(tool);

// Assert
Assert.That(result.Payload["isError"]!.Value<bool>(), Is.True);
}

private static GetPerformanceStatsTool.FrameWindow SteadyWindow() =>
new (120, 1920f, 16f, 16f, 0);

private static McpToolResult Execute(GetPerformanceStatsTool tool, JObject? arguments = null) =>
tool.ExecuteAsync(arguments ?? new JObject(), CancellationToken.None).GetAwaiter().GetResult();
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading