-
Notifications
You must be signed in to change notification settings - Fork 484
Load uitableviews faster? #211
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Can you provide an instruments (time profiler) trace for what's taking the most time? If it's not something in FirebaseUI I'll file an internal issue so the core Firebase team can take a look. It's possible an instruments trace won't be that useful if it's all asynchronous waiting, but it's worth a try nonetheless. |
Sure, I just took one. Do you want me to attach it here? I didn't see anything compelling in it but am happy to try any/all messing around to improve this. FirebaseUI is a really great code pattern for us! |
If it's got symbols of your project that you'd like to keep hidden from public view, you can email it to me at morganchen@google. |
This @morganchen12, I emailed you the trace. Let me know if anything else would be helpful - I'll try to do some more debugging on this side as well. We can make a data set available publicly if it helps at all. |
Looks like FirebaseUI is causing some slowdown here, probably since we begin and end updates after every insert. It's still not the majority of the time spent here, but should make your app feel more responsive if we were to get rid of it. Having some formal initialization for FUIArray has been proposed in the past but not implemented for reasons I can't remember. For now you can work around it by wrapping FUIArray in your own data source and using |
I'm coming out of Realm, and wonder if the technique used there would work here. Basically, they get one main data set immediately when loading the view, and render that in the tableview with a traditional, non-animated I'm not really sure how to go about that here, though. I'm not too worried about netting together the updates because in practice, most updates tend to be a single operation anyway (once the table is rendered the first time). But how would one go about the first piece, doing a traditional reloadData for the first rendering pass? |
If your query is limited to some number of objects (which it should be if your collection in Firebase Database may be unbounded), you can track insertions until you reach that number, then call reloadData once, then set some state that says the initialization has finished. It's gross because you have to attach state to your objects but otherwise should be relatively simple. Having initialization from the Firebase queries themselves is possibly something work looking at. |
That makes sense, but it sounds like it precludes using FirebaseUI and doing the data source management manually, no? |
Yes, to an extent--you'd only have to write your own data source, but you could reuse FUIArray. |
It seems from reviewing the developer docs that If I find a clean solution to this would you entertain a PR to enhance |
I think we should provide initialization and behavior for changing the query to accommodate the relatively common case of having an unbounded list that a user scrolls through that only loads some content at a time. Say you have a Twitter-like app that loads the first ~50 items when launched, but as the user scrolls you want to load more. Our goals here should be:
This would solve your problem while still being adaptable to other use cases. |
Is there anything I can do to facilitate that? FYI I just did some more testing with a combination of persistence settings, attempts to pre-subscribe to the data set, moving the population work to
My particular application is more interested in value updates than live insert/delete operations so a combination of |
PRs are always welcome! |
One thing I'm experimenting with right now is using FUIArray directly, but adding a I then evaluate against this in my This doesn't seem to solve the entire problem but it does seem to be a lot faster. I'd appreciate your thoughts on this pattern and how it aligns with how you mean this library to be used... In particular, are there holes/edge cases where |
It's reasonable and does solve your particular problem, but lacks flexibility. I think an ideal solution in terms of speed would be to only load data through Alternatively, a simpler solution if you don't mind discarding animations would be to create a dumber array that only sends events on any update and call |
Yeah, I'm trying to marry these two things together and it's a little tricky. It seems to me that iOS really expects you to be providing an initial, already-loaded dataset by or before viewWillAppear, to provide the best visual experience. There's a dataSource call to ...rowsInSection just after that, and although I obv. don't have the source for this I can imagine the Apple core devs wired up tableviews such that the initial data load automatically doesn't have animation. For a lot of my data sets I do actually know what I'm going to need and when ahead of time. I wonder if the best thing to do would be to pre-subscribe to these things, not the "normal Firebase way" of
but rather having a database service singleton that set up these FUIArrays when the app started and just provided references to them when the views needed them. This would keep a lot of data in memory so I need to figure out whether that's practicable - my data isn't huge, but I don't want to be too crazy here. But for 6-8 data sets it's probably manageable, and would let the views themselves load almost instantly, no? Does this sound crazy/stupid? Is there any better way? I feel like I'm overbuilding it here but remember, there's just one simple initial goal: user complaints that on every view appearance, the tables animate-reload with data they already saw. Any way of eliminating that is problem-solved... |
Table views should behave fine when empty. If you'd like to preload stuff, I'd suggest you use Reachability to check if you're on wifi first and preload content more aggressively if you are. There's nothing wrong with loading content beforehand, especially if it's content you can guarantee your user will see and it's content that's valuable. Try to avoid doing things like preloading ads before actual content on mobile data. Preloading with a singleton can sometimes add massive complexity to your app/tests. |
No, the pre-loading is just a goose chase. The only important goal is to eliminate the initial on-load animation when the first records are being displayed. In iOS, tableviews aren't supposed to animate-load - animations are usually for updates, not load events. It's disconcerting to the user because the 700ms or so it takes this to get through makes the views look very "slow". If there's a quick way to do this it would be ideal, even if it's a hack, that would be great. If not, manually managing the FUIArray, using |
#186 has been merged. Release coming soon. |
v2.0.0 has been released. This behavior should be fixed automatically for UITableView if you're using Feel free to reopen if you run into any issues. |
Is there anything I can do to speed up UITableView loads? Even when using persistent/cached data (and I've confirmed this via Airplane Mode) it takes a long time to populate a UITableView with its first cells. Here's a quick/dirty NSLog dump population a table with a few rows:
I set up the query in viewWillAppear, hence the tracking for those. After setting up the query and datasource, there's about a 700ms wait before rows begin to populate. This delay is VERY visually noticeable particularly because we have a "You have not yet..." empty message for this table encouraging users to interact with the app to get data to appear.
This delay occurs EVERY time the view appears, not just the first time, and as I said, it happens even while in Airplane Mode using offline data, so it's not network-related.
I don't mind if the solution is some sort of hack - I like the workflow here enough that a hack would be fine. Does anybody have any idea how to speed this up? It would be really ideal if we could get this into the <200ms range.
The text was updated successfully, but these errors were encountered: