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

@@ -5,6 +5,8 @@
#include <vector>
#include <map>
#include <set>
#include <atomic>
#include <chrono>
#include <mutex>
#include <thread>
#include <memory>
@@ -231,6 +233,13 @@ private:
std::set<uint64_t> m_OfflineDevices; // Devices that went offline since last flush
std::mutex m_DirtyDevicesMutex;
// Grace-period timers: delay CloseWebRemoteDesktopByClientID by 30 s after
// the last web viewer disconnects to allow quick mobile reconnects (e.g.
// switching to a TOTP app briefly). Cancelled by StartRemoteDesktop when a
// viewer reconnects within the window.
std::map<uint64_t, std::shared_ptr<std::atomic<bool>>> m_PendingCloseTimers;
std::mutex m_PendingCloseMutex;
public:
// Check if a device session was triggered by web (should be hidden)
bool IsWebTriggered(uint64_t device_id);