Repository navigation
Closed
Labels
androidPrimary Android workbugSomething isn't workingcrashApp crash reported by Crashlyticspriority: highActive V1 blocker
Description
Summary
New ANR cluster on the newest Android release 1.4.0 (37): the main thread is stuck in SessionFamily.memberIds / SessionFamily.resolveRoot while the Home list recomputes rows from live data.
| Crashlytics issue | Events | Users | Top frame |
|---|---|---|---|
27876e6c003b436dd89938681d30dabe |
10 | 1 | SessionFamily.resolveRoot (SessionFamily.java:218, mutableSetOf) |
b0f05655cbed44b8cf2dad1ea5d36054 |
7 | 1 | SessionFamily.memberIds (SessionFamily.java:434, HashMap.put) |
79f77c0a4aa13eb4f4f0060209e5efee |
1 | 1 | SessionFamily.resolveRoot (LinkedHashSet.<init>) |
- Total: 18 events, 1 user, all on 1.4.0 (37). Build 37 has 138 sessions so far (Nov 3–4).
- Device: realme RMX3741, Android 15 (API 35). Both foreground and background.
- Window: Nov 4 2026, 18:46–19:12 CET.
- First seen today; none of these showed up on older builds.
Stack path
MainScreenViewModel.startLiveObservations combine{...}.collect (main thread)
-> MainScreenViewModel.updateSectionFromLiveData
-> MainScreenViewModel.homeSummaries
-> SessionActivitySnapshot.homeActivitySessionId
-> SessionFamily.memberIds
-> SessionFamily.resolveRoot -> mutableSetOf / HashMap.put
Root-cause hypothesis (code on main @ 2803d3d)
The Home row family lookup is quadratic and runs on the main thread for every live emission:
MainScreenViewModel.kt#L1512-L1528:startLiveObservationsrunscombine(observeSessions, observeActivity, observeReadyIds).collectinviewModelScope.launch, which defaults toDispatchers.Main. Each session or status event (streaming status updates come in very often) callsupdateSectionFromLiveDataon the main thread.MainScreenViewModel.kt#L1805-L1818:homeSummariescallssnapshot.homeActivitySessionId(session.id, family)once per root session.SessionModels.kt#L174:homeActivitySessionIdcallsSessionFamily.memberIds(rootId, sessions)again for each root.SessionModels.kt#L199-L210:memberIdsrebuildsparentById = sessions.associate {...}(O(N) map) for each root. It then callsresolveRootfor every session.SessionModels.kt#L213-L224:resolveRootallocates a newmutableSetOfand walks the parent chain each time.
The cost per emission is O(roots × sessions × depth), with about roots × sessions short-lived set and map allocations. A worktree with many sessions and sub-agent children makes this heavy work on the UI thread, and it repeats on every status tick. The ANR frames sit in HashMap.put / LinkedHashSet.<init>, which fits allocation and GC pressure, not an infinite loop (seen already guards cycles).
Suggested fix
- Build
parentByIdand arootOfmap once perhomeSummariescall, memoizing resolved roots. Group the members by root so each root's lookup is O(1) and total cost is O(N). - Move
homeSummariesoff the main thread (flowOn(Dispatchers.Default)/withContext(Default)). Considerconflate()/debounce on the combined live flow. - Add a perf test in
SessionFamilyActivityTestwith something like 500 sessions and deep chains.
Labels: crash triage, Crashlytics project opencode-mobile-release.
Metadata
Metadata
Assignees
Labels
androidPrimary Android workbugSomething isn't workingcrashApp crash reported by Crashlyticspriority: highActive V1 blocker
Activity
#981 Keep paging an empty filter and when a window gains more
#981 Page Home sessions and roll up busy sub-agents off the main thre…
ivanfenenko commentedon Nov 6, 2026
Crashlytics triage, 2026-11-06: fix PR #984 (
8adeb6112a, merged 2026-11-05 10:18 UTC) closed this issue, and it is now in a release build.a6e744cd65(Bump app versions: Android 1.4.1, iOS 1.3.1 #986), built 2026-11-05 11:25 CET: https://github.com/opencode-mobile/opencode-mobile/actions/runs/42010644249 . Compare showsa6e744cd65ahead of8adeb6112a.27876e6c(11 events / 1 user),b0f05655(8 / 1) and79f77c0a(1 / 1), all from the same realme RMX3741 user. Build 37 has 400 sessions; no new events on these signatures since yesterday's count.27876e6c,b0f05655and79f77c0a.3f7e7e9b(AndroidComposeView_androidKt.C, 1 event / 1 user on 1.4.0 (37)). It's below the filing threshold.