Enhance FPS monitoring with detailed logging and switch to simple background mode on low FPS detection

This commit is contained in:
MayaChat
2025-11-24 13:58:10 -05:00
parent 4866f46aaf
commit 33f6f196eb

View File

@@ -146,14 +146,16 @@
if (delta >= 500) { // Update FPS every 500ms if (delta >= 500) { // Update FPS every 500ms
fps = Math.round((frameCount * 1000) / delta); fps = Math.round((frameCount * 1000) / delta);
console.log(`FPS: ${fps} (threshold: ${FPS_THRESHOLD}, low samples: ${lowFpsCount}/${LOW_FPS_SAMPLES})`);
frameCount = 0; frameCount = 0;
lastTime = currentTime; lastTime = currentTime;
// Check if FPS is consistently low // Check if FPS is consistently low
if (fps < FPS_THRESHOLD) { if (fps < FPS_THRESHOLD) {
lowFpsCount++; lowFpsCount++;
console.warn(`⚠️ Low FPS detected! ${fps} FPS (${lowFpsCount}/${LOW_FPS_SAMPLES})`);
if (lowFpsCount >= LOW_FPS_SAMPLES) { if (lowFpsCount >= LOW_FPS_SAMPLES) {
console.warn(`Low FPS detected (${fps}). Switching to simple background...`); console.warn(`🔄 Switching to simple background mode...`);
switchToSimpleBackground(); switchToSimpleBackground();
isSimpleMode = true; isSimpleMode = true;
// Stop monitoring - mode persists until page refresh // Stop monitoring - mode persists until page refresh
@@ -173,22 +175,28 @@
} }
function switchToSimpleBackground() { function switchToSimpleBackground() {
console.log('🎨 Activating simple background mode...');
// Stop rendering 3D scene // Stop rendering 3D scene
const canvas = document.querySelector('#galaxy-canvas'); const canvas = document.querySelector('#galaxy-canvas');
canvas.style.display = 'none'; canvas.style.display = 'none';
console.log('✓ 3D canvas hidden');
// Create simple gradient background // Create simple gradient background
const overlay = document.querySelector('#background-overlay'); const overlay = document.querySelector('#background-overlay');
overlay.style.background = 'linear-gradient(180deg, #0a1628 0%, #001a2d 50%, #000d1a 100%)'; overlay.style.background = 'linear-gradient(180deg, #0a1628 0%, #001a2d 50%, #000d1a 100%)';
overlay.style.backdropFilter = 'none'; overlay.style.backdropFilter = 'none';
console.log('✓ Gradient background applied');
// Disable all animations and transitions // Disable all animations and transitions
disableAnimations(); disableAnimations();
console.log('✓ Animations disabled');
// Add simple animated stars // Add simple animated stars
createSimpleStars(); createSimpleStars();
console.log('✓ Simple stars created');
console.log('Simple background mode activated - animations disabled for performance'); console.log('Simple background mode activated - animations disabled for performance');
} }
function disableAnimations() { function disableAnimations() {