WalletConnectSwiftV2 icon indicating copy to clipboard operation
WalletConnectSwiftV2 copied to clipboard

WalletConnect 100% CPU usage and increased device temperature due to the checkPairingState being run each second

Open chichkanov opened this issue 11 months ago • 1 comments

Describe the bug Hello WC team! We experience a huge CPU usage and highly increase device temperatures while using your SDK. We use WalletConnect Swift Web3Modal, but according to the logs the issue is in the main WC Swift V2 library. From what I've found you setup a timer in PairingStateProvider which updates each second and inside it Decodes the sessions from the storage.

SDK Version

  • Client: Swift
  • Version: 1.13.0

To Reproduce Steps to reproduce the behavior:

  1. Initialize WC SDK
  2. Open Xcode App profiler and check CPU usage

Expected behavior No high CPU usage.

  1. If it is essential to check session each second, at least cache them in-memory to avoid long running operations.
  2. Moreover, some of these operations are happening on the main thread, which also affects an app performance

Screenshots Attaching the place where the issues is located

Screenshot 2024-03-21 at 2 57 32 PM

Device (please complete the following information):

  • Device: iphone 15 pro max
  • OS: ios 17.4
  • Browser - (native app)

chichkanov avatar Mar 21 '24 12:03 chichkanov

thanks for reporting this, I will investigate.

llbartekll avatar Apr 26 '24 06:04 llbartekll

Hello guys! Do you have any news/updates? Thanks!

alexanderkhitev avatar Sep 04 '24 08:09 alexanderkhitev

Hey, yes, we expire pairings earlier now and there should not be as many objects in the storage anymore. Please upgrade to the latest version

llbartekll avatar Sep 04 '24 12:09 llbartekll

Hey, yes, we expire pairings earlier now and there should not be as many objects in the storage anymore. Please upgrade to the latest version

Hey! Ok, thank you!

alexanderkhitev avatar Sep 04 '24 14:09 alexanderkhitev

Hey, yes, we expire pairings earlier now and there should not be as many objects in the storage anymore. Please upgrade to the latest version

Hello @llbartekll ! Thanks it works for us and the new version fixed this issue.

alexanderkhitev avatar Sep 13 '24 10:09 alexanderkhitev

thanks for confirming, closing the issue then

llbartekll avatar Sep 13 '24 11:09 llbartekll