-
-
Notifications
You must be signed in to change notification settings - Fork 34
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Subscriptions Block UI thread #75
Comments
I was having the similar problems. I ended up having to do pretty hefty changes to make sure we aren't oversubscribing and that we only get change notifications when we want. I'm not sure how much of my changes ended up being unique to my experience, but if you are still looking for a solution this is a good starting point: https://github.com/ToyboxZach/meteor-react-native My app got significantly better after these changes |
@ToyboxZach, would you be open to possibly merging your changes into this repo? |
I don't have the time to thoroughly validate it across all use cases or maintain it outside of times my product has a bug, but I can definitely open up a PR |
Also do you have resources explaining how to run the tests? "npx mocha" doesn't seem to work for me like I would expect |
I think react native's new fabric architecture should solve this problem. From my experience, if you have a large list with lots of nested components and you try to have subscriptions like so: const MyAppContainer = withTracker(() => {
})(MyApp); The UI thread will be blocked, the only work around for me was using meteor methods. But hopefully this will be solved. |
@jankapunkt could you provide info regarding testing? |
If I have an example component that shows how to reproduce these oversubscription then I can fast test/debug/provide a fix if possible |
Merging in master resolved this. For clarification on what the problem is in master: Every time you register a callback it gets added to a generic "changed" callback, that means that every single callback needs to be called on every single change to a collection which causes a huge hold up on the UI thread. To make it even worst the subscriptions don't get cleaned up when you resubscribe so every time a "withTracker" or "useTracker" was called you would get stacked subscriptions. This then would lead to 100 plus subscriptions for a single component after some time which leads to bigger and bigger slow downs. My PR separates that out as much as possible and makes sure that you only have as many subscriptions as you actually need. It is a pretty hefty change and I don't personally use and local collections in my app so those are going to be pretty poorly tested, but if other people want to take my change as a jumping off point I think its a pretty good point for server only subscriptions. |
I'll try to get an example I had into a demo repo. This was only a problem on android If I remember correctly. But give me a couple days to get the repo back up. |
The part that causes over subscriptions is in useTracker const meteorDataDep = new Tracker.Dependency(); will be called every render loop. Which means you are just stacking dependencies. fixes that part in useTracker.js |
Here is the best reproduction I could get. One file, main.js subthread is just a document of post, you can create a sample subscription:
hope this helps |
Closing this issue due to no activity. Feel free to reopen. |
…y better Merge pull request #111 from ToyboxZach/Merge Restructure how we handle the Tracker, instead of a global listen to any change make the listens happen on specific queries and collections. Also fixes some bugs where we would generate way too many instances of subscriptions. This also fixes the log in flow so the series of loggingIn -> LoggedIN is consistent and doesn't allow the package to ever auto log you out as that should be handled by the owning app just like in base meteor. Every time you register a callback it gets added to a generic "changed" callback, that means that every single callback needs to be called on every single change to a collection which causes a huge hold up on the UI thread. To make it even worst the subscriptions don't get cleaned up when you resubscribe so every time a "withTracker" or "useTracker" was called you would get stacked subscriptions. This then would lead to 100 plus subscriptions for a single component after some time which leads to bigger and bigger slow downs. My PR separates that out as much as possible and makes sure that you only have as many subscriptions as you actually need. It is a pretty hefty change and I don't personally use and local collections in my app so those are going to be pretty poorly tested, but if other people want to take my change as a jumping off point I think its a pretty good point for server only subscriptions. This also fixes up weirdness with the logging in and order of events where you would have an invalid user state or it would force you to logout because of bad internet Likely fixes these erorrs: #75 #58 and maybe #79
I was have been using the old repo before migrating to yours. This is an important issue worth reviewing
inProgress-team/react-native-meteor#301
The main benefit of this library is subscriptions. For large list or complex components, subscriptions can cause weird rendering problems.
Some content can be partially rendered.
I've tried the InteractionManage, not very helpful. React native is single threaded. Not sure if we can use a background process for this. Just an idea
The text was updated successfully, but these errors were encountered: