Repository navigation
Fix the Android freeze after the timeline loads - #327
Conversation
…pegging the phone Stay detection copied and sorted the reported accuracy of every sample in a stay each time it checked the next sample, so a day spent in one place cost time and memory that grew with the square of its samples. A phone with months of background location spent minutes of CPU and constant garbage collection rebuilding days after the timeline loaded, and the app stopped responding while it did. A growing stay now keeps its accuracies in order as it adds them and reads the median directly, which picks the same value as before, so every stay and visit comes out unchanged. A whole day sampled every two seconds now reconstructs in well under the test's ten second budget. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QRSSFdu7yRMwr8c9upd3o3
… timeline loads Since day cards started listing places from location history, building a day read every location sample around it and reran stay detection. The timeline rebuilds its days whenever a note, caption or transcript in its window changes, and each rebuild reconstructed every visible day again, so the phone stayed busy for as long as anything kept changing. Each day's history is now reconstructed once and reused for five minutes across rebuilds and older pages, for up to 64 days. A day card's places can trail new location samples by up to five minutes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QRSSFdu7yRMwr8c9upd3o3
|
The failure in Generated by Claude Code |
|
The other "Managed native restore" jobs (work-restart, widget, missing-keys, d2d, publication, data-only, privacy, archive) failed the same way as contracts: Generated by Claude Code |
Requested by Willie · project thread
TL;DR
The app became unresponsive right after the timeline loaded. Every timeline day card rebuilt that day's location history from raw samples (added in a4d7129), and stay detection was quadratic: for each new sample it copied and sorted the accuracy of every earlier sample in the stay. The timeline also rebuilds its cards on any note, caption or transcript change, so the phone kept redoing that work on every core with heavy garbage collection.
Changes
fix(location-timeline):StayDetector.growkeeps a running sorted list of anchor accuracies (SortedAccuracies) and reads the median directly. That picks the same element asdynamicCoreRadius, so stays and visits are unchanged.StayDetectionCostTestreconstructs a 43,200-sample day (0.19s on the Studio) and checks that the running median matches the per-anchor radius on random inputs.fix(timeline):TimelineDayHistory(a Koin single) reconstructs each day's history at most once every 5 minutes, holding up to 64 days, and shares it across timeline rebuilds and older pages. Tradeoff: places on a day card can lag new location samples by up to 5 minutes. Covered byTimelineDayHistoryTest.Verification
This ran on the Studio, because this container gets HTTP 429 from Maven Central.
:client:domain:jvmTestpassed: 1,406 tests, 0 failures.GoldenLocationBenchmarkTest,ReconstructLocationDayTestand the new tests all pass.:client:domain:ktlintCheckand:app:android-main:assembleDebugpassed.flagshipPhoneApi37Gradle Managed Device: 2,000 notes with media, 172k location samples and Places beta on. The multi-core reconstruction burst after launch dropped from about 9s to under 3s. GCs in that window fell from 106 to 14. Max main-thread ping fell from 875ms to 292ms, with 0 skipped frames or Davey reports. There were no ANRs before or after the change.Follow-ups and Next Work
location_logs. The suspect isLocationChangeMilestoneDetector. It's unrelated to the freeze and isn't changed here.OnboardingTestFixture(hasCloudAccount = true)crashes with "Session authorization changed".Generated by Claude Code