-
Notifications
You must be signed in to change notification settings - Fork 32
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
Find a solution for application hang #52
Comments
I'd vote for this even if it's not the (main) cause of the bug. It's pretty easy to expose a list to QML nowadays by subclassing QAbstractListModel. This would also ease the performance optimization changes I mentioned in my comment to #20 by moving data out of QML files and making them more stateless. |
Yea i think both possible fixes should be combined, because building the list model should also run in a different thread for performance. I think this is easy and fast to implement, i hope i find the time implementing this. |
Ok i looked into the threading stuff, it could be implemented but i'm still checking the best approach. Most samples (and the implementation for the calendar) based on single functions/tasks moved to threads not a whole class/object like the parser. I found documentation about moving a whole object into a thread, but then the communication with that object gets complicated. you can not longer call the parser directly, but need to either "invoke" the methods or use signals. |
Ok, here is my implementation of the threading thing, what do you think? After thinking about the listmodel thing i'm not sure if its really a good thing, where should we put it, its gui specific. There is the posibillity that one gui uses more or less or simple different data from the result object. I tested with just the threading and the searching of connections looks well better on my N950. (to test use Öbb.at, it uses a huge response xml) |
I quickly skimmed through the code - looks ok to me. Will try to take a closer look this weekend, if I have enough time.
I would disagree on that. QAbstractListModel is very general and it doesn't depend on UI. Except for BlackBerry Cascades, it can be used directly on all supported platforms. But Fahrplan for BlackBerry doesn't use Cascades yet, so no problem here. And it's always possible to write platform specific adapter if necessary. Regarding different sets of data - we don't have this case currently and if this different data comes down to only different sets of fields, then no problem at all - model can generally provide all possible fields and UI will use only the ones it needs. Generally speaking, switching to directly using QAbstractListModel would simplify code and should improve the performance. |
Ok, After some tests on Harmattan with just the thread changes, the application hang should no longer occure. With general switching to QAbstractListModel do you mean get rid of all structs like "StationsResultItem" or what exactly do you mean :) |
But don't wait too much: my spare time is quite limited nowadays, since becoming a father 12 days ago :-)
What I mean is converting, for example, StationsResultList into QAbstractListModel derived class. In this case all list fields that were properties of StationsResultItem before, will be exposed as roles of the model. Then this model can be directly "plugged" into QML ListView. onParserStationsResult handler will become obsolete. Additional benefit to this would be that all pages that display results will become stateless -> no need to create and keep them on application start -> lower memory footprint and faster startup time. StationsResultItem might still be useful in case there is a need to retrieve all fields at once (e.g., returning the whole object contents the same as get() method of ListModel does). |
Generally, I would make the whole UI stateless. Currently there is some business logic present in UI and it needs to be copied and updated when changed for all platform UIs. Let's take departure station as an example. It is stored as a string on UI side. Most probably, you noticed that it's not easy to change station from string into an object that can store more than just a name (e.g., ID): this change involves changing UI-side code or it will break. I was thinking how this can be fixed and one solution is:
The benefit of this approach would be that if you need to add some additional data to station object it won't affect UI at all. UI will continue to display station name provided as a property by FahrplanBackend. UI will continue to select a station by its index in the list and FahrplanBackend will take care about what data it needs to retrieve/save from the list based on this index. Nothing will need to be updated on UI as long as you don't change display-related property names. This is just a rough idea of what I see can be done. I'm sure other approaches exist as well. |
First of, congratz to your fatherhood. About the stateless approach, i really like the idea, it will be quite a lot of work, but i think it would be really great. But i think for that i will create a separate ticket/issue |
See discussion in issues smurfy#52 & smurfy#62 at https://github.com/smurfy/fahrplan.
Here's a quick conversion of FarplanFavoritesManager to QAbstarctListModel to illustrate what I mean :-)
Thank you.
Yes, it's quite some work so sounds like separate a issue is needed (and I can see you created one already). |
Ok, looked through 5a317f1 and it looks good. Also, quickly tested it on BB10 - UI stays responsive during search and parse stages. Didn't notice any regressions, so I think you can merge it. |
Some backends (mainly öbb and possible bahn.de binary) could cause a application hang.
Possible Reasons:
Possible Fixes:
The text was updated successfully, but these errors were encountered: