ericberman / MyFlightbookAndroid

Android client app for MyFlightbook.com
http://myflightbook.com
GNU General Public License v3.0
21 stars 8 forks source link

Stuttering UI when changing block time and total time is set to be block time #234

Closed ericberman closed 3 years ago

ericberman commented 3 years ago

In preferences I've changed the total time to be equal to Block time. Once I've done that and I'm editing the block (out or in) in a specific flight, it is very slow (the time spinner movement). I guess it is because it update the total time and SIC and X-country time fields in real-time and not just after I press the ok button

ericberman commented 3 years ago

Some quick analysis on this: looks like it's about 130ms to update a time when no autototal, about 300-350ms when autototal from block, and about 250ms when autototal from flight/engine. So slightly slower from properties. But properties also has more to update due to the architecture there.

May not be much I can do about this due to the UI updates propagating, except possibly setting a background timer and updating after that timer. I'm not doing anything particularly computational here, it's the UI updates that seem to be slowing things down and the properties just...have more updating going on (partly because they're in two places)

I can cut all of this down to around 150ms regardless of source by only doing selective UI get/set, but I'm leery of doing that because it's fragile to do so. That is, right now when I do autototals I do "get data from the UI " to ensure that the state of the flight is up-to-date, then I autototals, then I do a "set form from the data" to update the UI from the form. My speed up is from not doing the blanket get/set but rather to selectively get/set specific affected fields. Works, but it means that I would have two places in the code where I get/set data; that is an invitation to bugs down the road where things can get out of sync, or where I miss something that I need to get/set, so I'm loathe to do this change.

BTW, I'm not updating SIC fields. If it's a real aircraft, I update total and XC field if it's over 50nm (so there's some computation there as well); if it's a sim, I only update ground sim. This is also part of the performance.

Yes, the fields are all updated in real-time. It's the only way to make sure things stay in sync, especially since these changes (e.g., if sourced from flight or engine times or even hobbs time) can happen without user intervention.

I'll keep this open in case I see something with eggregiously bad performance that I can improve, but it looks like the bulk of the performance here is at the android level - getting a value from a UI element on the screen and setting a UI element based on the value of its data.

ericberman commented 3 years ago

Looks like I can in fact wait for OK/None/Now to be tapped.