WalletConnect / WalletConnectSwiftV2

WalletConnect Swift SDK v2
https://docs.walletconnect.com
Apache License 2.0
368 stars 180 forks source link

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

Closed chichkanov closed 1 month ago

chichkanov commented 7 months ago

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

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):

llbartekll commented 6 months ago

thanks for reporting this, I will investigate.

alexanderkhitev commented 2 months ago

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

llbartekll commented 2 months ago

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

alexanderkhitev commented 2 months ago

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 commented 1 month ago

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.

llbartekll commented 1 month ago

thanks for confirming, closing the issue then