EMERGENCY PERFORMANCE FIXES + Unity Migration Plan
IMMEDIATE PERFORMANCE FIXES: - Disabled synthwaveMove animation on hero background (major GPU strain) - Disabled scanning line animation (constant viewport repainting) - Disabled gridFloat animation on 3D perspective grid - Reduced grid opacity for lighter rendering - Performance improvements should be immediately noticeable UNITY MIGRATION PLANNING: - Created comprehensive Unity migration plan (UNITY_MIGRATION_PLAN.md) - Analyzed current 653k+ lines of JS code and complex media architecture - Identified QuadVideoPlayer as primary performance bottleneck - Designed modular Unity architecture for video system - 8-week migration timeline with 3 phases - Focus on native video processing to solve 4+ simultaneous stream issues KEY INSIGHTS: - Web stack hitting limits with complex multi-video management - Unity VideoPlayer + RenderTextures can handle 4+ streams efficiently - Current modular architecture translates well to Unity GameObjects - Migration justified by performance needs + future platform goals Next: Test performance fixes, then begin Unity prototype
This commit is contained in:
parent
34261fcfa9
commit
bdcb9bea18
|
|
@ -0,0 +1,194 @@
|
|||
# Unity Migration Plan - Gooner Training Academy
|
||||
|
||||
## 🎯 **Migration Priority: HIGH**
|
||||
**Performance bottlenecks identified in multi-video system justify Unity migration**
|
||||
|
||||
---
|
||||
|
||||
## 📊 **Current Web Architecture Analysis**
|
||||
|
||||
### **Media System Complexity (Primary Migration Driver):**
|
||||
- **QuadVideoPlayer**: 4 simultaneous video streams with individual controls
|
||||
- **OverlayVideoPlayer**: Popup video system with full controls
|
||||
- **FocusVideoPlayer**: Minimal focus session player
|
||||
- **BaseVideoPlayer**: 400+ line shared video foundation
|
||||
- **VideoPlayerManager**: Centralized video orchestration
|
||||
- **Real-time video management**: Live switching, volume mixing, progress tracking
|
||||
|
||||
### **Web Performance Limitations:**
|
||||
- ✅ **HTML5 Video Limitations**: Browser video element limitations with 4+ simultaneous streams
|
||||
- ✅ **CSS Animation Overhead**: Synthwave effects causing repainting issues
|
||||
- ✅ **DOM Complexity**: Heavy video DOM manipulation and control overlays
|
||||
- ✅ **Memory Management**: No fine-grained video memory control in web
|
||||
- ✅ **GPU Utilization**: Limited GPU optimization in browser context
|
||||
|
||||
---
|
||||
|
||||
## 🎮 **Unity Architecture Design**
|
||||
|
||||
### **Phase 1: Core Video Engine (Month 1)**
|
||||
```csharp
|
||||
// Unity Video Architecture
|
||||
VideoManager {
|
||||
- QuadVideoDisplay (4 RenderTextures)
|
||||
- OverlayVideoSystem (UI Canvas overlay)
|
||||
- FocusVideoPlayer (minimal UI)
|
||||
- VideoLibraryManager (asset streaming)
|
||||
- PerformanceProfiler (frame rate monitoring)
|
||||
}
|
||||
|
||||
// Video Performance Optimization
|
||||
- Native video decoding (AVPro or Unity VideoPlayer)
|
||||
- GPU texture streaming for multiple videos
|
||||
- Memory pooling for video assets
|
||||
- Async video loading with progress tracking
|
||||
- Hardware-accelerated video compositing
|
||||
```
|
||||
|
||||
### **Phase 2: Game Logic Port (Month 2)**
|
||||
```csharp
|
||||
// Core Game Systems
|
||||
TaskChallengeGame {
|
||||
- GameStateManager (JSON persistence)
|
||||
- GameModeManager (scenario handling)
|
||||
- ProgressionSystem (statistics & achievements)
|
||||
- EventSystem (task completion, timers)
|
||||
}
|
||||
|
||||
// Data Architecture
|
||||
- ScriptableObject-based game data
|
||||
- JSON import/export for web compatibility
|
||||
- Event-driven architecture for loose coupling
|
||||
- Modular game mode system
|
||||
```
|
||||
|
||||
### **Phase 3: Advanced Features (Month 3)**
|
||||
```csharp
|
||||
// Unity-Specific Enhancements
|
||||
- 3D UI elements (rotating panels, depth-based layouts)
|
||||
- Particle effects for rewards/achievements
|
||||
- Advanced audio mixing (Unity AudioMixer)
|
||||
- VR/AR readiness (future expansion)
|
||||
- Console platform support
|
||||
- Advanced input handling (gamepads, touch)
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 🚀 **Migration Strategy: Modular Approach**
|
||||
|
||||
### **Week 1-2: Video System Proof of Concept**
|
||||
1. **Unity Project Setup**: 2022.3 LTS with Video packages
|
||||
2. **Basic Video Player**: Single video with controls in Unity UI
|
||||
3. **Quad Layout Test**: 4 videos rendering to RenderTextures
|
||||
4. **Performance Baseline**: Frame rate testing vs web version
|
||||
|
||||
### **Week 3-4: Core Video Features**
|
||||
1. **Video Library Integration**: File system scanning in Unity
|
||||
2. **Control Systems**: Play/pause, volume, progress for each video
|
||||
3. **Video Switching**: Smooth transitions between videos
|
||||
4. **Memory Management**: Proper video asset loading/unloading
|
||||
|
||||
### **Week 5-6: Game Logic Foundation**
|
||||
1. **Data Layer**: Game state, progression, statistics
|
||||
2. **Event System**: Task completion, mode switching
|
||||
3. **UI Framework**: Menus, modals, notifications
|
||||
4. **Settings System**: User preferences and configuration
|
||||
|
||||
### **Week 7-8: Feature Parity**
|
||||
1. **Game Modes**: Port all game scenarios and rules
|
||||
2. **Audio Integration**: Background music and TTS
|
||||
3. **Image Systems**: Task images and consequences
|
||||
4. **Save/Load**: Complete persistence system
|
||||
|
||||
---
|
||||
|
||||
## 🔧 **Technical Architecture**
|
||||
|
||||
### **Unity Package Requirements:**
|
||||
```
|
||||
- Video Player (built-in)
|
||||
- AVPro Video (optional, for advanced codec support)
|
||||
- TextMeshPro (UI text rendering)
|
||||
- JSON.NET (for data serialization)
|
||||
- Modern UI Pack (optional, for polished UI)
|
||||
```
|
||||
|
||||
### **Performance Targets:**
|
||||
- **60+ FPS** with 4 simultaneous videos
|
||||
- **<2GB RAM** usage for video streaming
|
||||
- **<100ms** video switching latency
|
||||
- **<5 second** cold startup time
|
||||
|
||||
### **Cross-Platform Strategy:**
|
||||
```
|
||||
Primary: Windows (PC)
|
||||
Secondary: macOS, Linux (desktop expansion)
|
||||
Future: Android/iOS (mobile adaptation)
|
||||
Long-term: VR platforms (Quest, PCVR)
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 📋 **Migration Phases**
|
||||
|
||||
### **Phase 1: Video Engine (Priority 1)**
|
||||
**Goal**: Solve performance bottlenecks with native video processing
|
||||
- Multi-video rendering system
|
||||
- GPU-optimized video playback
|
||||
- Advanced video controls and overlays
|
||||
- **Success Metric**: 4 videos @ 60fps consistently
|
||||
|
||||
### **Phase 2: Game Logic (Priority 2)**
|
||||
**Goal**: Feature parity with web version
|
||||
- Complete game mechanics port
|
||||
- Data persistence and statistics
|
||||
- All game modes and scenarios
|
||||
- **Success Metric**: 100% feature parity
|
||||
|
||||
### **Phase 3: Unity Enhancements (Priority 3)**
|
||||
**Goal**: Leverage Unity-specific features
|
||||
- 3D UI elements and effects
|
||||
- Advanced audio systems
|
||||
- Platform-specific optimizations
|
||||
- **Success Metric**: Enhanced user experience beyond web
|
||||
|
||||
---
|
||||
|
||||
## 🎯 **Decision Matrix**
|
||||
|
||||
### **Migrate Now If:**
|
||||
- ✅ Video performance continues to degrade
|
||||
- ✅ Need for mobile/console platforms
|
||||
- ✅ Want advanced 3D UI effects
|
||||
- ✅ Development team ready to learn Unity/C#
|
||||
|
||||
### **Stay Web If:**
|
||||
- ❌ Performance issues can be web-optimized
|
||||
- ❌ Rapid iteration is more important
|
||||
- ❌ Team lacks Unity expertise
|
||||
- ❌ Web-first distribution is critical
|
||||
|
||||
---
|
||||
|
||||
## 💡 **Immediate Actions**
|
||||
|
||||
### **This Week:**
|
||||
1. **Performance Test Current Fixes**: Validate if CSS optimizations resolve issues
|
||||
2. **Unity Learning**: Install Unity 2022.3 LTS and test basic video playback
|
||||
3. **Architecture Planning**: Design Unity class structure based on current system
|
||||
4. **Team Preparation**: Begin Unity/C# learning if needed
|
||||
|
||||
### **Next Week:**
|
||||
1. **Unity Prototype**: Build minimal 4-video system in Unity
|
||||
2. **Performance Comparison**: Direct fps comparison web vs Unity
|
||||
3. **Migration Timeline**: Finalize timeline based on prototype results
|
||||
4. **Resource Planning**: Assess development time and learning curve
|
||||
|
||||
---
|
||||
|
||||
## 🏁 **Recommendation: START UNITY MIGRATION**
|
||||
|
||||
**The media system complexity and performance requirements justify Unity migration now rather than later. The modular web architecture will translate well to Unity, and the advanced video processing capabilities will solve current bottlenecks.**
|
||||
|
||||
**Timeline: 2-3 months for full migration with enhanced features**
|
||||
|
|
@ -176,6 +176,7 @@ body {
|
|||
min-height: 400px;
|
||||
}
|
||||
|
||||
/* PERFORMANCE: Disabled moving background for performance */
|
||||
.hero-background {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
|
|
@ -183,16 +184,11 @@ body {
|
|||
right: 0;
|
||||
bottom: 0;
|
||||
background:
|
||||
linear-gradient(transparent 50%, rgba(255, 0, 255, 0.05) 50%),
|
||||
repeating-linear-gradient(
|
||||
0deg,
|
||||
transparent,
|
||||
transparent 98px,
|
||||
rgba(255, 0, 255, 0.1) 100px
|
||||
);
|
||||
animation: synthwaveMove 6s linear infinite;
|
||||
linear-gradient(135deg, rgba(20, 20, 40, 0.95) 0%, rgba(40, 20, 60, 0.9) 50%, rgba(20, 20, 40, 0.95) 100%);
|
||||
/* REMOVED: synthwaveMove animation - was causing performance issues */
|
||||
}
|
||||
|
||||
/* PERFORMANCE: Disabled scanning line animation */
|
||||
.hero-header::before {
|
||||
content: '';
|
||||
position: absolute;
|
||||
|
|
@ -201,7 +197,7 @@ body {
|
|||
width: 100%;
|
||||
height: 1px;
|
||||
background: linear-gradient(90deg, transparent, #00ffff, transparent);
|
||||
animation: scanline 12s linear infinite;
|
||||
/* REMOVED: scanline animation - causing performance issues */
|
||||
z-index: 10;
|
||||
}
|
||||
|
||||
|
|
@ -213,10 +209,10 @@ body {
|
|||
height: 120%;
|
||||
transform: translate(-50%, -50%) perspective(1000px) rotateX(60deg);
|
||||
background-image:
|
||||
linear-gradient(rgba(255, 0, 255, 0.2) 1px, transparent 1px),
|
||||
linear-gradient(90deg, rgba(255, 0, 255, 0.2) 1px, transparent 1px);
|
||||
linear-gradient(rgba(255, 0, 255, 0.15) 1px, transparent 1px),
|
||||
linear-gradient(90deg, rgba(255, 0, 255, 0.15) 1px, transparent 1px);
|
||||
background-size: 50px 50px;
|
||||
animation: gridFloat 12s ease-in-out infinite;
|
||||
/* REMOVED: gridFloat animation for performance */
|
||||
z-index: 1;
|
||||
will-change: transform;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue