Skip to content

Conversation

@emberian
Copy link
Owner

inside these commits there's experimentation and a few dozen dollars of claude usage.

emberian and others added 28 commits September 4, 2025 13:51
- Use StoredValue for all contexts to prevent re-creation on re-renders
- Fix modal event listener using window_event_listener for proper cleanup
- AppState now created once, preventing exponential listener accumulation
- Critical bug fixed: login page no longer lags after keystrokes
- Added event_log signal to store all GameEvents
- Updated handle_game_event to store events before processing
- Added get_event_log_signal accessor for components
- Events now accumulated in reactive signals (no HTTP fetches needed)
- Implements memory management (keep last 500 events max)
- Completely rewrote GameHistory to read from event_log signal
- Removed LocalResource and all HTTP fetching from history panel
- Removed deprecated history_version signal and bump_history method
- History now updates instantly via reactive signals (no HTTP delay)
- Major performance improvement: 0 HTTP requests vs dozens per game
- Added best practices documentation to helpers.rs
- Formatted code with cargo fmt
- All phases complete and tested
- Ready for production use
CRITICAL FIXES:

1. NetworkStatus: Event Listener Leak (CATASTROPHIC)
   - Fixed manual Closure management with .forget() causing listener accumulation
   - Replaced with window_event_listener for automatic cleanup
   - File: webapp/src/components/common.rs

2. KeyboardContext: Global Listener in Constructor (CRITICAL)
   - Removed setup_listener() from constructor that leaked listeners
   - Created separate KeyboardListener component with proper cleanup
   - Every keystroke was firing multiple accumulated listeners causing severe lag
   - Files: webapp/src/components/keyboard.rs, mod.rs, main.rs

3. Inefficient Signal Subscriptions (HIGH)
   - All get_*_signal() methods were using .get() creating HashMap subscriptions
   - Changed to .get_untracked() to avoid unnecessary re-renders
   - Components no longer re-render on unrelated game additions/removals
   - File: webapp/src/state.rs

IMPACT:
- Eliminates input lag in login/register forms
- Stops event listener accumulation
- Drastically reduces unnecessary component re-renders
- Keyboard shortcuts now execute once per keystroke, not N times

Documentation:
- WEBAPP_PERFORMANCE_ANALYSIS.md: Root cause analysis
- WEBAPP_PERFORMANCE_FIXES.md: Summary of fixes and impact

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants