-
Notifications
You must be signed in to change notification settings - Fork 1
Remote Debug System
Bidirectional command channel for inspecting and modifying a running game from the editor, with loopback mode for local testing.
Source: SparkEngine/Source/Engine/RemoteDebug/RemoteDebugSystem.h
The Remote Debug System provides a live link between the editor and a running game instance. The editor sends commands (console commands, property reads/writes, performance requests) to the game, and the game dispatches them to registered handlers and returns responses. This enables live tuning, inspection, and diagnostics without stopping the game.
Transport is abstracted behind the RemoteSession class, which provides thread-safe send/receive queues. A real transport adapter (TCP socket) plugs into EnqueueReceived() and DequeuePendingSend(). For testing and single-machine workflows, EnableLoopback() connects server and client through shared queues with no sockets required.
The RemoteDebugServer runs in the game runtime with built-in handlers for console commands, property get/set, performance data, and heartbeat. Custom handlers can be registered for game-specific debug commands.
RemoteDebugSystem (singleton)
+-- RemoteDebugServer (game-side)
| +-- RemoteSession (thread-safe queues)
| +-- CommandHandler map (type -> callback)
| +-- Built-in handlers: console_cmd, property_get/set, profile_data, heartbeat
+-- RemoteDebugClient (editor-side)
| +-- RemoteSession (thread-safe queues)
| +-- Convenience methods (ExecuteConsoleCommand, GetProperty, etc.)
+-- Loopback pump (client send -> server recv, server send -> client recv)
Editor (Client) Game (Server)
| |
|-- SendCommand(cmd) ------------>|
| [EnqueueSend -> transport -> |
| EnqueueReceived] |
| |-- ProcessCommand(cmd)
| |-- handler(cmd) -> response
| |-- EnqueueSend(response)
|<-- PollResponses() -------------|
| Class | Description |
|---|---|
RemoteDebugSystem |
Singleton owning server and client instances |
RemoteDebugServer |
Accepts connections, dispatches commands to handlers |
RemoteDebugClient |
Connects to game, provides convenience debug methods |
RemoteSession |
Thread-safe connection state with send/receive queues |
RemoteCommand |
Wire message with type, JSON payload, request ID, timestamp |
auto& debug = Spark::RemoteDebug::RemoteDebugSystem::GetInstance();
debug.Initialize();
debug.EnableLoopback(); // No sockets needed
// Send a command from the client side
auto* client = debug.GetClient();
uint32_t reqId = client->ExecuteConsoleCommand("stat fps");
// Update pumps loopback and processes commands
debug.Update(0.016f);
// Poll responses
auto responses = client->PollResponses();
for (const auto& resp : responses)
{
// resp.type == "console_cmd_result"
// resp.payload contains JSON result
}auto& debug = Spark::RemoteDebug::RemoteDebugSystem::GetInstance();
debug.Initialize();
// Game side: start listening
debug.StartServer(9090);
// Editor side: connect to game
debug.ConnectToTarget("192.168.1.100", 9090);auto* server = debug.GetServer();
server->RegisterCommandHandler("spawn_entity",
[](const Spark::RemoteDebug::RemoteCommand& cmd) {
// Parse cmd.payload, spawn entity
return Spark::RemoteDebug::RemoteCommand{
"spawn_result", R"({"status":"ok","entityId":42})", cmd.requestId, 0.0f
};
});| Method | Description |
|---|---|
Initialize() / Shutdown() |
Lifecycle management |
StartServer(port) |
Begin listening for editor connections |
ConnectToTarget(addr, port) |
Connect client to a running game |
EnableLoopback() |
Connect server and client in-process (no sockets) |
Update(float dt) |
Per-frame update: pump loopback, process commands |
IsConnected() |
True if either side has an active connection |
| Method | Description |
|---|---|
ExecuteConsoleCommand(cmd) |
Run a console command on the remote game |
GetProperty(path) |
Request a dot-separated property value |
SetProperty(path, value) |
Set a property on the remote game |
RequestPerformanceSnapshot() |
Request CPU/GPU/memory stats |
PollResponses() |
Drain all received responses since last poll |
| Type | Description |
|---|---|
console_cmd |
Execute a console command, returns console_cmd_result
|
property_get |
Read a property by path, returns property_value
|
property_set |
Write a property, returns property_set_result
|
profile_data |
Performance snapshot (FPS, CPU, GPU, memory) |
heartbeat |
Connection keepalive check |
| Setting | Default | Description |
|---|---|---|
| Server port | 9090 | TCP port for editor connections |
| Loopback mode | off | Enable with EnableLoopback() for local testing |
- Console System -- In-engine console for command execution
- Profiler -- Performance monitoring data source
- Editor -- Editor-side UI for remote debugging
Published from 936a8401bf15. Edit the canonical source in wiki/.
- Documentation
- Docs route
- Wiki index
- Guides
- Tutorials
- Samples
- Examples
- API Reference
- API route
- Reference
- Build Guide
- Dependencies
- FAQ
- Changelog
- Roadmap
- Contributing
- Code of Conduct
- Home
- FAQ
- Getting Started
- Quick-Start Tutorial
- Making Your First Game
- Making Your First Multiplayer Game
- Artist Workflow Guide
- Editor Walkthrough
- Migration Guide
- How SparkEngine Works
- Architecture Overview
- Engine Architecture Flowchart
- Creating a Game Module
- Game Modules (catalog)
- Entity Component System
- Rendering and Graphics
- Physics
- Cloth Simulation
- Audio
- Input System
- Camera System
- Scripting with AngelScript
- Visual Scripting
- AI and Navigation
- Animation
- 2D Systems
- Networking
- Dedicated Server
- Multiplayer Quick Start
- Area Server Architecture
- Scene Management
- Large World Support
- Collaborative Editing
- Coroutine System
- Event System
- Event Response System
- Job System
- UI System
- UI Layout Extensions
- Localization
- Dialogue System
- Destruction System
- Replay System
- Achievement System
- Loading System
- Mod System
- Content Delivery
- Tween System
- Memory Integrity
- Gameplay Systems
- Terrain and Procedural Generation
- Save System
- Persistence System
- Day Night Cycle and Weather
- Cinematic Sequencer
- Runtime Prefabs
- SparkEditor
- Editor Tutorials
- SparkConsole
- SparkDaemon
- Shader Pipeline
- Asset Pipeline
- Asset Validation
- Asset Migration
- Game Packaging
- Online Services
- DataTable System
- Loot and Crafting System
- CSG System
- Font System
- Timer Manager
- Movie Render Pipeline
- HLOD and World Partition
- Remote Debug System
- Selection Manager
- Asset Dependency Graph
- Editor Automation
- File Watcher
- Project Templates
- System Requirements
- VR Support
- Mobile Platform
- Accessibility
- Platform Input
- Cross-Compilation: Wine Testing
- RHI Abstraction Layer
- D3D11 Backend
- D3D12 Backend
- Vulkan Backend
- OpenGL Backend
- Metal Backend
- DXR Raytracing
- Hybrid Ray Tracing
- Upscaling (DLSS/FSR)
- Render Graph
- Shader Graph
- GPU Particles
- GPU-Driven Rendering
- Volumetric Fog
- Volumetric Clouds
- Global Illumination
- Virtual Texturing
- Water Rendering
- Clustered Lighting
- Material System
- Post-Processing
- Shadow System
- Particle System
- Decal System
- Sky and Atmosphere
- Foliage System
- Mesh Shaders
- Neural Rendering
- Configuration Reference
- Performance Tips
- Benchmark Framework
- Threading Model
- Memory Safety
- Memory Management Patterns
- Build System and CMake Modules
- Profiler and Debugging
- Performance Profiling Guide
- Telemetry System
- Golden Image Testing
- Utilities
- Testing
- Codebase Statistics
- Codebase Health
- Error Handling Patterns
- Hot Reload Overview
- Troubleshooting
- Contributing
- Workflow Patterns
- Build Optimizations
- CI Reproducible Builds
- GitHub API and PR Checks
- Git Rebase Conflicts
- Clang-Format
- Code Quality Violations
- AI Bloat Pattern
- MinGW + Wine Cross-Compilation
- Live Editor Testing
- Engine & Renderer Landscape
- DuetOS Portability Catalog
- Five-Engine Analysis
- Eleven-Engine Analysis
- ThorVG / Unity Graphics Analysis
- Advanced Techniques Catalog
- Third-Party Library Evaluation
- Engine Viability Evaluation
- Engine Feature Recommendations
- Project Recommendations
- Mac Compatibility Analysis
- Codebase Observations
- Codebase Bloat Audit
- Test Suite Audit
- Documentation Coverage Audit
- ThirdParty Dependencies Audit
- Load Test Baseline
- Gameplay Systems Status
- SparkGame Module Status
- Stub and Abandoned Features
- Memory Integrity System
- Memory Safety Evaluation
- Hardware Acceleration Systems
- Jolt Physics Integration
- GPU/CPU Separation Plan
- Daemon Services Architecture
- Reflection & Polymorphism Refactoring Plan
- SparkBuild In-Tree
- Wine No-JobSystem Breakthrough
- Wine Role and Fallback Tiers