twoolf / circator

Metabolic Compass: A Circadian Monitoring Mobile Health Stack
https://www.metaboliccompass.com
Apache License 2.0
6 stars 1 forks source link

long load times for HK on first screen #64

Open twoolf opened 8 years ago

twoolf commented 8 years ago

Consistent over last two days is that it takes a minute or longer for the HK store to put the personal values up on the first screen -- population values are up quickly -- we should make that faster or provide some indicators for why it is delayed -- the only item coming up in the log is 'refreshing population aggregate', so perhaps we have a thread blocking the refresh on the dashboard and should consider putting them into a different order.

Following up on this, current code efforts are only making this worse; right now (on device) it fails to even call up any items for display from the HK; most likely this is the same error, and so currently working on the idea that some thread is blocking the completion and/or that it has gotten slower

More followup, without a current candidate for solution, but it appears that HK deletes all Sources for data read/write under some conditions. We'd seen it lock up on reading from HK store, but not that it ever lost the list of Apps that it had already agreed to read/write. These re-appear on re-boot, but they shouldn't be disappearing mid-stream. The current problem on the first screen is at least in part due to whatever process is causing the memory of the Sources in HK to disappear.

This stack overflow seems to address the same problem: http://stackoverflow.com/questions/36582705/how-to-speed-up-hkstatisticscollectionquery-in-ios-9-3

Still in progress, but one note is that using QOS_CLASS_BACKGROUND the blocking of access to HK seems to clear; not yet getting reasonable load times and so needs more tuning, but with QOS_CLASS_USER_INTERACTIVE it still blocks, so this supports that at least part of the problem is with the queue/threads system interactions with HK from the App. Currently working to define better which QOS classes can be supported in the code and not block HK, so tuning up from BACKGROUND.

sokol8 commented 8 years ago

@twoolf could you point out device model and OS version. Values appear fairly fast on my iPhone6 with iOS 9.3.

This may work fine for me due to low number of data points as well.

twoolf commented 8 years ago

iPhone 6S plus with iOS 9.3.1 -- about a year's worth of data on the phone --

conny-the-unicorn commented 8 years ago

Put into backlog to double check and fix