Repository navigation
Conversation
…nd timeout - Server: increase keepalive timeout threshold from 5s to 30s so mobile browsers suspended while choosing files or taking photos are not prematurely dropped (fixes schlagmichdoch#247). - Server: listen to socket 'close' for prompt tab-close cleanup. - Server: prevent ghost peer-left broadcasts when a reloaded tab reconnects with the same peerId; ensure dying old sockets never evict newly reconnected sockets from rooms. - Server: fix array membership and deletion on roomSecrets in Peer. - Client: fix _onVisibilityChange to check document[window.hiddenProperty] instead of truthy string window.hiddenProperty, which previously prevented any auto-reconnection on tab focus (fixes schlagmichdoch#498). - Client: ignore pagehide when e.persisted (bfcache). - Client: debounce WebRTC transient 'disconnected' state before tearing down peer to allow ICE candidate recovery.
|
Hello @BemreSTR , I tried your patch on a few affected phones with specific ways of selecting files. On one phone the selection window can be kept open 15 instead of 10 seconds now, on another phone the connection drops after just 5 seconds. Increasing the number "30000" further does not make any difference. It thus seems the patch is not working here. Edit: This setup uses Coturn, it might matter. |
dayowe
pushed a commit
to dayowe/PairDrop
that referenced
this pull request
Nov 25, 2026
Partial port of 0a7b466 from schlagmichdoch#524. This takes the visibility-state check.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This pull request fixes a collection of critical stability and reconnection bugs, most notably resolving the 2-year-old issue #247 (where mobile devices are dropped offline while selecting files or taking photos in the camera) and #498 (stuck offline on tab focus/visibility change).
It strictly follows the repository's "Stability always comes first" guideline with zero protocol or UI changes.
Root Causes & Fixes
1. Mobile Suspension Timeout (Fixes #247)
Date.now() - lastBeat > 5000). If a user took even 6 seconds to browse photos or snap a picture, the server dropped the connection, broadcastedpeer-left, and the other device saw them go offline.peer.socket.on('close')listener so real tab closures on desktop are cleaned up immediately without waiting for the timeout.2. Auto-Reconnect on Visibility Change Bug (Fixes #498, #260)
public/scripts/network.js:296,_onVisibilityChangechecked:window.hiddenPropertyis defined as the string'hidden'(or vendor prefixed). Because a non-empty string is always truthy in JavaScript,if (window.hiddenProperty)always evaluated to true and returned immediately on every single visibility change event! PairDrop never actually attempted to auto-reconnect when switching back to the tab.document[window.hiddenProperty], and proactively trigger reconnect if disconnected.3. Ghost
peer-leftRace Condition on Tab Reload / ReconnectsessionStoragepreserves thepeer_id. The client establishes a new WebSocket with the samepeer_id. When the new connection joins the room, the dying old socket was subsequently cleaned up by disconnect/timeout, which deleted the room entry and broadcasted a phantompeer-left(disconnect: true) to all other devices, prematurely destroying their WebRTC connection to the newly reconnected tab._leaveRoom(), added guardif (this._rooms[roomId][peer.id] !== peer) return;. If a newer connection has already taken over the room entry for thatpeer.id, the dying old socket will never delete the room entry nor broadcastpeer-left. Additionally, reconnecting with the samepeer.idterminates the superseded socket cleanly without emittingpeer-left.4. WebRTC Disconnect Debounce & BFCache Preservation
connectionState === 'disconnected'is often a transient state during ICE candidate rechecks (e.g. Wi-Fi handover). Firingpeer-disconnectedimmediately killed connections on brief glitches. It is now debounced for 5 seconds to allow recovery before tearing down the peer.pagehide, ignore events wheree.persisted === trueso tabs placed in browser page cache do not eagerly sever their active WebRTC connections.addRoomSecret/removeRoomSecretinserver/peer.jsto useincludesandfilterinstead ofinanddeleteon Arrays.Verification
peer_id, active message routing switches to the new socket, and closing the old socket does NOT evict the new socket from the room.node --checksyntax on all files.Fixes #247
Fixes #498
Relates to #260, #478