WalletConnectSwiftV2 icon indicating copy to clipboard operation
WalletConnectSwiftV2 copied to clipboard

SocketConnectionType automatic failing to reconnect after long backgrounding

Open simonmcl opened this issue 1 year ago • 1 comments

Describe the bug I have a QRCode scanner button in my app, that I cover with a activityIndicator when socketConnectionStatusPublisher publishes a disconnected event. For a while now i've been trying to track down an issue, where sometimes I open my app and the indicator stays active indefinitely. I'm not able to reliably reproduce the issue in a dev setup, so for testing purposes I installed a second version on my device with 2 buttons, one without the indicator to try debug the issue. While trying to use my app today it happened again, using the second button to scan the QRCode, I then got a WC2 error that the socket was not connected and the pairing process couldn't be complete. So its not a UI glitch or my lifecycle management of the events/buttons, the socket is in fact disconnected and not reconnecting. I force closed the app and reopened, it immediately reconnected, and the pairing request came through on screen without any interaction.

There is a bug in the automatic connection management somewhere, that appears semi-often after a long period in the background. Likely a timer is timing out in the background, or an event handler is getting deallocated. Whats particularly frustrating about this issue is the fact that the SDK bans me from triggering a reconnect while using automatic mode. As a workaround, i'd be happy to add a tap gesture to my indicator, or set a 3 second timer etc, to manually trigger a reconnect. I've tried switching to manual connection and theres unknown edge cases i'm not handling properly, i'd love the ability to just use automatic with a manual fallback. Please investigate the connection issue, and please allow manual reconnection while using automatic mode

SDK Version

  • Client: Swift
  • Version: 1.19.4

To Reproduce Steps to reproduce the behavior:

  • Setup wallet using automatic connection mode
  • Background the app for a long time
  • Reopen the app and attempt to use WC2

Expected behavior A clear and concise description of what you expected to happen.

simonmcl avatar Jul 26 '24 11:07 simonmcl

Possibly related is this warning coming from AutomaticSocketConnectionHandler which appears in the console regularly Screenshot 2024-07-26 at 14 23 09

simonmcl avatar Jul 26 '24 13:07 simonmcl

the issue has been resolved in https://github.com/reown-com/reown-swift

llbartekll avatar Nov 19 '24 13:11 llbartekll