fix: move AIDL binder calls off main thread to prevent ANR (COLUMBA-3X)#524
fix: move AIDL binder calls off main thread to prevent ANR (COLUMBA-3X)#524torlando-tech merged 1 commit intomainfrom
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Greptile SummaryThis PR fixes a background ANR issue (COLUMBA-3X) by moving synchronous AIDL binder calls off the main thread. The changes correctly wrap Key Changes:
Analysis: Note: Confidence Score: 5/5
Important Files Changed
Last reviewed commit: e0758fe |
app/src/main/java/com/lxmf/messenger/viewmodel/InterfaceStatsViewModel.kt
Outdated
Show resolved
Hide resolved
getRNodeRssi() and getInterfaceStats() are synchronous AIDL binder IPC calls that can block for seconds during BLE hardware reads. Wrapping them in withContext(Dispatchers.IO) prevents background ANR on the main thread while keeping coroutine lifecycle tied to viewModelScope. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
ddd0a0e to
e0758fe
Compare
Additional Comments (1)
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time! Prompt To Fix With AIThis is a comment left during a code review.
Path: app/src/main/java/com/lxmf/messenger/viewmodel/InterfaceStatsViewModel.kt
Line: 209
Comment:
`reticulumProtocol.getInterfaceStats()` already wraps the AIDL call in `withContext(Dispatchers.IO)` at ServiceReticulumProtocol.kt:2025. Consider removing the outer wrapper to reduce nesting.
<sub>Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!</sub>
How can I resolve this? If you propose a fix, please make it concise. |
Summary
getRNodeRssi()andgetInterfaceStats()AIDL binder IPC calls inwithContext(Dispatchers.IO)to prevent background ANR when the service is slow (e.g. BLE hardware reads from RNode)RNodeWizardViewModel.startRssiPolling()andInterfaceStatsViewModel.refreshStats()which both called synchronous AIDL onDispatchers.Mainfix/anr-rssi-polling-v0.8.xTest plan
./gradlew :app:compileNoSentryDebugKotlinpasses./gradlew :app:testNoSentryDebugUnitTest --tests "*.RNodeWizardViewModelTest"passes./gradlew :app:testNoSentryDebugUnitTest --tests "*.InterfaceStatsViewModelTest"passes🤖 Generated with Claude Code