Fix: prevent mobile web remote desktop freeze on Safari app-switch
by forcing clean WS reconnect on foreground return; add 30-second grace period on server to avoid cold-start on quick reconnects
This commit is contained in:
@@ -4185,11 +4185,33 @@
|
||||
clearTimeout(backgroundDisconnectTimer);
|
||||
backgroundDisconnectTimer = null;
|
||||
}
|
||||
// Reconnect or send immediate ping
|
||||
const screenPage = document.getElementById('screen-page');
|
||||
const onScreenPage = screenPage && screenPage.classList.contains('active') && currentDevice;
|
||||
|
||||
if (!ws || ws.readyState !== WebSocket.OPEN) {
|
||||
// WS was dropped — reset decoder before reconnect.
|
||||
if (onScreenPage && decoder) {
|
||||
try { decoder.close(); } catch(e) {}
|
||||
decoder = null;
|
||||
needKeyframe = true;
|
||||
}
|
||||
connectWebSocket();
|
||||
} else if (onScreenPage && isTouchDevice) {
|
||||
// iOS suspends the tab and silently invalidates the VideoDecoder
|
||||
// GPU context (or quietly closes the WS while readyState stays OPEN).
|
||||
// Always force a clean WS reconnect on mobile so the server delivers
|
||||
// a fresh stream start; the server no longer sends a stale cached
|
||||
// keyframe (cleared on disconnect), so the client waits for the next
|
||||
// natural IDR — no mosaic, no freeze.
|
||||
if (decoder) {
|
||||
try { decoder.close(); } catch(e) {}
|
||||
decoder = null;
|
||||
needKeyframe = true;
|
||||
}
|
||||
ws.onclose = null;
|
||||
ws.close();
|
||||
connectWebSocket();
|
||||
} else if (token) {
|
||||
// Connection still open - send immediate ping to refresh server heartbeat
|
||||
ws.send(JSON.stringify({ cmd: 'ping', token }));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user