Skip to content

Latest commit

 

History

History
61 lines (43 loc) · 2.4 KB

File metadata and controls

61 lines (43 loc) · 2.4 KB

Performance & Debug Logging Configuration

This document tracks all debug flags in the codebase to help diagnose performance issues.

Debug Flags Status

All debug flags should be FALSE by default in production to avoid performance overhead.

Component Debug Flags

  • src/components/Map/DroppedObjects.jsx - DEBUG = false (line 13)
  • src/components/Map/MapContainer.jsx - DEBUG = false (line 28)
  • src/components/Map/CustomShapeLabels.jsx - DEBUG = false (line 3)

Hook Debug Flags

  • src/hooks/useInfrastructure.js - DEBUG_INFRA = false (line 19)
  • src/hooks/useClickToPlace.js - DEBUG = false (line 5)

Utility Debug Flags

  • src/utils/enhancedRenderingUtils.js - DEBUG = false (line 147, hardcoded to prevent runtime activation)

Runtime Debug Switches

For development debugging, you can temporarily enable logs via:

  • Browser console: window.__DEBUG_DROPPED_OBJECTS__ = true (then reload)
  • localStorage: localStorage.setItem('debug:dropped-objects', '1') (then reload)
  • Vite env: VITE_DEBUG_DROPPED_OBJECTS=true in .env.local

⚠️ WARNING: Do NOT enable these in production! They cause significant performance degradation during map rotation.

Performance-Critical Paths

These areas execute on every rotation event and must have minimal logging:

  1. DroppedObjects.jsx - onRotate() handler (line 523)
  2. useInfrastructure.js - onRotate() handler (line 387)
  3. enhancedRenderingUtils.js - addEnhancedSpritesToMap() (called during sprite loading)

How to Debug Rotation Performance

If you experience lag during rotation (Q/E keys):

  1. Check browser console - Are there any logs appearing? If yes, a debug flag is accidentally enabled.
  2. Check browser devtools Performance tab - Record during rotation and look for:
    • Long-running JavaScript tasks
    • Frequent setData() calls on GeoJSON sources
    • Console logging operations
  3. Temporarily enable profiling:
    // In browser console
    window.__DEBUG_DROPPED_OBJECTS__ = true;
    // Rotate the map
    // Count how many logs appear - should be 0 during normal rotation
    window.__DEBUG_DROPPED_OBJECTS__ = false;

Confirmed Issues (Fixed)

  • enhancedRenderingUtils.js was checking window.__DEBUG_DROPPED_OBJECTS__ at runtime, allowing accidental activation
  • ✅ Now hardcoded to false to prevent runtime activation

Last updated: 2025-10-02