Debugging & Performance Tools
Hyperscape includes built-in debugging tools for monitoring performance, inspecting game state, and troubleshooting issues.FPS Debug Panel
Toggle with F5
Press F5 to toggle the FPS debug panel on/off:Panel Contents
The debug panel shows:- FPS - Frames per second (target: 60 FPS)
- Frame Time - Milliseconds per frame (target: <16.67ms)
- Memory Usage - Heap size and allocation rate
- Entity Count - Active entities in the world
- Network Stats - Ping, packet loss, bandwidth
Performance Targets
| Metric | Target | Warning | Critical |
|---|---|---|---|
| FPS | 60 | <45 | <30 |
| Frame Time | <16.67ms | >22ms | >33ms |
| Memory | <500MB | >800MB | >1GB |
| Entities | <1000 | >2000 | >5000 |
| Ping | <50ms | >100ms | >200ms |
Console Logging
Debug Flags
Enable detailed logging for specific systems:Gathering Debug Output
WhenDEBUG_GATHERING = true:
Combat Debug Output
WhenDEBUG_COMBAT = true:
Network Debugging
WebSocket Inspector
Use browser DevTools to inspect WebSocket traffic:- Open DevTools (F12)
- Go to Network tab
- Filter by WS (WebSockets)
- Click the WebSocket connection
- View Messages tab
Common Messages
| Message Type | Direction | Purpose |
|---|---|---|
playerJoined | Server → Client | Player connected |
entityModified | Server → Client | Entity state changed |
useItem | Client → Server | Player eating/using item |
equipItem | Client → Server | Player equipping item |
attackEntity | Client → Server | Combat request |
gatherResource | Client → Server | Mining/woodcutting/fishing |
Performance Profiling
Chrome DevTools
- Open DevTools (F12)
- Go to Performance tab
- Click Record
- Perform actions in-game
- Stop recording
- Analyze flame graph
Key Areas to Profile
- Rendering - Three.js draw calls
- Physics - PhysX simulation
- Networking - WebSocket message processing
- ECS Systems - Entity updates
Common Bottlenecks
| Issue | Cause | Solution |
|---|---|---|
| Low FPS | Too many entities | Reduce render distance |
| High frame time | Complex shaders | Disable post-processing |
| Memory leak | Entity cleanup | Check entity destruction |
| Network lag | Packet spam | Implement rate limiting |
Entity Inspection
World Entity Query
Access the world object in console:System Inspection
Error Logging
Client Errors
Client errors are logged to console and can be reported:Server Errors
Server errors are logged with structured data:Testing Tools
Visual Testing Framework
Hyperscape uses real gameplay testing with Playwright:Screenshot Assertions
Related Documentation
- Development Guide - Setting up dev environment
- Testing Strategy - Writing tests
- Performance Optimization - Improving FPS
- Troubleshooting - Common issues