Skip to content

Improve refresh discovery

Apollo Zhu requested to merge work/iOS-16/discovery into master
  • Only stop and start tcp socket when network actually changed to reduce flickering and chance of concurrent modification to _pendingSockets
  • Fix not reconnecting after rejoining network while the other device thinks we are still connected by always reconnecting upon receiving identity package.
  • Enable reusing LanLink to allow continuous file transfer even with new socket for every identity package
  • Fix missing battery status by sending and requesting battery status after pairing succeeds
  • Remove nil checking + removal if true to prevent possible concurrent modification exception
  • Prevent concurrency issues on hard refresh by synchronizing access to Device's _links.

TestFlight

Try out changes in this merge request by joining https://testflight.apple.com/join/N7gQIPan. Limited to 100 external testers, will become unavailable once this merge request is merged.

On Reachability

  • We can't reliably tell "joined a new network" because NWPath doesn't have identifying information. We could integrate with Trusted Network feature later -- if the user gives precise location permission
  • We can't reliably tell if the other device is still connected, as seen in all KDE Connect clients. Suppose we are device Self, and we are connected to some Other device: If we disconnect S from the network:
    • O will think S is still connected until O hard refreshes (disconnect from all and restart discovery)
    • When S joins the network again while O still thinks S is connected, the only way for S to connect to O is for O to attempt connecting to an "already connected" device. Currently, older versions of KDE Connect iOS app doesn't.
    • What we want is SO_KEEPALIVE/TCP_KEEPALIVE, I think, which someone else tried before https://blog.csdn.net/PDUnderstand/article/details/80049903 (note: blog post is in Simplified Chinese)
  • Hard refresh still possible through Advanced Settings
  • To prevent weird socket issues, we now aggressively close sockets immediately upon entering background, since we don't support background activity currently
Edited by Apollo Zhu

Merge request reports