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:
yuanyuanxiang
2026-07-10 15:56:32 +02:00
parent 72dcdc5a6f
commit f146af121a
5 changed files with 111 additions and 9 deletions

View File

@@ -244,7 +244,7 @@ func (h *wsHub) handleDisconnect(c *wsClient, _ []byte) {
h.mu.Unlock()
c.queue([]byte(`{"cmd":"disconnect_result","ok":true}`))
if prev != "" && h.countWatchers(prev) == 0 {
h.devices.CloseScreen(prev)
h.deferredCloseScreen(prev)
}
}
@@ -288,6 +288,11 @@ func (h *wsHub) handleConnect(c *wsClient, raw []byte) {
c.queueBinary(cache.Keyframe)
}
h.mu.Lock()
// Cancel any pending deferred close so the relay stays alive.
if t, ok := h.screenCloseTimers[in.ID]; ok {
t.Stop()
delete(h.screenCloseTimers, in.ID)
}
c.watching = in.ID
h.mu.Unlock()
return