ue-mcp 1.4.12 → 1.4.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -5
- package/dist/bridge/bridge-timeouts.js +16 -0
- package/dist/bridge/bridge-timeouts.js.map +1 -1
- package/dist/bridge/bridge.d.ts +58 -3
- package/dist/bridge/bridge.js +149 -8
- package/dist/bridge/bridge.js.map +1 -1
- package/dist/cli/cli-commands.js +7 -1
- package/dist/cli/cli-commands.js.map +1 -1
- package/dist/cli/doctor.d.ts +9 -0
- package/dist/cli/doctor.js +63 -0
- package/dist/cli/doctor.js.map +1 -1
- package/dist/cli/editor-flag.js +5 -1
- package/dist/cli/editor-flag.js.map +1 -1
- package/dist/cli/extension-cli.d.ts +3 -0
- package/dist/cli/extension-cli.js +83 -16
- package/dist/cli/extension-cli.js.map +1 -1
- package/dist/cli/flow-cli.js +3 -1
- package/dist/cli/flow-cli.js.map +1 -1
- package/dist/cli/init-core.d.ts +74 -1
- package/dist/cli/init-core.js +231 -38
- package/dist/cli/init-core.js.map +1 -1
- package/dist/cli/init.js +86 -22
- package/dist/cli/init.js.map +1 -1
- package/dist/cli/login-cli.d.ts +27 -1
- package/dist/cli/login-cli.js +130 -17
- package/dist/cli/login-cli.js.map +1 -1
- package/dist/cli/plugin-cli.js +1 -1
- package/dist/cli/plugin-cli.js.map +1 -1
- package/dist/cli/tools-cli.d.ts +14 -0
- package/dist/cli/tools-cli.js +270 -0
- package/dist/cli/tools-cli.js.map +1 -0
- package/dist/cli/ui/ansi.d.ts +2 -0
- package/dist/cli/ui/ansi.js +8 -0
- package/dist/cli/ui/ansi.js.map +1 -1
- package/dist/codeintel/config-hierarchy.d.ts +73 -0
- package/dist/codeintel/config-hierarchy.js +165 -0
- package/dist/codeintel/config-hierarchy.js.map +1 -0
- package/dist/config/project.d.ts +12 -4
- package/dist/config/project.js.map +1 -1
- package/dist/core/archive.d.ts +8 -0
- package/dist/core/archive.js +40 -0
- package/dist/core/archive.js.map +1 -0
- package/dist/core/env.d.ts +4 -0
- package/dist/core/env.js +4 -0
- package/dist/core/env.js.map +1 -1
- package/dist/core/errors.d.ts +9 -1
- package/dist/core/errors.js +8 -0
- package/dist/core/errors.js.map +1 -1
- package/dist/core/png.d.ts +31 -0
- package/dist/core/png.js +308 -0
- package/dist/core/png.js.map +1 -0
- package/dist/core/types.d.ts +31 -0
- package/dist/daemon/daemon.js +16 -2
- package/dist/daemon/daemon.js.map +1 -1
- package/dist/daemon/extension-install.d.ts +14 -0
- package/dist/daemon/extension-install.js +25 -29
- package/dist/daemon/extension-install.js.map +1 -1
- package/dist/daemon/install-names.d.ts +10 -0
- package/dist/daemon/install-names.js +39 -0
- package/dist/daemon/install-names.js.map +1 -0
- package/dist/daemon/tools-routes.d.ts +23 -0
- package/dist/daemon/tools-routes.js +46 -0
- package/dist/daemon/tools-routes.js.map +1 -0
- package/dist/diagram/action.d.ts +25 -0
- package/dist/diagram/action.js +141 -0
- package/dist/diagram/action.js.map +1 -0
- package/dist/diagram/adapters.d.ts +48 -0
- package/dist/diagram/adapters.js +569 -0
- package/dist/diagram/adapters.js.map +1 -0
- package/dist/diagram/mermaid.d.ts +22 -0
- package/dist/diagram/mermaid.js +164 -0
- package/dist/diagram/mermaid.js.map +1 -0
- package/dist/diagram/model.d.ts +59 -0
- package/dist/diagram/model.js +17 -0
- package/dist/diagram/model.js.map +1 -0
- package/dist/diagram/png.d.ts +17 -0
- package/dist/diagram/png.js +48 -0
- package/dist/diagram/png.js.map +1 -0
- package/dist/diagram/select.d.ts +26 -0
- package/dist/diagram/select.js +146 -0
- package/dist/diagram/select.js.map +1 -0
- package/dist/diagram/svg.d.ts +10 -0
- package/dist/diagram/svg.js +254 -0
- package/dist/diagram/svg.js.map +1 -0
- package/dist/diagram/theme.d.ts +33 -0
- package/dist/diagram/theme.js +37 -0
- package/dist/diagram/theme.js.map +1 -0
- package/dist/dispatch/call-pipeline.d.ts +8 -0
- package/dist/dispatch/call-pipeline.js +19 -2
- package/dist/dispatch/call-pipeline.js.map +1 -1
- package/dist/dispatch/inline-image.d.ts +70 -0
- package/dist/dispatch/inline-image.js +198 -0
- package/dist/dispatch/inline-image.js.map +1 -0
- package/dist/dispatch/lease-paths.d.ts +16 -0
- package/dist/dispatch/lease-paths.js +42 -0
- package/dist/dispatch/lease-paths.js.map +1 -0
- package/dist/dispatch/leases.d.ts +71 -0
- package/dist/dispatch/leases.js +191 -0
- package/dist/dispatch/leases.js.map +1 -0
- package/dist/dispatch/offline.js +17 -0
- package/dist/dispatch/offline.js.map +1 -1
- package/dist/dispatch/server-dispatch.d.ts +32 -1
- package/dist/dispatch/server-dispatch.js +70 -2
- package/dist/dispatch/server-dispatch.js.map +1 -1
- package/dist/editor/bridge-binaries.d.ts +2 -0
- package/dist/editor/bridge-binaries.js +12 -22
- package/dist/editor/bridge-binaries.js.map +1 -1
- package/dist/editor/dialog-guard.d.ts +10 -0
- package/dist/editor/dialog-guard.js +26 -4
- package/dist/editor/dialog-guard.js.map +1 -1
- package/dist/editor/editor-plugin.d.ts +16 -0
- package/dist/editor/editor-plugin.js +98 -0
- package/dist/editor/editor-plugin.js.map +1 -0
- package/dist/editor/engine-root.d.ts +2 -0
- package/dist/editor/engine-root.js +2 -2
- package/dist/editor/engine-root.js.map +1 -1
- package/dist/editor/install-marker.d.ts +2 -0
- package/dist/editor/install-marker.js +13 -6
- package/dist/editor/install-marker.js.map +1 -1
- package/dist/extensions/registry-auth.d.ts +60 -1
- package/dist/extensions/registry-auth.js +202 -5
- package/dist/extensions/registry-auth.js.map +1 -1
- package/dist/extensions/skill-catalog.d.ts +20 -0
- package/dist/extensions/skill-catalog.js +56 -0
- package/dist/extensions/skill-catalog.js.map +1 -0
- package/dist/flow/flow-tool.js +10 -2
- package/dist/flow/flow-tool.js.map +1 -1
- package/dist/flow/guarded-bridge.d.ts +6 -4
- package/dist/flow/guarded-bridge.js +11 -5
- package/dist/flow/guarded-bridge.js.map +1 -1
- package/dist/flow/loader.js +19 -0
- package/dist/flow/loader.js.map +1 -1
- package/dist/flow/run-action.js +37 -5
- package/dist/flow/run-action.js.map +1 -1
- package/dist/flow/write-methods.js +4 -0
- package/dist/flow/write-methods.js.map +1 -1
- package/dist/integrations/agent-guides.d.ts +29 -0
- package/dist/integrations/agent-guides.js +125 -0
- package/dist/integrations/agent-guides.js.map +1 -0
- package/dist/integrations/claude-code/mcp-client-config.d.ts +16 -4
- package/dist/integrations/claude-code/mcp-client-config.js +57 -10
- package/dist/integrations/claude-code/mcp-client-config.js.map +1 -1
- package/dist/integrations/claude-code/unreal-mcp-entries.d.ts +33 -0
- package/dist/integrations/claude-code/unreal-mcp-entries.js +159 -0
- package/dist/integrations/claude-code/unreal-mcp-entries.js.map +1 -0
- package/dist/integrations/epic/project-status.d.ts +25 -0
- package/dist/integrations/epic/project-status.js +35 -0
- package/dist/integrations/epic/project-status.js.map +1 -0
- package/dist/integrations/epic/toolset-settings.d.ts +28 -0
- package/dist/integrations/epic/toolset-settings.js +136 -0
- package/dist/integrations/epic/toolset-settings.js.map +1 -0
- package/dist/integrations/epic/unreal-assistant.d.ts +64 -0
- package/dist/integrations/epic/unreal-assistant.js +209 -0
- package/dist/integrations/epic/unreal-assistant.js.map +1 -0
- package/dist/integrations/epic/unreal-canvas.d.ts +48 -0
- package/dist/integrations/epic/unreal-canvas.js +126 -0
- package/dist/integrations/epic/unreal-canvas.js.map +1 -0
- package/dist/integrations/epic/unreal-mcp-server.d.ts +74 -0
- package/dist/integrations/epic/unreal-mcp-server.js +231 -0
- package/dist/integrations/epic/unreal-mcp-server.js.map +1 -0
- package/dist/server/context-projection.js +5 -3
- package/dist/server/context-projection.js.map +1 -1
- package/dist/server/editor-resources.d.ts +39 -0
- package/dist/server/editor-resources.js +94 -0
- package/dist/server/editor-resources.js.map +1 -0
- package/dist/server/mcp-server.d.ts +7 -0
- package/dist/server/mcp-server.js +49 -13
- package/dist/server/mcp-server.js.map +1 -1
- package/dist/server/runtime.js +21 -1
- package/dist/server/runtime.js.map +1 -1
- package/dist/server/skill-prompts.d.ts +16 -0
- package/dist/server/skill-prompts.js +22 -0
- package/dist/server/skill-prompts.js.map +1 -0
- package/dist/sessions/session-load.d.ts +16 -0
- package/dist/sessions/session-load.js +64 -20
- package/dist/sessions/session-load.js.map +1 -1
- package/dist/sessions/session.d.ts +9 -0
- package/dist/sessions/session.js +8 -0
- package/dist/sessions/session.js.map +1 -1
- package/dist/surface/action-signature.js +9 -0
- package/dist/surface/action-signature.js.map +1 -1
- package/dist/surface/category-state.d.ts +119 -0
- package/dist/surface/category-state.js +232 -0
- package/dist/surface/category-state.js.map +1 -0
- package/dist/surface/context/call-envelope.d.ts +7 -0
- package/dist/surface/context/call-envelope.js +11 -0
- package/dist/surface/context/call-envelope.js.map +1 -1
- package/dist/surface/context/instructions.d.ts +2 -0
- package/dist/surface/context/instructions.js +20 -10
- package/dist/surface/context/instructions.js.map +1 -1
- package/dist/surface/context/micro-context.d.ts +7 -0
- package/dist/surface/context/micro-context.js +70 -14
- package/dist/surface/context/micro-context.js.map +1 -1
- package/dist/surface/context/tool-search.js +6 -2
- package/dist/surface/context/tool-search.js.map +1 -1
- package/dist/surface/epic-engines.d.ts +24 -0
- package/dist/surface/epic-engines.js +32 -0
- package/dist/surface/epic-engines.js.map +1 -0
- package/dist/surface/epic-input.d.ts +27 -2
- package/dist/surface/epic-input.js +39 -2
- package/dist/surface/epic-input.js.map +1 -1
- package/dist/surface/epic-surface.d.ts +15 -17
- package/dist/surface/epic-surface.js +13 -57
- package/dist/surface/epic-surface.js.map +1 -1
- package/dist/surface/registered-surface.d.ts +21 -4
- package/dist/surface/registered-surface.js +67 -23
- package/dist/surface/registered-surface.js.map +1 -1
- package/dist/surface/schemas.d.ts +8 -0
- package/dist/surface/schemas.js +14 -3
- package/dist/surface/schemas.js.map +1 -1
- package/dist/tool-counts.json +38 -31
- package/dist/tools/ai-assistant-wait.d.ts +17 -0
- package/dist/tools/ai-assistant-wait.js +45 -0
- package/dist/tools/ai-assistant-wait.js.map +1 -0
- package/dist/tools/animation.js +14 -8
- package/dist/tools/animation.js.map +1 -1
- package/dist/tools/asset.js +18 -5
- package/dist/tools/asset.js.map +1 -1
- package/dist/tools/audio.js +3 -0
- package/dist/tools/audio.js.map +1 -1
- package/dist/tools/blueprint.js +7 -0
- package/dist/tools/blueprint.js.map +1 -1
- package/dist/tools/canvas-results.d.ts +32 -0
- package/dist/tools/canvas-results.js +137 -0
- package/dist/tools/canvas-results.js.map +1 -0
- package/dist/tools/canvas.d.ts +19 -0
- package/dist/tools/canvas.js +254 -0
- package/dist/tools/canvas.js.map +1 -0
- package/dist/tools/chooser.js +42 -6
- package/dist/tools/chooser.js.map +1 -1
- package/dist/tools/demo.js +2 -2
- package/dist/tools/demo.js.map +1 -1
- package/dist/tools/editor/batch.js +1 -1
- package/dist/tools/editor/batch.js.map +1 -1
- package/dist/tools/editor-csv-profile.d.ts +62 -0
- package/dist/tools/editor-csv-profile.js +266 -0
- package/dist/tools/editor-csv-profile.js.map +1 -0
- package/dist/tools/editor.js +41 -12
- package/dist/tools/editor.js.map +1 -1
- package/dist/tools/epic/animation.generated.d.ts +1 -1
- package/dist/tools/epic/animation.generated.js +5051 -695
- package/dist/tools/epic/animation.generated.js.map +1 -1
- package/dist/tools/epic/asset.generated.d.ts +1 -1
- package/dist/tools/epic/asset.generated.js +848 -156
- package/dist/tools/epic/asset.generated.js.map +1 -1
- package/dist/tools/epic/audio.generated.d.ts +6 -0
- package/dist/tools/epic/audio.generated.js +323 -0
- package/dist/tools/epic/audio.generated.js.map +1 -0
- package/dist/tools/epic/blueprint.generated.d.ts +1 -1
- package/dist/tools/epic/blueprint.generated.js +467 -118
- package/dist/tools/epic/blueprint.generated.js.map +1 -1
- package/dist/tools/epic/catalog-engines.d.ts +2 -0
- package/dist/tools/epic/catalog-engines.js +4 -0
- package/dist/tools/epic/catalog-engines.js.map +1 -0
- package/dist/tools/epic/conversation.generated.js +11 -11
- package/dist/tools/epic/conversation.generated.js.map +1 -1
- package/dist/tools/epic/dataflow.generated.d.ts +1 -1
- package/dist/tools/epic/dataflow.generated.js +349 -29
- package/dist/tools/epic/dataflow.generated.js.map +1 -1
- package/dist/tools/epic/editor.generated.d.ts +1 -1
- package/dist/tools/epic/editor.generated.js +575 -41
- package/dist/tools/epic/editor.generated.js.map +1 -1
- package/dist/tools/epic/effects.d.ts +9 -3
- package/dist/tools/epic/effects.js +3384 -33
- package/dist/tools/epic/effects.js.map +1 -1
- package/dist/tools/epic/epic.generated.d.ts +1 -1
- package/dist/tools/epic/epic.generated.js +68 -10
- package/dist/tools/epic/epic.generated.js.map +1 -1
- package/dist/tools/epic/gameplay.generated.d.ts +1 -1
- package/dist/tools/epic/gameplay.generated.js +502 -45
- package/dist/tools/epic/gameplay.generated.js.map +1 -1
- package/dist/tools/epic/gas.generated.d.ts +1 -1
- package/dist/tools/epic/gas.generated.js +29 -21
- package/dist/tools/epic/gas.generated.js.map +1 -1
- package/dist/tools/epic/index.d.ts +4 -0
- package/dist/tools/epic/index.js +4 -0
- package/dist/tools/epic/index.js.map +1 -1
- package/dist/tools/epic/level.generated.d.ts +1 -1
- package/dist/tools/epic/level.generated.js +524 -95
- package/dist/tools/epic/level.generated.js.map +1 -1
- package/dist/tools/epic/material.generated.d.ts +1 -1
- package/dist/tools/epic/material.generated.js +152 -76
- package/dist/tools/epic/material.generated.js.map +1 -1
- package/dist/tools/epic/niagara.generated.d.ts +1 -1
- package/dist/tools/epic/niagara.generated.js +124 -115
- package/dist/tools/epic/niagara.generated.js.map +1 -1
- package/dist/tools/epic/pcg.generated.d.ts +1 -1
- package/dist/tools/epic/pcg.generated.js +322 -47
- package/dist/tools/epic/pcg.generated.js.map +1 -1
- package/dist/tools/epic/plugins.generated.d.ts +1 -1
- package/dist/tools/epic/plugins.generated.js +143 -36
- package/dist/tools/epic/plugins.generated.js.map +1 -1
- package/dist/tools/epic/project.generated.d.ts +1 -1
- package/dist/tools/epic/project.generated.js +144 -31
- package/dist/tools/epic/project.generated.js.map +1 -1
- package/dist/tools/epic/reflection.generated.d.ts +1 -1
- package/dist/tools/epic/reflection.generated.js +33 -16
- package/dist/tools/epic/reflection.generated.js.map +1 -1
- package/dist/tools/epic/source_control.generated.d.ts +6 -0
- package/dist/tools/epic/source_control.generated.js +260 -0
- package/dist/tools/epic/source_control.generated.js.map +1 -0
- package/dist/tools/epic/statetree.generated.d.ts +1 -1
- package/dist/tools/epic/statetree.generated.js +292 -20
- package/dist/tools/epic/statetree.generated.js.map +1 -1
- package/dist/tools/epic/toolset-routes.d.ts +6 -0
- package/dist/tools/epic/toolset-routes.js +74 -0
- package/dist/tools/epic/toolset-routes.js.map +1 -0
- package/dist/tools/epic/widget.generated.d.ts +1 -1
- package/dist/tools/epic/widget.generated.js +797 -85
- package/dist/tools/epic/widget.generated.js.map +1 -1
- package/dist/tools/epic.js +22 -4
- package/dist/tools/epic.js.map +1 -1
- package/dist/tools/gameplay.js +10 -0
- package/dist/tools/gameplay.js.map +1 -1
- package/dist/tools/graph-diagrams.d.ts +15 -0
- package/dist/tools/graph-diagrams.js +153 -0
- package/dist/tools/graph-diagrams.js.map +1 -0
- package/dist/tools/landscape.js +12 -1
- package/dist/tools/landscape.js.map +1 -1
- package/dist/tools/level.js +35 -1
- package/dist/tools/level.js.map +1 -1
- package/dist/tools/material.js +7 -1
- package/dist/tools/material.js.map +1 -1
- package/dist/tools/networking.js +1 -0
- package/dist/tools/networking.js.map +1 -1
- package/dist/tools/pcg.js +8 -1
- package/dist/tools/pcg.js.map +1 -1
- package/dist/tools/project/categories.d.ts +74 -0
- package/dist/tools/project/categories.js +405 -0
- package/dist/tools/project/categories.js.map +1 -0
- package/dist/tools/project/config.js +93 -0
- package/dist/tools/project/config.js.map +1 -1
- package/dist/tools/project/leases.d.ts +8 -0
- package/dist/tools/project/leases.js +107 -0
- package/dist/tools/project/leases.js.map +1 -0
- package/dist/tools/project/localization.d.ts +7 -0
- package/dist/tools/project/localization.js +21 -0
- package/dist/tools/project/localization.js.map +1 -0
- package/dist/tools/project/sessions.js +29 -1
- package/dist/tools/project/sessions.js.map +1 -1
- package/dist/tools/project.js +25 -4
- package/dist/tools/project.js.map +1 -1
- package/dist/tools/source_control.js +3 -0
- package/dist/tools/source_control.js.map +1 -1
- package/dist/tools/specs/animation.generated.js +3 -3
- package/dist/tools/specs/animation.generated.js.map +1 -1
- package/dist/tools/specs/asset.generated.js +223 -12
- package/dist/tools/specs/asset.generated.js.map +1 -1
- package/dist/tools/specs/chooser.generated.js +1039 -63
- package/dist/tools/specs/chooser.generated.js.map +1 -1
- package/dist/tools/specs/demo.generated.js +11 -3
- package/dist/tools/specs/demo.generated.js.map +1 -1
- package/dist/tools/specs/editor.generated.js +444 -15
- package/dist/tools/specs/editor.generated.js.map +1 -1
- package/dist/tools/specs/epic.generated.js +215 -3
- package/dist/tools/specs/epic.generated.js.map +1 -1
- package/dist/tools/specs/gameplay.generated.js +175 -4
- package/dist/tools/specs/gameplay.generated.js.map +1 -1
- package/dist/tools/specs/landscape.generated.js +483 -7
- package/dist/tools/specs/landscape.generated.js.map +1 -1
- package/dist/tools/specs/level.generated.js +1218 -68
- package/dist/tools/specs/level.generated.js.map +1 -1
- package/dist/tools/specs/networking.generated.js +83 -0
- package/dist/tools/specs/networking.generated.js.map +1 -1
- package/dist/tools/specs/pcg.generated.js +125 -5
- package/dist/tools/specs/pcg.generated.js.map +1 -1
- package/dist/tools/specs/project.generated.js +134 -0
- package/dist/tools/specs/project.generated.js.map +1 -1
- package/dist/tools/specs/statetree.generated.js +245 -9
- package/dist/tools/specs/statetree.generated.js.map +1 -1
- package/dist/tools/specs/widget.generated.js +362 -3
- package/dist/tools/specs/widget.generated.js.map +1 -1
- package/dist/tools/statetree.js +12 -1
- package/dist/tools/statetree.js.map +1 -1
- package/dist/tools/widget.js +12 -0
- package/dist/tools/widget.js.map +1 -1
- package/dist/tools.js +2 -0
- package/dist/tools.js.map +1 -1
- package/dist/ue-mcp.default.yml +14785 -983
- package/package.json +4 -2
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/BridgePortConfig.cpp +56 -4
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/BridgeRequestContext.h +54 -0
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/BridgeServer.cpp +203 -18
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/BridgeServer.h +42 -0
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/HandlerCatalog.cpp +6 -0
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/HandlerDeferred.cpp +225 -0
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/HandlerLevelSwitch.h +123 -0
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/HandlerScriptErrors.h +44 -0
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/Animation/AnimationHandlers.cpp +7 -7
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/Asset/AssetHandlers.cpp +15 -0
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/Asset/AssetHandlers.h +9 -0
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/Asset/AssetHandlers_Import.cpp +147 -0
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/Asset/AssetHandlers_Redirectors.cpp +11 -0
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/Asset/AssetHandlers_SemanticSearch.cpp +435 -0
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/Chooser/ChooserHandlers.cpp +363 -331
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/Chooser/ChooserHandlers.h +30 -0
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/Chooser/ChooserHandlers_Authoring.cpp +2178 -0
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/Chooser/HandlerChooserShared.h +1005 -0
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/Demo/DemoHandlers.cpp +104 -11
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/Demo/DemoHandlers.h +19 -1
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/Dialog/DialogHandlers.cpp +54 -2
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/Dialog/DialogHandlers.h +9 -0
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/Editor/EditorHandlers.cpp +31 -0
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/Editor/EditorHandlers.h +15 -0
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/Editor/EditorHandlers_CsvProfile.cpp +272 -0
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/Editor/EditorHandlers_MapCheck.cpp +197 -0
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/Editor/EditorHandlers_Profiling.cpp +11 -16
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/Editor/EditorHandlers_PythonPaths.cpp +237 -0
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/Editor/EditorHandlers_TraceAnalysis.cpp +790 -0
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/Epic/EpicHandlers.cpp +201 -56
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/Epic/EpicHandlers.h +30 -0
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/Epic/EpicHandlers_AIAssistant.cpp +510 -0
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/Epic/EpicHandlers_MCP.cpp +394 -0
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/Epic/EpicHandlers_Toolsets.cpp +542 -0
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/Epic/MCPAIAssistantListener.h +19 -0
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/Gas/GasHandlers_Runtime.cpp +10 -7
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/Landscape/LandscapeHandlers.cpp +9 -23
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/Landscape/LandscapeHandlers.h +4 -0
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/Landscape/LandscapeHandlers_Sculpt.cpp +7 -0
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/Landscape/LandscapeHandlers_Splines.cpp +1253 -0
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/Landscape/LandscapeHandlers_Splines.h +39 -0
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/Level/LevelGeneratorRecords.h +84 -0
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/Level/LevelHandlers.cpp +57 -12
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/Level/LevelHandlers.h +33 -0
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/Level/LevelHandlers_Blockout.cpp +987 -0
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/Level/LevelHandlers_Blockout.h +23 -0
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/Level/LevelHandlers_PerfAudit.cpp +925 -0
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/Level/LevelHandlers_ReplaceActors.cpp +387 -0
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/Level/LevelHandlers_SplineGen.cpp +813 -0
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/Level/LevelHandlers_SplineGen.h +22 -0
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/Level/LevelHandlers_WorldPartitionSubsystem.cpp +1238 -0
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/Localization/LocalizationHandlers.cpp +982 -0
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/Localization/LocalizationHandlers.h +32 -0
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/MachineLearning/MachineLearningHandlers.cpp +44 -0
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/MachineLearning/MachineLearningHandlers.h +29 -0
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/MachineLearning/MachineLearningHandlers_LearningAgents.cpp +491 -0
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/MachineLearning/MachineLearningHandlers_NNE.cpp +532 -0
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/Networking/NetworkingHandlers.cpp +14 -0
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/Networking/NetworkingHandlers.h +2 -0
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/Networking/NetworkingHandlers_Audit.cpp +496 -0
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/PCG/PCGEdgeValidation.h +150 -0
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/PCG/PCGHandlers.cpp +26 -1
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/PCG/PCGHandlers.h +5 -0
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/PCG/PCGHandlers_CustomHLSL.cpp +290 -0
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/PCG/PCGHandlers_LevelToAsset.cpp +34 -3
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/Sequencer/MovieRenderQueueHandlers.cpp +1215 -0
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/Sequencer/MovieRenderQueueHandlers.h +27 -0
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/StateTree/StateTreeHandlers.cpp +72 -0
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/StateTree/StateTreeHandlers.h +11 -0
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/StateTree/StateTreeHandlers_NodesAndBindings.cpp +1172 -0
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/Widget/WidgetHandlers.cpp +4 -0
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/Widget/WidgetHandlers_MVVM.cpp +396 -0
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/Widget/WidgetHandlers_MVVM.h +32 -0
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Tests/DialogBlockingWindowTests.cpp +74 -0
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Tests/HandlerSpecContractTests.cpp +4 -0
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Public/HandlerDeferred.h +76 -0
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Public/HandlerEngineVersion.h +4 -0
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Public/HandlerMVVMBackend.h +92 -0
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Public/HandlerStaticInvoke.h +96 -0
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/UE_MCP_Bridge.Build.cs +75 -0
- package/plugin/ue_mcp_bridge/Source/UE_MCP_BridgeMVVM/Private/UE_MCP_BridgeMVVMModule.cpp +1277 -0
- package/plugin/ue_mcp_bridge/Source/UE_MCP_BridgeMVVM/UE_MCP_BridgeMVVM.Build.cs +58 -0
- package/plugin/ue_mcp_bridge/UE_MCP_Bridge.uplugin +7 -2
- package/skills/ue-mcp-animation/SKILL.md +4 -4
- package/skills/ue-mcp-epic-routing/SKILL.md +4 -0
|
@@ -0,0 +1,790 @@
|
|
|
1
|
+
// editor(analyze_trace): read a recorded .utrace back and summarise it.
|
|
2
|
+
//
|
|
3
|
+
// editor(start_trace) and editor(stop_trace) write a trace and report where it
|
|
4
|
+
// landed. This file is the other half: it opens the file with the engine's own
|
|
5
|
+
// analysis stack (TraceServices, the module Unreal Insights is built on) and
|
|
6
|
+
// answers the questions a profiling pass starts with, without leaving the
|
|
7
|
+
// editor:
|
|
8
|
+
//
|
|
9
|
+
// * frames: count, average, p50/p95/p99, min and max frame time;
|
|
10
|
+
// * hitches: every frame over a threshold, in time order;
|
|
11
|
+
// * worst frames, each with the CPU timers that spent its time;
|
|
12
|
+
// * top timers over the window, by inclusive or exclusive time;
|
|
13
|
+
// * GPU busy time per frame, when the trace carries GPU timing;
|
|
14
|
+
// * bookmarks with their times and the frame they fell in.
|
|
15
|
+
//
|
|
16
|
+
// How a session is opened and read mirrors Insights: ITraceServicesModule hands
|
|
17
|
+
// out the analysis service, StartAnalysis runs the analyzers on worker threads,
|
|
18
|
+
// and every provider read happens inside FAnalysisSessionReadScope once
|
|
19
|
+
// IsAnalysisComplete reports true. A long trace takes a while to analyse, so a
|
|
20
|
+
// bridge request defers its answer (HandlerDeferred.h): the handler starts the
|
|
21
|
+
// session on the game thread, returns the deferred marker, and a pool task
|
|
22
|
+
// waits for the analysis, reports progress, builds the summary and completes
|
|
23
|
+
// the call. A cancel stops the session.
|
|
24
|
+
//
|
|
25
|
+
// Engine versions. TraceServices exists on every supported engine, but its
|
|
26
|
+
// timing-profiler surface moved a lot before 5.7 (aggregation parameters, timer
|
|
27
|
+
// readers, GPU queues). The headers read for this file are 5.7, 5.8 and 5.9, so
|
|
28
|
+
// the analysis is compiled from 5.7 up and older engines get a clear error
|
|
29
|
+
// rather than a guess at an API nobody here has read. Within that range the
|
|
30
|
+
// calls used here (CreateAggregation, ReadTimeline, EnumerateGpuQueues and the
|
|
31
|
+
// frame, thread and bookmark providers) have the same signatures.
|
|
32
|
+
//
|
|
33
|
+
// Every helper is prefixed MCPTraceAnalysis: the module is a unity build, and
|
|
34
|
+
// two .cpp files that share a blob share their anonymous namespaces.
|
|
35
|
+
|
|
36
|
+
#include "EditorHandlers.h"
|
|
37
|
+
|
|
38
|
+
#include "HandlerDeferred.h"
|
|
39
|
+
#include "HandlerUtils.h"
|
|
40
|
+
|
|
41
|
+
#include "Async/Async.h"
|
|
42
|
+
#include "HAL/FileManager.h"
|
|
43
|
+
#include "HAL/PlatformProcess.h"
|
|
44
|
+
#include "HAL/PlatformTime.h"
|
|
45
|
+
#include "Misc/DateTime.h"
|
|
46
|
+
#include "Misc/Paths.h"
|
|
47
|
+
#include "Modules/ModuleManager.h"
|
|
48
|
+
#include "ProfilingDebugging/MiscTrace.h"
|
|
49
|
+
#include "ProfilingDebugging/TraceAuxiliary.h"
|
|
50
|
+
|
|
51
|
+
#include "Dom/JsonObject.h"
|
|
52
|
+
#include "Dom/JsonValue.h"
|
|
53
|
+
|
|
54
|
+
#if UE_MCP_HAS_5_7_API
|
|
55
|
+
#include "TraceServices/AnalysisService.h"
|
|
56
|
+
#include "TraceServices/Containers/Tables.h"
|
|
57
|
+
#include "TraceServices/Containers/Timelines.h"
|
|
58
|
+
#include "TraceServices/ITraceServicesModule.h"
|
|
59
|
+
#include "TraceServices/Model/AnalysisSession.h"
|
|
60
|
+
#include "TraceServices/Model/Bookmarks.h"
|
|
61
|
+
#include "TraceServices/Model/Frames.h"
|
|
62
|
+
#include "TraceServices/Model/Threads.h"
|
|
63
|
+
#include "TraceServices/Model/TimingProfiler.h"
|
|
64
|
+
#endif
|
|
65
|
+
|
|
66
|
+
namespace
|
|
67
|
+
{
|
|
68
|
+
/** What the caller asked for, copied off the params on the game thread so
|
|
69
|
+
* the pool task never touches the request object. */
|
|
70
|
+
struct FMCPTraceAnalysisRequest
|
|
71
|
+
{
|
|
72
|
+
FString File;
|
|
73
|
+
double WindowStart = 0.0;
|
|
74
|
+
/** Negative: to the end of the trace. */
|
|
75
|
+
double WindowEnd = -1.0;
|
|
76
|
+
double HitchThresholdMs = 50.0;
|
|
77
|
+
int32 WorstFrames = 10;
|
|
78
|
+
int32 TopTimers = 20;
|
|
79
|
+
int32 TimersPerFrame = 5;
|
|
80
|
+
int32 MaxHitches = 50;
|
|
81
|
+
int32 MaxBookmarks = 100;
|
|
82
|
+
bool bAllThreads = false;
|
|
83
|
+
bool bSortExclusive = false;
|
|
84
|
+
bool bRenderingFrames = false;
|
|
85
|
+
bool bDumpToFile = false;
|
|
86
|
+
FString OutputPath;
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
/** The newest .utrace under Saved/Profiling, which is where start_trace
|
|
90
|
+
* writes by default. Empty when there is none. */
|
|
91
|
+
FString MCPTraceAnalysisNewestTrace()
|
|
92
|
+
{
|
|
93
|
+
const FString Dir = FPaths::ConvertRelativePathToFull(
|
|
94
|
+
FPaths::Combine(FPaths::ProjectSavedDir(), TEXT("Profiling")));
|
|
95
|
+
TArray<FString> Found;
|
|
96
|
+
IFileManager::Get().FindFilesRecursive(Found, *Dir, TEXT("*.utrace"), /*Files=*/true, /*Directories=*/false);
|
|
97
|
+
FString Newest;
|
|
98
|
+
FDateTime NewestStamp = FDateTime::MinValue();
|
|
99
|
+
for (const FString& Path : Found)
|
|
100
|
+
{
|
|
101
|
+
const FDateTime Stamp = IFileManager::Get().GetTimeStamp(*Path);
|
|
102
|
+
if (Newest.IsEmpty() || Stamp > NewestStamp)
|
|
103
|
+
{
|
|
104
|
+
Newest = Path;
|
|
105
|
+
NewestStamp = Stamp;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
return Newest;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/** A relative path is tried under Saved/Profiling first, where traces
|
|
112
|
+
* land, then under the project directory. */
|
|
113
|
+
FString MCPTraceAnalysisResolveFile(const FString& Requested)
|
|
114
|
+
{
|
|
115
|
+
if (!FPaths::IsRelative(Requested))
|
|
116
|
+
{
|
|
117
|
+
return FPaths::ConvertRelativePathToFull(Requested);
|
|
118
|
+
}
|
|
119
|
+
const FString UnderProfiling = FPaths::ConvertRelativePathToFull(
|
|
120
|
+
FPaths::Combine(FPaths::ProjectSavedDir(), TEXT("Profiling"), Requested));
|
|
121
|
+
if (FPaths::FileExists(UnderProfiling))
|
|
122
|
+
{
|
|
123
|
+
return UnderProfiling;
|
|
124
|
+
}
|
|
125
|
+
return FPaths::ConvertRelativePathToFull(FPaths::Combine(FPaths::ProjectDir(), Requested));
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
#if UE_MCP_HAS_5_7_API
|
|
129
|
+
double MCPTraceAnalysisPercentile(const TArray<double>& Sorted, double P)
|
|
130
|
+
{
|
|
131
|
+
if (Sorted.Num() == 0) return 0.0;
|
|
132
|
+
// Nearest rank: the smallest value with at least P of the samples at
|
|
133
|
+
// or below it. No interpolation, so every reported value is a frame
|
|
134
|
+
// that really happened.
|
|
135
|
+
const int32 Rank = FMath::Clamp(FMath::CeilToInt(P * Sorted.Num()) - 1, 0, Sorted.Num() - 1);
|
|
136
|
+
return Sorted[Rank];
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
TSharedPtr<FJsonObject> MCPTraceAnalysisDistribution(TArray<double> Values)
|
|
140
|
+
{
|
|
141
|
+
TSharedPtr<FJsonObject> Out = MakeShared<FJsonObject>();
|
|
142
|
+
Values.Sort();
|
|
143
|
+
double Total = 0.0;
|
|
144
|
+
for (double V : Values) Total += V;
|
|
145
|
+
Out->SetNumberField(TEXT("count"), Values.Num());
|
|
146
|
+
Out->SetNumberField(TEXT("avgMs"), Values.Num() > 0 ? Total / Values.Num() : 0.0);
|
|
147
|
+
Out->SetNumberField(TEXT("p50Ms"), MCPTraceAnalysisPercentile(Values, 0.50));
|
|
148
|
+
Out->SetNumberField(TEXT("p95Ms"), MCPTraceAnalysisPercentile(Values, 0.95));
|
|
149
|
+
Out->SetNumberField(TEXT("p99Ms"), MCPTraceAnalysisPercentile(Values, 0.99));
|
|
150
|
+
Out->SetNumberField(TEXT("minMs"), Values.Num() > 0 ? Values[0] : 0.0);
|
|
151
|
+
Out->SetNumberField(TEXT("maxMs"), Values.Num() > 0 ? Values.Last() : 0.0);
|
|
152
|
+
return Out;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
struct FMCPTraceAnalysisFrame
|
|
156
|
+
{
|
|
157
|
+
uint64 Index = 0;
|
|
158
|
+
double Start = 0.0;
|
|
159
|
+
double End = 0.0;
|
|
160
|
+
double Ms = 0.0;
|
|
161
|
+
};
|
|
162
|
+
|
|
163
|
+
struct FMCPTraceAnalysisTimerRow
|
|
164
|
+
{
|
|
165
|
+
FString Name;
|
|
166
|
+
const TCHAR* Type = TEXT("cpu");
|
|
167
|
+
uint64 Count = 0;
|
|
168
|
+
double InclusiveMs = 0.0;
|
|
169
|
+
double ExclusiveMs = 0.0;
|
|
170
|
+
double MaxInclusiveMs = 0.0;
|
|
171
|
+
double AvgInclusiveMs = 0.0;
|
|
172
|
+
};
|
|
173
|
+
|
|
174
|
+
const TCHAR* MCPTraceAnalysisTimerTypeName(const TraceServices::FTimingProfilerTimer* Timer)
|
|
175
|
+
{
|
|
176
|
+
if (!Timer) return TEXT("unknown");
|
|
177
|
+
switch (Timer->Type)
|
|
178
|
+
{
|
|
179
|
+
case TraceServices::ETimingProfilerTimerType::CpuScope: return TEXT("cpu");
|
|
180
|
+
case TraceServices::ETimingProfilerTimerType::CpuSampling: return TEXT("cpuSampling");
|
|
181
|
+
case TraceServices::ETimingProfilerTimerType::GpuScope: return TEXT("gpu");
|
|
182
|
+
case TraceServices::ETimingProfilerTimerType::VerseSampling: return TEXT("verse");
|
|
183
|
+
default: return TEXT("unknown");
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
/** One aggregation over [Start, End], CPU timelines only. ThreadId unset
|
|
188
|
+
* means every CPU thread; set, only that one. Rows come back unsorted:
|
|
189
|
+
* the caller sorts by the column it reports, because the engine's own
|
|
190
|
+
* sort only knows inclusive time and the per-frame view wants exclusive. */
|
|
191
|
+
TArray<FMCPTraceAnalysisTimerRow> MCPTraceAnalysisAggregate(
|
|
192
|
+
const TraceServices::ITimingProfilerProvider& Timing, double Start, double End, TOptional<uint32> ThreadId)
|
|
193
|
+
{
|
|
194
|
+
TArray<FMCPTraceAnalysisTimerRow> Rows;
|
|
195
|
+
|
|
196
|
+
TraceServices::FCreateAggregationParams Params;
|
|
197
|
+
Params.IntervalStart = Start;
|
|
198
|
+
Params.IntervalEnd = End;
|
|
199
|
+
if (ThreadId.IsSet())
|
|
200
|
+
{
|
|
201
|
+
const uint32 Wanted = ThreadId.GetValue();
|
|
202
|
+
Params.CpuThreadFilter = [Wanted](uint32 Id) { return Id == Wanted; };
|
|
203
|
+
}
|
|
204
|
+
else
|
|
205
|
+
{
|
|
206
|
+
Params.CpuThreadFilter = [](uint32) { return true; };
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
TUniquePtr<TraceServices::ITable<TraceServices::FTimingProfilerAggregatedStats>> Table(Timing.CreateAggregation(Params));
|
|
210
|
+
if (!Table.IsValid()) return Rows;
|
|
211
|
+
|
|
212
|
+
TUniquePtr<TraceServices::ITableReader<TraceServices::FTimingProfilerAggregatedStats>> Reader(Table->CreateReader());
|
|
213
|
+
if (!Reader.IsValid()) return Rows;
|
|
214
|
+
|
|
215
|
+
for (; Reader->IsValid(); Reader->NextRow())
|
|
216
|
+
{
|
|
217
|
+
const TraceServices::FTimingProfilerAggregatedStats* Stats = Reader->GetCurrentRow();
|
|
218
|
+
if (!Stats || Stats->InstanceCount == 0) continue;
|
|
219
|
+
FMCPTraceAnalysisTimerRow Row;
|
|
220
|
+
Row.Name = (Stats->Timer && Stats->Timer->Name) ? FString(Stats->Timer->Name) : FString(TEXT("<unnamed>"));
|
|
221
|
+
Row.Type = MCPTraceAnalysisTimerTypeName(Stats->Timer);
|
|
222
|
+
Row.Count = Stats->InstanceCount;
|
|
223
|
+
Row.InclusiveMs = Stats->TotalInclusiveTime * 1000.0;
|
|
224
|
+
Row.ExclusiveMs = Stats->TotalExclusiveTime * 1000.0;
|
|
225
|
+
Row.MaxInclusiveMs = Stats->MaxInclusiveTime > 0.0 ? Stats->MaxInclusiveTime * 1000.0 : 0.0;
|
|
226
|
+
Row.AvgInclusiveMs = Stats->AverageInclusiveTime * 1000.0;
|
|
227
|
+
Rows.Add(MoveTemp(Row));
|
|
228
|
+
}
|
|
229
|
+
return Rows;
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
void MCPTraceAnalysisSortRows(TArray<FMCPTraceAnalysisTimerRow>& Rows, bool bExclusive)
|
|
233
|
+
{
|
|
234
|
+
Rows.Sort([bExclusive](const FMCPTraceAnalysisTimerRow& A, const FMCPTraceAnalysisTimerRow& B)
|
|
235
|
+
{
|
|
236
|
+
const double KeyA = bExclusive ? A.ExclusiveMs : A.InclusiveMs;
|
|
237
|
+
const double KeyB = bExclusive ? B.ExclusiveMs : B.InclusiveMs;
|
|
238
|
+
if (KeyA != KeyB) return KeyA > KeyB;
|
|
239
|
+
return A.Name < B.Name;
|
|
240
|
+
});
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
TArray<TSharedPtr<FJsonValue>> MCPTraceAnalysisTimerRowsToJson(
|
|
244
|
+
const TArray<FMCPTraceAnalysisTimerRow>& Rows, int32 Limit, int32 FrameCount)
|
|
245
|
+
{
|
|
246
|
+
TArray<TSharedPtr<FJsonValue>> Out;
|
|
247
|
+
for (int32 i = 0; i < Rows.Num() && i < Limit; ++i)
|
|
248
|
+
{
|
|
249
|
+
const FMCPTraceAnalysisTimerRow& Row = Rows[i];
|
|
250
|
+
TSharedPtr<FJsonObject> Obj = MakeShared<FJsonObject>();
|
|
251
|
+
Obj->SetStringField(TEXT("name"), Row.Name);
|
|
252
|
+
Obj->SetStringField(TEXT("type"), Row.Type);
|
|
253
|
+
Obj->SetNumberField(TEXT("count"), static_cast<double>(Row.Count));
|
|
254
|
+
Obj->SetNumberField(TEXT("inclusiveMs"), Row.InclusiveMs);
|
|
255
|
+
Obj->SetNumberField(TEXT("exclusiveMs"), Row.ExclusiveMs);
|
|
256
|
+
Obj->SetNumberField(TEXT("maxInclusiveMs"), Row.MaxInclusiveMs);
|
|
257
|
+
Obj->SetNumberField(TEXT("avgInclusiveMs"), Row.AvgInclusiveMs);
|
|
258
|
+
if (FrameCount > 0)
|
|
259
|
+
{
|
|
260
|
+
Obj->SetNumberField(TEXT("inclusiveMsPerFrame"), Row.InclusiveMs / FrameCount);
|
|
261
|
+
Obj->SetNumberField(TEXT("exclusiveMsPerFrame"), Row.ExclusiveMs / FrameCount);
|
|
262
|
+
}
|
|
263
|
+
Out.Add(MakeShared<FJsonValueObject>(Obj));
|
|
264
|
+
}
|
|
265
|
+
return Out;
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
/** GPU busy time per frame: for every GPU timeline the trace carries, the
|
|
269
|
+
* depth-0 scopes are summed into the frames they overlap, and a frame's
|
|
270
|
+
* figure is the busiest single timeline (queues run in parallel, so
|
|
271
|
+
* adding them would count overlapping work twice). It approximates GPU
|
|
272
|
+
* frame time from the scopes the RHI emitted; work outside any scope is
|
|
273
|
+
* not counted, which the result says. */
|
|
274
|
+
bool MCPTraceAnalysisGpuPerFrame(
|
|
275
|
+
const TraceServices::ITimingProfilerProvider& Timing,
|
|
276
|
+
const TArray<FMCPTraceAnalysisFrame>& Frames,
|
|
277
|
+
TArray<double>& OutPerFrameMs,
|
|
278
|
+
int32& OutTimelineCount)
|
|
279
|
+
{
|
|
280
|
+
OutPerFrameMs.Init(0.0, Frames.Num());
|
|
281
|
+
OutTimelineCount = 0;
|
|
282
|
+
if (Frames.Num() == 0) return false;
|
|
283
|
+
|
|
284
|
+
TArray<uint32> TimelineIndices;
|
|
285
|
+
uint32 Index = 0;
|
|
286
|
+
if (Timing.GetGpuTimelineIndex(Index)) TimelineIndices.AddUnique(Index);
|
|
287
|
+
if (Timing.GetGpu2TimelineIndex(Index)) TimelineIndices.AddUnique(Index);
|
|
288
|
+
Timing.EnumerateGpuQueues([&TimelineIndices](const TraceServices::FGpuQueueInfo& Queue)
|
|
289
|
+
{
|
|
290
|
+
if (Queue.TimelineIndex != ~0u) TimelineIndices.AddUnique(Queue.TimelineIndex);
|
|
291
|
+
});
|
|
292
|
+
|
|
293
|
+
const double WindowStart = Frames[0].Start;
|
|
294
|
+
const double WindowEnd = Frames.Last().End;
|
|
295
|
+
bool bAnyEvent = false;
|
|
296
|
+
|
|
297
|
+
for (const uint32 TimelineIndex : TimelineIndices)
|
|
298
|
+
{
|
|
299
|
+
TArray<double> Busy;
|
|
300
|
+
Busy.Init(0.0, Frames.Num());
|
|
301
|
+
bool bTimelineHasEvents = false;
|
|
302
|
+
|
|
303
|
+
Timing.ReadTimeline(TimelineIndex, [&](const TraceServices::ITimingProfilerProvider::Timeline& Timeline)
|
|
304
|
+
{
|
|
305
|
+
Timeline.EnumerateEvents(WindowStart, WindowEnd,
|
|
306
|
+
[&](double EventStart, double EventEnd, uint32 Depth, const TraceServices::FTimingProfilerEvent&) -> TraceServices::EEventEnumerate
|
|
307
|
+
{
|
|
308
|
+
if (Depth != 0 || EventEnd <= EventStart) return TraceServices::EEventEnumerate::Continue;
|
|
309
|
+
bTimelineHasEvents = true;
|
|
310
|
+
// First frame that ends after this event starts.
|
|
311
|
+
int32 Lo = 0;
|
|
312
|
+
int32 Hi = Frames.Num();
|
|
313
|
+
while (Lo < Hi)
|
|
314
|
+
{
|
|
315
|
+
const int32 Mid = (Lo + Hi) / 2;
|
|
316
|
+
if (Frames[Mid].End <= EventStart) Lo = Mid + 1; else Hi = Mid;
|
|
317
|
+
}
|
|
318
|
+
for (int32 F = Lo; F < Frames.Num() && Frames[F].Start < EventEnd; ++F)
|
|
319
|
+
{
|
|
320
|
+
const double Overlap = FMath::Min(EventEnd, Frames[F].End) - FMath::Max(EventStart, Frames[F].Start);
|
|
321
|
+
if (Overlap > 0.0) Busy[F] += Overlap * 1000.0;
|
|
322
|
+
}
|
|
323
|
+
return TraceServices::EEventEnumerate::Continue;
|
|
324
|
+
});
|
|
325
|
+
});
|
|
326
|
+
|
|
327
|
+
if (!bTimelineHasEvents) continue;
|
|
328
|
+
bAnyEvent = true;
|
|
329
|
+
++OutTimelineCount;
|
|
330
|
+
for (int32 F = 0; F < Frames.Num(); ++F)
|
|
331
|
+
{
|
|
332
|
+
OutPerFrameMs[F] = FMath::Max(OutPerFrameMs[F], Busy[F]);
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
return bAnyEvent;
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
/** The whole summary. Called inside FAnalysisSessionReadScope on a
|
|
339
|
+
* completed session. Returns an error string on a request the trace
|
|
340
|
+
* cannot answer, or empty with OutResult filled. */
|
|
341
|
+
FString MCPTraceAnalysisSummarise(
|
|
342
|
+
const TraceServices::IAnalysisSession& Session,
|
|
343
|
+
const FMCPTraceAnalysisRequest& Request,
|
|
344
|
+
TSharedPtr<FJsonObject>& OutResult)
|
|
345
|
+
{
|
|
346
|
+
TArray<FString> Warnings;
|
|
347
|
+
const double Duration = Session.GetDurationSeconds();
|
|
348
|
+
const double WindowStart = FMath::Max(0.0, Request.WindowStart);
|
|
349
|
+
const double WindowEnd = Request.WindowEnd < 0.0 ? Duration : FMath::Min(Request.WindowEnd, Duration);
|
|
350
|
+
if (WindowEnd <= WindowStart)
|
|
351
|
+
{
|
|
352
|
+
return FString::Printf(
|
|
353
|
+
TEXT("The time window [%.3f, %.3f] s holds nothing: the trace lasts %.3f s. Pass startSeconds below endSeconds, inside the trace."),
|
|
354
|
+
WindowStart, WindowEnd, Duration);
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
const ETraceFrameType FrameType = Request.bRenderingFrames ? TraceFrameType_Rendering : TraceFrameType_Game;
|
|
358
|
+
const TraceServices::IFrameProvider& FrameProvider = TraceServices::ReadFrameProvider(Session);
|
|
359
|
+
const uint64 FramesInTrace = FrameProvider.GetFrameCount(FrameType);
|
|
360
|
+
|
|
361
|
+
// Whole frames inside the window only. A frame cut by the window edge
|
|
362
|
+
// would report a duration it did not have, and the last frame of a
|
|
363
|
+
// trace often never ended.
|
|
364
|
+
TArray<FMCPTraceAnalysisFrame> Frames;
|
|
365
|
+
FrameProvider.EnumerateFrames(FrameType, WindowStart, WindowEnd, [&](const TraceServices::FFrame& Frame)
|
|
366
|
+
{
|
|
367
|
+
if (Frame.StartTime < WindowStart || Frame.EndTime > WindowEnd) return;
|
|
368
|
+
if (!(Frame.EndTime > Frame.StartTime) || Frame.EndTime >= Duration + 1.0) return;
|
|
369
|
+
FMCPTraceAnalysisFrame Row;
|
|
370
|
+
Row.Index = Frame.Index;
|
|
371
|
+
Row.Start = Frame.StartTime;
|
|
372
|
+
Row.End = Frame.EndTime;
|
|
373
|
+
Row.Ms = (Frame.EndTime - Frame.StartTime) * 1000.0;
|
|
374
|
+
Frames.Add(Row);
|
|
375
|
+
});
|
|
376
|
+
Frames.Sort([](const FMCPTraceAnalysisFrame& A, const FMCPTraceAnalysisFrame& B) { return A.Start < B.Start; });
|
|
377
|
+
|
|
378
|
+
TSharedPtr<FJsonObject> Result = MCPSuccess();
|
|
379
|
+
Result->SetNumberField(TEXT("sessionDurationSeconds"), Duration);
|
|
380
|
+
TSharedPtr<FJsonObject> Window = MakeShared<FJsonObject>();
|
|
381
|
+
Window->SetNumberField(TEXT("startSeconds"), WindowStart);
|
|
382
|
+
Window->SetNumberField(TEXT("endSeconds"), WindowEnd);
|
|
383
|
+
Window->SetBoolField(TEXT("wholeTrace"), Request.WindowStart <= 0.0 && Request.WindowEnd < 0.0);
|
|
384
|
+
Result->SetObjectField(TEXT("window"), Window);
|
|
385
|
+
|
|
386
|
+
// ── Frames ──────────────────────────────────────────────────────────
|
|
387
|
+
TArray<double> FrameMs;
|
|
388
|
+
FrameMs.Reserve(Frames.Num());
|
|
389
|
+
double TotalMs = 0.0;
|
|
390
|
+
for (const FMCPTraceAnalysisFrame& Frame : Frames)
|
|
391
|
+
{
|
|
392
|
+
FrameMs.Add(Frame.Ms);
|
|
393
|
+
TotalMs += Frame.Ms;
|
|
394
|
+
}
|
|
395
|
+
TSharedPtr<FJsonObject> FramesObj = MCPTraceAnalysisDistribution(FrameMs);
|
|
396
|
+
FramesObj->SetStringField(TEXT("frameType"), Request.bRenderingFrames ? TEXT("rendering") : TEXT("game"));
|
|
397
|
+
FramesObj->SetNumberField(TEXT("framesInTrace"), static_cast<double>(FramesInTrace));
|
|
398
|
+
FramesObj->SetNumberField(TEXT("avgFps"), TotalMs > 0.0 ? Frames.Num() * 1000.0 / TotalMs : 0.0);
|
|
399
|
+
Result->SetObjectField(TEXT("frames"), FramesObj);
|
|
400
|
+
if (FramesInTrace == 0)
|
|
401
|
+
{
|
|
402
|
+
Warnings.Add(TEXT("The trace has no frame events. Record with the 'frame' channel on (the 'default' preset includes it)."));
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
// ── Hitches ─────────────────────────────────────────────────────────
|
|
406
|
+
{
|
|
407
|
+
TArray<TSharedPtr<FJsonValue>> List;
|
|
408
|
+
int32 Count = 0;
|
|
409
|
+
double HitchTotalMs = 0.0;
|
|
410
|
+
for (const FMCPTraceAnalysisFrame& Frame : Frames)
|
|
411
|
+
{
|
|
412
|
+
if (Frame.Ms < Request.HitchThresholdMs) continue;
|
|
413
|
+
++Count;
|
|
414
|
+
HitchTotalMs += Frame.Ms;
|
|
415
|
+
if (List.Num() >= Request.MaxHitches) continue;
|
|
416
|
+
TSharedPtr<FJsonObject> Row = MakeShared<FJsonObject>();
|
|
417
|
+
Row->SetNumberField(TEXT("frameIndex"), static_cast<double>(Frame.Index));
|
|
418
|
+
Row->SetNumberField(TEXT("startSeconds"), Frame.Start);
|
|
419
|
+
Row->SetNumberField(TEXT("durationMs"), Frame.Ms);
|
|
420
|
+
List.Add(MakeShared<FJsonValueObject>(Row));
|
|
421
|
+
}
|
|
422
|
+
TSharedPtr<FJsonObject> Hitches = MakeShared<FJsonObject>();
|
|
423
|
+
Hitches->SetNumberField(TEXT("thresholdMs"), Request.HitchThresholdMs);
|
|
424
|
+
Hitches->SetNumberField(TEXT("count"), Count);
|
|
425
|
+
Hitches->SetNumberField(TEXT("totalMs"), HitchTotalMs);
|
|
426
|
+
Hitches->SetArrayField(TEXT("list"), List);
|
|
427
|
+
Hitches->SetBoolField(TEXT("truncated"), List.Num() < Count);
|
|
428
|
+
Result->SetObjectField(TEXT("hitches"), Hitches);
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
// ── Threads ─────────────────────────────────────────────────────────
|
|
432
|
+
TOptional<uint32> GameThreadId;
|
|
433
|
+
{
|
|
434
|
+
const TraceServices::IThreadProvider& Threads = TraceServices::ReadThreadProvider(Session);
|
|
435
|
+
Threads.EnumerateThreads([&GameThreadId](const TraceServices::FThreadInfo& Info)
|
|
436
|
+
{
|
|
437
|
+
if (!GameThreadId.IsSet() && Info.Name && FCString::Stricmp(Info.Name, TEXT("GameThread")) == 0)
|
|
438
|
+
{
|
|
439
|
+
GameThreadId = Info.Id;
|
|
440
|
+
}
|
|
441
|
+
});
|
|
442
|
+
}
|
|
443
|
+
TOptional<uint32> TimerThread = Request.bAllThreads ? TOptional<uint32>() : GameThreadId;
|
|
444
|
+
FString ThreadScope = Request.bAllThreads ? TEXT("all") : TEXT("game");
|
|
445
|
+
if (!Request.bAllThreads && !GameThreadId.IsSet())
|
|
446
|
+
{
|
|
447
|
+
ThreadScope = TEXT("all");
|
|
448
|
+
Warnings.Add(TEXT("No thread named GameThread is in the trace, so timers are aggregated over every CPU thread."));
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
// ── Timers: worst frames and the window ─────────────────────────────
|
|
452
|
+
const TraceServices::ITimingProfilerProvider* Timing = TraceServices::ReadTimingProfilerProvider(Session);
|
|
453
|
+
TArray<TSharedPtr<FJsonValue>> WorstJson;
|
|
454
|
+
{
|
|
455
|
+
TArray<FMCPTraceAnalysisFrame> Worst = Frames;
|
|
456
|
+
Worst.Sort([](const FMCPTraceAnalysisFrame& A, const FMCPTraceAnalysisFrame& B) { return A.Ms > B.Ms; });
|
|
457
|
+
for (int32 i = 0; i < Worst.Num() && i < Request.WorstFrames; ++i)
|
|
458
|
+
{
|
|
459
|
+
const FMCPTraceAnalysisFrame& Frame = Worst[i];
|
|
460
|
+
TSharedPtr<FJsonObject> Row = MakeShared<FJsonObject>();
|
|
461
|
+
Row->SetNumberField(TEXT("frameIndex"), static_cast<double>(Frame.Index));
|
|
462
|
+
Row->SetNumberField(TEXT("startSeconds"), Frame.Start);
|
|
463
|
+
Row->SetNumberField(TEXT("durationMs"), Frame.Ms);
|
|
464
|
+
if (Timing && Request.TimersPerFrame > 0)
|
|
465
|
+
{
|
|
466
|
+
TArray<FMCPTraceAnalysisTimerRow> Rows = MCPTraceAnalysisAggregate(*Timing, Frame.Start, Frame.End, TimerThread);
|
|
467
|
+
// Exclusive time names where the frame went; inclusive time
|
|
468
|
+
// would list the call-stack spine (the engine tick and its
|
|
469
|
+
// parents) first in every frame.
|
|
470
|
+
MCPTraceAnalysisSortRows(Rows, /*bExclusive=*/true);
|
|
471
|
+
Row->SetArrayField(TEXT("topTimers"), MCPTraceAnalysisTimerRowsToJson(Rows, Request.TimersPerFrame, 0));
|
|
472
|
+
}
|
|
473
|
+
WorstJson.Add(MakeShared<FJsonValueObject>(Row));
|
|
474
|
+
}
|
|
475
|
+
}
|
|
476
|
+
Result->SetArrayField(TEXT("worstFrames"), WorstJson);
|
|
477
|
+
|
|
478
|
+
TSharedPtr<FJsonObject> TopTimers = MakeShared<FJsonObject>();
|
|
479
|
+
TopTimers->SetStringField(TEXT("threads"), ThreadScope);
|
|
480
|
+
TopTimers->SetStringField(TEXT("sortedBy"), Request.bSortExclusive ? TEXT("exclusive") : TEXT("inclusive"));
|
|
481
|
+
if (Timing)
|
|
482
|
+
{
|
|
483
|
+
TArray<FMCPTraceAnalysisTimerRow> Rows = MCPTraceAnalysisAggregate(*Timing, WindowStart, WindowEnd, TimerThread);
|
|
484
|
+
MCPTraceAnalysisSortRows(Rows, Request.bSortExclusive);
|
|
485
|
+
TopTimers->SetNumberField(TEXT("distinctTimers"), Rows.Num());
|
|
486
|
+
TopTimers->SetArrayField(TEXT("rows"), MCPTraceAnalysisTimerRowsToJson(Rows, Request.TopTimers, Frames.Num()));
|
|
487
|
+
TopTimers->SetBoolField(TEXT("truncated"), Rows.Num() > Request.TopTimers);
|
|
488
|
+
if (Rows.Num() == 0)
|
|
489
|
+
{
|
|
490
|
+
Warnings.Add(TEXT("No CPU timer events in the window. Record with the 'cpu' channel on (the 'default' preset includes it)."));
|
|
491
|
+
}
|
|
492
|
+
}
|
|
493
|
+
else
|
|
494
|
+
{
|
|
495
|
+
TopTimers->SetNumberField(TEXT("distinctTimers"), 0);
|
|
496
|
+
TopTimers->SetArrayField(TEXT("rows"), TArray<TSharedPtr<FJsonValue>>());
|
|
497
|
+
TopTimers->SetBoolField(TEXT("truncated"), false);
|
|
498
|
+
Warnings.Add(TEXT("The trace has no timing-profiler data. Record with the 'cpu' channel on (the 'default' preset includes it)."));
|
|
499
|
+
}
|
|
500
|
+
Result->SetObjectField(TEXT("topTimers"), TopTimers);
|
|
501
|
+
|
|
502
|
+
// ── GPU ─────────────────────────────────────────────────────────────
|
|
503
|
+
{
|
|
504
|
+
TSharedPtr<FJsonObject> Gpu = MakeShared<FJsonObject>();
|
|
505
|
+
TArray<double> PerFrame;
|
|
506
|
+
int32 TimelineCount = 0;
|
|
507
|
+
const bool bPresent = Timing && MCPTraceAnalysisGpuPerFrame(*Timing, Frames, PerFrame, TimelineCount);
|
|
508
|
+
Gpu->SetBoolField(TEXT("present"), bPresent);
|
|
509
|
+
if (bPresent)
|
|
510
|
+
{
|
|
511
|
+
TArray<double> Measured;
|
|
512
|
+
for (double Ms : PerFrame) if (Ms > 0.0) Measured.Add(Ms);
|
|
513
|
+
TSharedPtr<FJsonObject> Dist = MCPTraceAnalysisDistribution(Measured);
|
|
514
|
+
Gpu->SetObjectField(TEXT("busyMsPerFrame"), Dist);
|
|
515
|
+
Gpu->SetNumberField(TEXT("framesWithGpuWork"), Measured.Num());
|
|
516
|
+
Gpu->SetNumberField(TEXT("timelines"), TimelineCount);
|
|
517
|
+
Gpu->SetStringField(TEXT("method"),
|
|
518
|
+
TEXT("Per game frame, the time covered by top-level GPU scopes on the busiest GPU timeline. It approximates GPU frame time; GPU work outside any scope is not counted."));
|
|
519
|
+
}
|
|
520
|
+
else
|
|
521
|
+
{
|
|
522
|
+
Gpu->SetStringField(TEXT("reason"),
|
|
523
|
+
TEXT("The trace carries no GPU timing events. Record with the 'gpu' channel on, from an editor with a real RHI (a -nullrhi editor emits none)."));
|
|
524
|
+
}
|
|
525
|
+
Result->SetObjectField(TEXT("gpu"), Gpu);
|
|
526
|
+
}
|
|
527
|
+
|
|
528
|
+
// ── Bookmarks ───────────────────────────────────────────────────────
|
|
529
|
+
{
|
|
530
|
+
const TraceServices::IBookmarkProvider& Bookmarks = TraceServices::ReadBookmarkProvider(Session);
|
|
531
|
+
TArray<TSharedPtr<FJsonValue>> List;
|
|
532
|
+
int32 Count = 0;
|
|
533
|
+
Bookmarks.EnumerateBookmarks(WindowStart, WindowEnd, [&](const TraceServices::FBookmark& Bookmark)
|
|
534
|
+
{
|
|
535
|
+
++Count;
|
|
536
|
+
if (List.Num() >= Request.MaxBookmarks) return;
|
|
537
|
+
TSharedPtr<FJsonObject> Row = MakeShared<FJsonObject>();
|
|
538
|
+
Row->SetNumberField(TEXT("timeSeconds"), Bookmark.Time);
|
|
539
|
+
Row->SetStringField(TEXT("text"), Bookmark.Text ? FString(Bookmark.Text) : FString());
|
|
540
|
+
Row->SetNumberField(TEXT("frameIndex"),
|
|
541
|
+
static_cast<double>(FrameProvider.GetFrameNumberForTimestamp(FrameType, Bookmark.Time)));
|
|
542
|
+
List.Add(MakeShared<FJsonValueObject>(Row));
|
|
543
|
+
});
|
|
544
|
+
TSharedPtr<FJsonObject> BookmarksObj = MakeShared<FJsonObject>();
|
|
545
|
+
BookmarksObj->SetNumberField(TEXT("count"), Count);
|
|
546
|
+
BookmarksObj->SetNumberField(TEXT("countInTrace"), static_cast<double>(Bookmarks.GetBookmarkCount()));
|
|
547
|
+
BookmarksObj->SetArrayField(TEXT("list"), List);
|
|
548
|
+
BookmarksObj->SetBoolField(TEXT("truncated"), List.Num() < Count);
|
|
549
|
+
Result->SetObjectField(TEXT("bookmarks"), BookmarksObj);
|
|
550
|
+
}
|
|
551
|
+
|
|
552
|
+
Result->SetArrayField(TEXT("warnings"), MCPStringListToJson(Warnings));
|
|
553
|
+
OutResult = Result;
|
|
554
|
+
return FString();
|
|
555
|
+
}
|
|
556
|
+
|
|
557
|
+
/** Write the full result to disk and turn the response into a pointer to
|
|
558
|
+
* it, keeping the headline numbers inline. Game thread. */
|
|
559
|
+
TSharedPtr<FJsonValue> MCPTraceAnalysisFinish(TSharedPtr<FJsonObject> Result, const FMCPTraceAnalysisRequest& Request)
|
|
560
|
+
{
|
|
561
|
+
if (!Request.bDumpToFile)
|
|
562
|
+
{
|
|
563
|
+
return MCPResult(Result);
|
|
564
|
+
}
|
|
565
|
+
const FString DefaultPath = FPaths::Combine(FPaths::ProjectSavedDir(), TEXT("UE_MCP"), TEXT("TraceAnalysis"),
|
|
566
|
+
FPaths::GetBaseFilename(Request.File) + TEXT(".analysis.json"));
|
|
567
|
+
const FString Target = MCPResolveDumpPath(Request.OutputPath.IsEmpty() ? DefaultPath : Request.OutputPath);
|
|
568
|
+
|
|
569
|
+
FString JsonText;
|
|
570
|
+
const TSharedRef<TJsonWriter<>> Writer = TJsonWriterFactory<>::Create(&JsonText);
|
|
571
|
+
if (!FJsonSerializer::Serialize(Result.ToSharedRef(), Writer))
|
|
572
|
+
{
|
|
573
|
+
return MCPError(TEXT("Failed to serialise the trace analysis to JSON."));
|
|
574
|
+
}
|
|
575
|
+
FString Error;
|
|
576
|
+
if (!MCPWriteDumpFile(Target, JsonText, TEXT("trace analysis"), Error))
|
|
577
|
+
{
|
|
578
|
+
return MCPError(Error);
|
|
579
|
+
}
|
|
580
|
+
|
|
581
|
+
TSharedPtr<FJsonObject> Short = MCPSuccess();
|
|
582
|
+
Short->SetBoolField(TEXT("dumpedToFile"), true);
|
|
583
|
+
Short->SetStringField(TEXT("outputPath"), FPaths::ConvertRelativePathToFull(Target));
|
|
584
|
+
for (const TCHAR* Key : { TEXT("traceFile"), TEXT("traceFileBytes"), TEXT("analysisSeconds"),
|
|
585
|
+
TEXT("sessionDurationSeconds"), TEXT("window"), TEXT("frames"), TEXT("gpu"), TEXT("warnings") })
|
|
586
|
+
{
|
|
587
|
+
if (const TSharedPtr<FJsonValue> Value = Result->TryGetField(Key)) Short->SetField(Key, Value);
|
|
588
|
+
}
|
|
589
|
+
const TSharedPtr<FJsonObject>* Hitches = nullptr;
|
|
590
|
+
if (Result->TryGetObjectField(TEXT("hitches"), Hitches) && Hitches)
|
|
591
|
+
{
|
|
592
|
+
Short->SetNumberField(TEXT("hitchCount"), (*Hitches)->GetNumberField(TEXT("count")));
|
|
593
|
+
}
|
|
594
|
+
const TSharedPtr<FJsonObject>* Bookmarks = nullptr;
|
|
595
|
+
if (Result->TryGetObjectField(TEXT("bookmarks"), Bookmarks) && Bookmarks)
|
|
596
|
+
{
|
|
597
|
+
Short->SetNumberField(TEXT("bookmarkCount"), (*Bookmarks)->GetNumberField(TEXT("count")));
|
|
598
|
+
}
|
|
599
|
+
return MCPResult(Short);
|
|
600
|
+
}
|
|
601
|
+
|
|
602
|
+
void MCPTraceAnalysisStamp(TSharedPtr<FJsonObject> Result, const FMCPTraceAnalysisRequest& Request, double WallStart)
|
|
603
|
+
{
|
|
604
|
+
Result->SetStringField(TEXT("traceFile"), Request.File);
|
|
605
|
+
Result->SetNumberField(TEXT("traceFileBytes"), static_cast<double>(IFileManager::Get().FileSize(*Request.File)));
|
|
606
|
+
Result->SetNumberField(TEXT("analysisSeconds"), FPlatformTime::Seconds() - WallStart);
|
|
607
|
+
}
|
|
608
|
+
|
|
609
|
+
/** State the pool task and the cancel hook share. */
|
|
610
|
+
struct FMCPTraceAnalysisJob
|
|
611
|
+
{
|
|
612
|
+
TSharedPtr<const TraceServices::IAnalysisSession> Session;
|
|
613
|
+
};
|
|
614
|
+
#endif // UE_MCP_HAS_5_7_API
|
|
615
|
+
}
|
|
616
|
+
|
|
617
|
+
// ---------------------------------------------------------------------------
|
|
618
|
+
// analyze_insights_trace -- summarise a recorded .utrace.
|
|
619
|
+
// ---------------------------------------------------------------------------
|
|
620
|
+
TSharedPtr<FJsonValue> FEditorHandlers::AnalyzeInsightsTrace(const TSharedPtr<FJsonObject>& Params)
|
|
621
|
+
{
|
|
622
|
+
MCP_CHECK_GAME_THREAD();
|
|
623
|
+
|
|
624
|
+
FMCPTraceAnalysisRequest Request;
|
|
625
|
+
FString Requested = OptionalString(Params, TEXT("file"));
|
|
626
|
+
Requested.TrimStartAndEndInline();
|
|
627
|
+
Request.WindowStart = OptionalNumber(Params, TEXT("startSeconds"), 0.0);
|
|
628
|
+
Request.WindowEnd = OptionalNumber(Params, TEXT("endSeconds"), -1.0);
|
|
629
|
+
Request.HitchThresholdMs = FMath::Max(0.1, OptionalNumber(Params, TEXT("hitchThresholdMs"), 50.0));
|
|
630
|
+
Request.WorstFrames = FMath::Clamp(OptionalInt(Params, TEXT("worstFrames"), 10), 0, 50);
|
|
631
|
+
Request.TopTimers = FMath::Clamp(OptionalInt(Params, TEXT("topTimers"), 20), 0, 200);
|
|
632
|
+
Request.TimersPerFrame = FMath::Clamp(OptionalInt(Params, TEXT("timersPerFrame"), 5), 0, 20);
|
|
633
|
+
Request.MaxHitches = FMath::Clamp(OptionalInt(Params, TEXT("maxHitches"), 50), 0, 500);
|
|
634
|
+
Request.MaxBookmarks = FMath::Clamp(OptionalInt(Params, TEXT("maxBookmarks"), 100), 0, 1000);
|
|
635
|
+
const FString Threads = OptionalString(Params, TEXT("threads"), TEXT("game")).ToLower();
|
|
636
|
+
const FString TimerSort = OptionalString(Params, TEXT("timerSort"), TEXT("inclusive")).ToLower();
|
|
637
|
+
const FString FrameType = OptionalString(Params, TEXT("frameType"), TEXT("game")).ToLower();
|
|
638
|
+
Request.bDumpToFile = OptionalBool(Params, TEXT("dumpToFile"), false);
|
|
639
|
+
Request.OutputPath = OptionalString(Params, TEXT("outputPath"));
|
|
640
|
+
|
|
641
|
+
if (Threads != TEXT("game") && Threads != TEXT("all"))
|
|
642
|
+
{
|
|
643
|
+
return MCPError(FString::Printf(TEXT("Unknown threads '%s'. Use game (the game thread only, the default) or all (every CPU thread)."), *Threads));
|
|
644
|
+
}
|
|
645
|
+
if (TimerSort != TEXT("inclusive") && TimerSort != TEXT("exclusive"))
|
|
646
|
+
{
|
|
647
|
+
return MCPError(FString::Printf(TEXT("Unknown timerSort '%s'. Use inclusive (the default) or exclusive."), *TimerSort));
|
|
648
|
+
}
|
|
649
|
+
if (FrameType != TEXT("game") && FrameType != TEXT("rendering"))
|
|
650
|
+
{
|
|
651
|
+
return MCPError(FString::Printf(TEXT("Unknown frameType '%s'. Use game (the default) or rendering."), *FrameType));
|
|
652
|
+
}
|
|
653
|
+
if (!Request.OutputPath.IsEmpty() && !Request.bDumpToFile)
|
|
654
|
+
{
|
|
655
|
+
return MCPError(TEXT("outputPath needs dumpToFile=true."));
|
|
656
|
+
}
|
|
657
|
+
if (Request.WindowEnd >= 0.0 && Request.WindowEnd <= Request.WindowStart)
|
|
658
|
+
{
|
|
659
|
+
return MCPError(TEXT("endSeconds must be greater than startSeconds."));
|
|
660
|
+
}
|
|
661
|
+
Request.bAllThreads = Threads == TEXT("all");
|
|
662
|
+
Request.bSortExclusive = TimerSort == TEXT("exclusive");
|
|
663
|
+
Request.bRenderingFrames = FrameType == TEXT("rendering");
|
|
664
|
+
|
|
665
|
+
Request.File = Requested.IsEmpty() ? MCPTraceAnalysisNewestTrace() : MCPTraceAnalysisResolveFile(Requested);
|
|
666
|
+
if (Request.File.IsEmpty())
|
|
667
|
+
{
|
|
668
|
+
return MCPError(TEXT("No file was given and no .utrace is under <Project>/Saved/Profiling. Record one with editor(start_trace) and editor(stop_trace), or pass file."));
|
|
669
|
+
}
|
|
670
|
+
if (!FPaths::FileExists(Request.File))
|
|
671
|
+
{
|
|
672
|
+
return MCPError(FString::Printf(TEXT("Trace file not found: %s"), *Request.File));
|
|
673
|
+
}
|
|
674
|
+
if (!Request.File.EndsWith(TEXT(".utrace"), ESearchCase::IgnoreCase))
|
|
675
|
+
{
|
|
676
|
+
return MCPError(FString::Printf(TEXT("'%s' is not a .utrace file."), *Request.File));
|
|
677
|
+
}
|
|
678
|
+
// The file a running trace writes to is still growing and has no end; an
|
|
679
|
+
// analysis of it would describe a moment and present it as the whole run.
|
|
680
|
+
if (FTraceAuxiliary::IsConnected())
|
|
681
|
+
{
|
|
682
|
+
const FString Destination = FPaths::ConvertRelativePathToFull(FTraceAuxiliary::GetTraceDestinationString());
|
|
683
|
+
if (FPaths::IsSamePath(Destination, Request.File))
|
|
684
|
+
{
|
|
685
|
+
return MCPError(TEXT("That trace is still being written. Stop it with editor(stop_trace) first; the file is only complete after the stop."));
|
|
686
|
+
}
|
|
687
|
+
}
|
|
688
|
+
|
|
689
|
+
#if UE_MCP_HAS_5_7_API
|
|
690
|
+
ITraceServicesModule* Module = FModuleManager::LoadModulePtr<ITraceServicesModule>(TEXT("TraceServices"));
|
|
691
|
+
if (!Module)
|
|
692
|
+
{
|
|
693
|
+
return MCPError(TEXT("The TraceServices module could not be loaded, so the trace cannot be analysed in this editor."));
|
|
694
|
+
}
|
|
695
|
+
const TSharedPtr<TraceServices::IAnalysisService> Service = Module->GetAnalysisService();
|
|
696
|
+
if (!Service.IsValid())
|
|
697
|
+
{
|
|
698
|
+
return MCPError(TEXT("TraceServices returned no analysis service."));
|
|
699
|
+
}
|
|
700
|
+
|
|
701
|
+
const double WallStart = FPlatformTime::Seconds();
|
|
702
|
+
const FMCPDeferredCallPtr Deferred = MCPDeferRequest();
|
|
703
|
+
if (!Deferred)
|
|
704
|
+
{
|
|
705
|
+
// Called in-process rather than for a bridge request: nothing can wait
|
|
706
|
+
// for a later answer, so analyse here and block.
|
|
707
|
+
const TSharedPtr<const TraceServices::IAnalysisSession> Session = Service->Analyze(*Request.File);
|
|
708
|
+
if (!Session.IsValid())
|
|
709
|
+
{
|
|
710
|
+
return MCPError(FString::Printf(TEXT("TraceServices could not open '%s' for analysis."), *Request.File));
|
|
711
|
+
}
|
|
712
|
+
TSharedPtr<FJsonObject> Result;
|
|
713
|
+
FString Error;
|
|
714
|
+
{
|
|
715
|
+
TraceServices::FAnalysisSessionReadScope ReadScope(*Session);
|
|
716
|
+
Error = MCPTraceAnalysisSummarise(*Session, Request, Result);
|
|
717
|
+
}
|
|
718
|
+
if (!Error.IsEmpty()) return MCPError(Error);
|
|
719
|
+
MCPTraceAnalysisStamp(Result, Request, WallStart);
|
|
720
|
+
return MCPTraceAnalysisFinish(Result, Request);
|
|
721
|
+
}
|
|
722
|
+
|
|
723
|
+
const TSharedPtr<FMCPTraceAnalysisJob, ESPMode::ThreadSafe> Job = MakeShared<FMCPTraceAnalysisJob, ESPMode::ThreadSafe>();
|
|
724
|
+
Job->Session = Service->StartAnalysis(*Request.File);
|
|
725
|
+
if (!Job->Session.IsValid())
|
|
726
|
+
{
|
|
727
|
+
return MCPError(FString::Printf(TEXT("TraceServices could not open '%s' for analysis."), *Request.File));
|
|
728
|
+
}
|
|
729
|
+
|
|
730
|
+
Deferred->SetCancelNote(TEXT("The analysis session was stopped. Nothing was written, so there is nothing to undo."));
|
|
731
|
+
Deferred->OnCancel([Job](const FString&)
|
|
732
|
+
{
|
|
733
|
+
if (Job->Session.IsValid()) Job->Session->Stop(/*bAndWait=*/false);
|
|
734
|
+
});
|
|
735
|
+
|
|
736
|
+
FMCPDeferredCallPtr DeferredCopy = Deferred;
|
|
737
|
+
Async(EAsyncExecution::ThreadPool, [DeferredCopy, Job, Request, WallStart]()
|
|
738
|
+
{
|
|
739
|
+
const TraceServices::IAnalysisSession& Session = *Job->Session;
|
|
740
|
+
double LastReport = 0.0;
|
|
741
|
+
while (!Session.IsAnalysisComplete())
|
|
742
|
+
{
|
|
743
|
+
if (DeferredCopy->IsCancelled())
|
|
744
|
+
{
|
|
745
|
+
Session.Stop(/*bAndWait=*/true);
|
|
746
|
+
return;
|
|
747
|
+
}
|
|
748
|
+
FPlatformProcess::Sleep(0.05f);
|
|
749
|
+
const double Now = FPlatformTime::Seconds();
|
|
750
|
+
if (Now - LastReport >= 1.0)
|
|
751
|
+
{
|
|
752
|
+
LastReport = Now;
|
|
753
|
+
double Analysed = 0.0;
|
|
754
|
+
{
|
|
755
|
+
TraceServices::FAnalysisSessionReadScope ReadScope(Session);
|
|
756
|
+
Analysed = Session.GetDurationSeconds();
|
|
757
|
+
}
|
|
758
|
+
DeferredCopy->ReportProgress(Analysed, 0.0,
|
|
759
|
+
FString::Printf(TEXT("Analysed %.1f s of trace"), Analysed));
|
|
760
|
+
}
|
|
761
|
+
}
|
|
762
|
+
if (DeferredCopy->IsCancelled()) return;
|
|
763
|
+
|
|
764
|
+
TSharedPtr<FJsonObject> Result;
|
|
765
|
+
FString Error;
|
|
766
|
+
{
|
|
767
|
+
TraceServices::FAnalysisSessionReadScope ReadScope(Session);
|
|
768
|
+
Error = MCPTraceAnalysisSummarise(Session, Request, Result);
|
|
769
|
+
}
|
|
770
|
+
|
|
771
|
+
// The dump write and the final stamp go back to the game thread, where
|
|
772
|
+
// every other file write in the bridge happens.
|
|
773
|
+
AsyncTask(ENamedThreads::GameThread, [DeferredCopy, Result, Error, Request, WallStart]()
|
|
774
|
+
{
|
|
775
|
+
if (DeferredCopy->IsCancelled()) return;
|
|
776
|
+
if (!Error.IsEmpty())
|
|
777
|
+
{
|
|
778
|
+
DeferredCopy->Complete(MCPError(Error));
|
|
779
|
+
return;
|
|
780
|
+
}
|
|
781
|
+
MCPTraceAnalysisStamp(Result, Request, WallStart);
|
|
782
|
+
DeferredCopy->Complete(MCPTraceAnalysisFinish(Result, Request));
|
|
783
|
+
});
|
|
784
|
+
});
|
|
785
|
+
return MCPDeferredMarker();
|
|
786
|
+
#else
|
|
787
|
+
return MCPError(TEXT("editor(analyze_trace) needs UE 5.7 or newer: the TraceServices timing API it reads changed shape before 5.7. ")
|
|
788
|
+
TEXT("Open the file in Unreal Insights with the openCommand editor(stop_trace) reported."));
|
|
789
|
+
#endif
|
|
790
|
+
}
|