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;
}
// 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());

View File

@ -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());

View File

@ -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();