getsentry / getsentry/sentry-java
ANRWatchDog reports ANRs from another app when used in the system app
- 主要語言
- Kotlin
- 星號
- 1.4k
- 分支
- 478
- 平均合併
- 3 天 4 小時
- 30 天內合併 PR
- 72
描述
### Integration
sentry-android
### Build System
Gradle
### AGP Version
8.6.1
### Proguard
Enabled
### Version
8.11.1
### Steps to Reproduce
Other environment details: Android 6
1. Make the main app (when sentry installed) a system app. To achieve that, add `android:sharedUserId="android.uid.system"` to the android manifest
2. Trigger an ANR in another app - can be just an example app that simply uses Thread.sleep in the main thread
3. In the main app, we use Workmanager and some periodic workers, so the application eventually wakes up, then sleeps.
To simplify testing, I did something like in the main app:
```
viewModelScope.launch {
while (true) {
Timber.tag("ANR").i("isAnr=${ANRWatchDog.isProcessNotResponding}")
delay(5000)
}
}
```
Then, I opened another app which simply sleeps forever in onCreate.
This is happening because ANRWatchDog.isProcessNotResponding may return false positives for __system__ apps. That's happening because for system app `am.getProcessesInErrorState()` may return processes that do not belong to the current app because of wider permissions. I was able to validate this by checking `ActivityManager.ProcessErrorStateInfo.processName`.
### Expected Result
Main app doesn't report ANR from other apps
### Actual Result
Main app does report ANR from other apps
貢獻指南
研究方向
從 ANRWatchDog.isProcessNotResponding 以及報告中描述的 ActivityManager.ProcessErrorStateInfo.processName 值開始。在 Android 6 上使用一個設定了 android:sharedUserId="android.uid.system" 的系統應用程式,以及另一個會觸發 ANR 的應用程式進行重現;當主要應用程式不再回報另一個應用程式的 ANR 時即表示完成。
由索引模型根據 Issue 內容生成。
評估
- 技術堆疊
- android, kotlin
- 領域
- mobile, observability
- Issue 類型
- 缺陷
- 難度
- 3/5
- 預估耗時
- 1-2 天
- 活躍度
- 停滯
- 描述清晰度
- 基本清楚
- 新手友好度
- 45/100