From 2d5b112eee01132974578f92a5efe14c7935e0a8 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 13 Jan 2026 22:10:45 +0000 Subject: [PATCH] Fix progress bar jumping and slow exit Progress bar: - Only use local progress for UI (smoother) - Server PROGRESS messages logged but don't update UI Exit delays reduced from ~850ms to ~140ms: - stop(): 150ms -> 30ms - onExit(): 700ms -> 110ms --- src/activities/network/CrossPointWebServerActivity.cpp | 9 ++++----- src/network/CrossPointWebServer.cpp | 10 ++++------ src/network/html/FilesPage.html | 8 +++----- 3 files changed, 11 insertions(+), 16 deletions(-) diff --git a/src/activities/network/CrossPointWebServerActivity.cpp b/src/activities/network/CrossPointWebServerActivity.cpp index de4efe76..2e6429cb 100644 --- a/src/activities/network/CrossPointWebServerActivity.cpp +++ b/src/activities/network/CrossPointWebServerActivity.cpp @@ -84,9 +84,8 @@ void CrossPointWebServerActivity::onExit() { dnsServer = nullptr; } - // CRITICAL: Wait for LWIP stack to flush any pending packets - Serial.printf("[%lu] [WEBACT] Waiting 500ms for network stack to flush pending packets...\n", millis()); - delay(500); + // Brief wait for LWIP stack to flush pending packets + delay(50); // Disconnect WiFi gracefully if (isApMode) { @@ -96,11 +95,11 @@ void CrossPointWebServerActivity::onExit() { Serial.printf("[%lu] [WEBACT] Disconnecting WiFi (graceful)...\n", millis()); WiFi.disconnect(false); // false = don't erase credentials, send disconnect frame } - delay(100); // Allow disconnect frame to be sent + delay(30); // Allow disconnect frame to be sent Serial.printf("[%lu] [WEBACT] Setting WiFi mode OFF...\n", millis()); WiFi.mode(WIFI_OFF); - delay(100); // Allow WiFi hardware to fully power down + delay(30); // Allow WiFi hardware to power down Serial.printf("[%lu] [WEBACT] [MEM] Free heap after WiFi disconnect: %d bytes\n", millis(), ESP.getFreeHeap()); diff --git a/src/network/CrossPointWebServer.cpp b/src/network/CrossPointWebServer.cpp index 084dcd9a..23ba36ba 100644 --- a/src/network/CrossPointWebServer.cpp +++ b/src/network/CrossPointWebServer.cpp @@ -145,16 +145,14 @@ void CrossPointWebServer::stop() { Serial.printf("[%lu] [WEB] WebSocket server stopped\n", millis()); } - // Add delay to allow any in-flight handleClient() calls to complete - delay(100); - Serial.printf("[%lu] [WEB] Waited 100ms for handleClient to finish\n", millis()); + // Brief delay to allow any in-flight handleClient() calls to complete + delay(20); server->stop(); Serial.printf("[%lu] [WEB] [MEM] Free heap after server->stop(): %d bytes\n", millis(), ESP.getFreeHeap()); - // Add another delay before deletion to ensure server->stop() completes - delay(50); - Serial.printf("[%lu] [WEB] Waited 50ms before deleting server\n", millis()); + // Brief delay before deletion + delay(10); server.reset(); Serial.printf("[%lu] [WEB] Web server stopped and deleted\n", millis()); diff --git a/src/network/html/FilesPage.html b/src/network/html/FilesPage.html index 94ec65b3..ec0e17b5 100644 --- a/src/network/html/FilesPage.html +++ b/src/network/html/FilesPage.html @@ -887,11 +887,9 @@ function uploadFileWebSocket(file, onProgress, onComplete, onError) { reject(err); } } else if (msg.startsWith('PROGRESS:')) { - // Server confirmed progress - we can use this for accurate tracking - const parts = msg.split(':'); - const received = parseInt(parts[1]); - const total = parseInt(parts[2]); - if (onProgress) onProgress(received, total); + // Server confirmed progress - log for debugging but don't update UI + // (local progress is smoother, server progress causes jumping) + console.log('[WS] Server progress:', msg); } else if (msg === 'DONE') { ws.close(); if (onComplete) onComplete();