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
This commit is contained in:
Claude 2026-01-13 22:10:45 +00:00
parent 6ff7796b3a
commit 2d5b112eee
No known key found for this signature in database
3 changed files with 11 additions and 16 deletions

View File

@ -84,9 +84,8 @@ void CrossPointWebServerActivity::onExit() {
dnsServer = nullptr; dnsServer = nullptr;
} }
// CRITICAL: Wait for LWIP stack to flush any pending packets // Brief wait for LWIP stack to flush pending packets
Serial.printf("[%lu] [WEBACT] Waiting 500ms for network stack to flush pending packets...\n", millis()); delay(50);
delay(500);
// Disconnect WiFi gracefully // Disconnect WiFi gracefully
if (isApMode) { if (isApMode) {
@ -96,11 +95,11 @@ void CrossPointWebServerActivity::onExit() {
Serial.printf("[%lu] [WEBACT] Disconnecting WiFi (graceful)...\n", millis()); Serial.printf("[%lu] [WEBACT] Disconnecting WiFi (graceful)...\n", millis());
WiFi.disconnect(false); // false = don't erase credentials, send disconnect frame 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()); Serial.printf("[%lu] [WEBACT] Setting WiFi mode OFF...\n", millis());
WiFi.mode(WIFI_OFF); 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()); Serial.printf("[%lu] [WEBACT] [MEM] Free heap after WiFi disconnect: %d bytes\n", millis(), ESP.getFreeHeap());

View File

@ -145,16 +145,14 @@ void CrossPointWebServer::stop() {
Serial.printf("[%lu] [WEB] WebSocket server stopped\n", millis()); Serial.printf("[%lu] [WEB] WebSocket server stopped\n", millis());
} }
// Add delay to allow any in-flight handleClient() calls to complete // Brief delay to allow any in-flight handleClient() calls to complete
delay(100); delay(20);
Serial.printf("[%lu] [WEB] Waited 100ms for handleClient to finish\n", millis());
server->stop(); server->stop();
Serial.printf("[%lu] [WEB] [MEM] Free heap after server->stop(): %d bytes\n", millis(), ESP.getFreeHeap()); 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 // Brief delay before deletion
delay(50); delay(10);
Serial.printf("[%lu] [WEB] Waited 50ms before deleting server\n", millis());
server.reset(); server.reset();
Serial.printf("[%lu] [WEB] Web server stopped and deleted\n", millis()); Serial.printf("[%lu] [WEB] Web server stopped and deleted\n", millis());

View File

@ -887,11 +887,9 @@ function uploadFileWebSocket(file, onProgress, onComplete, onError) {
reject(err); reject(err);
} }
} else if (msg.startsWith('PROGRESS:')) { } else if (msg.startsWith('PROGRESS:')) {
// Server confirmed progress - we can use this for accurate tracking // Server confirmed progress - log for debugging but don't update UI
const parts = msg.split(':'); // (local progress is smoother, server progress causes jumping)
const received = parseInt(parts[1]); console.log('[WS] Server progress:', msg);
const total = parseInt(parts[2]);
if (onProgress) onProgress(received, total);
} else if (msg === 'DONE') { } else if (msg === 'DONE') {
ws.close(); ws.close();
if (onComplete) onComplete(); if (onComplete) onComplete();