Replies: 1 comment 4 replies
-
Hi @takehilo, there is actually a PR open right now that fixes that from @iampatbrown. Could you point your project to that fork and verify that it fixes your issue? That would provide a good data point for us to evaluate the PR. |
Beta Was this translation helpful? Give feedback.
4 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Our app has a vertically scrolling news feed using UICollectionView and TCA (version:
1.6.0
). The cells are not of a single type; different types of cells are displayed for each section. The cell views are implemented in SwiftUI, and we pass the scoped Store to the SwiftUI views.Here is a snippet of the implementation:
During scrolling, we are sending some actions. For example, in the scrollViewDidScroll method of UICollectionViewDelegate, we send an action when half of the cell height is displayed.
To ensure that an action is sent only once per cell, the frequency of action dispatch is not overwhelming. When the feed is reloaded, the state is reset, and actions are sent again.
The problem arises when repeatedly reloading the feed and scrolling; gradually, scrolling becomes laggy. Initially displaying the feed and scrolling works smoothly.
After checking the memory graph, we noticed that the number of instances of CurrentValueRelay.Subscription keeps increasing. It starts with around 100 instances at app launch, but after repeating the feed reload and scrolling, especially when it becomes laggy, there are thousands of instances.
CurrentValueRelay.Subscription is created with ifLet or ViewStore.init. As these methods are called every time a cell is displayed, the number of instances keeps increasing.
Changing the implementation to not have the Store in the cell resolved the laggy scrolling issue. However, in our app, there are use cases where we need to have the Store in the cell to change the cell appearance based on state changes.
In my view, the continuous increase in CurrentValueRelay.Subscription instances is the likely cause, but are there other possible reasons? Additionally, do you have any ideas for a better implementation?
Beta Was this translation helpful? Give feedback.
All reactions