Problem solved: System enter was janky (all 3D assets + textures at once).
Solution: 4-phase lazy loading per planet:
T=0ms Phase 0: Orbits + Star + Planet Spheres (flat color)
→ systemPlanetEntries built, animation starts
→ Fleets rendered immediately
T=50-100ms Phase 1: Planet 0 texture canvas-gen + material swap
T=100-150ms Phase 1: Planet 1 texture gen...
T=150-200ms Phase 1: Planet 2 texture gen...
T=...+10ms Phase 2: Atmosphere shells per planet
T=...+10ms Phase 3: Cloud shells per planet
Implementation:
_buildSystemPhase0()– Quick baseline (geometry, no textures)_queueSystemRefinement()– Build task queue (50ms staggered per planet)_processSystemRefinementQueue()– Async texture gen in tasks- Cleanup:
exitSystemView()cancels pending tasks
Result: System appears in ~0ms, visually complete in ~200-500ms (staggered).
Problem: System API responses 50-200KB JSON. Transit time bottleneck.
Solution: 3 tiers:
gzipheader +ob_gzhandler- Works: ~60-70% reduction (12KB for typical system)
- Status: Enabled in
api/galaxy.php
- Remove unused fields from response
?trim=1flag- Stripped fields:
server_ts,deposit_*, building details, etc. - Enabled by default in
API.galaxy()(js/api.js)
- MessagePack-like format: ~40% of gzipped JSON
- Schema defined in
api/compression.php - Not implemented yet (opt-in for future)
// Trimmed + gzipped (now default):
const payload = await API.galaxy(1, 1);
// Full response (backwards compat):
const fullPayload = await fetch('api/galaxy.php?galaxy=1&system=1').then(r => r.json());enable_response_gzip(); // Add to any API endpoint
// Optional trimming
$response = trim_system_payload_for_transit($payload);| Format | Size | Time (5G) | Notes |
|---|---|---|---|
| Full JSON | 120 KB | 156 ms | Baseline |
| + Gzip | 16 KB | 21 ms | Browser default |
| + Trim | 10 KB | 13 ms | Field reduction |
| + Binary | 4 KB | 5 ms | Phase 2 |
Current (Gzip + Trim): 91% reduction vs baseline.
-
Binary Format (
?format=bin)- Implement MessagePack on server (if available)
- JS decoder for parsing
- Fallback to JSON
-
Delta API (
?since_ts=1234567890)- Only fleet/colony changes since last fetch
- Reduces payload for live updates
-
GraphQL Variant (
POST /api/graphql)- Client picks exact fields needed
- 20-30% smaller than REST trim