getsentry / getsentry/sentry-java
Run the Integration.register() loop off the main thread (two-phase init)
還沒有人認領這個 Issue。
- 主要語言
- Kotlin
- 星號
- 1.4k
- 分支
- 478
- 平均合併
- 3 天 4 小時
- 30 天內合併 PR
- 72
描述
Problem
Sentry.init registers all integrations synchronously on the calling thread (sentry/src/main/java/io/sentry/Sentry.java:374-385) — the main thread under auto-init. With ~17 default Android integrations this is the biggest remaining block of main-thread init work once the per-integration items (NDK etc.) are fixed.
Proposal
Keep a minimal synchronous core — options, scopes, SentryClient binding, UncaughtExceptionHandlerIntegration — and submit the rest of the registration loop to options.getExecutorService(), with an opt-in marker for integrations that genuinely need the main thread (AppLifecycleIntegration already self-posts when off-main).
Sentry.captureX immediately after init() keeps working: the client is bound synchronously and events queue on the transport.
Constraints
- The deliberate startup-crash blocking flush (
sentry-android-core/.../SendCachedEnvelopeIntegration.java:151-161) must still blockinit()— needs an explicit carve-out. - Integration ordering guarantees (NDK before outbox watcher, AppLifecycle before ANR, ANR before Replay — see comments in
AndroidOptionsInitializer.installDefaultIntegrations) must be preserved. The single-threaded executor keeps submission order, but mixed sync/async registration could break it; audit each. - Session auto-start +
isForegroundImportance()at the end ofSentryAndroid.init(SentryAndroid.java:184-203) depend on integration state (LifecycleWatcher) — decide whether they move too.
Concrete follow-up to getsentry/sentry-java#5475 ("Move more init code async").
貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
研究方向
從 sentry/src/main/java/io/sentry/Sentry.java:374-385 中的註冊迴圈以及 AndroidOptionsInitializer.installDefaultIntegrations 中關於順序的註解開始。接著檢查 SendCachedEnvelopeIntegration.java:151-161 和 SentryAndroid.java:184-203。完成的標準是定義同步階段和由 executor 支援的階段,同時保留啟動當機時的 flush、整合順序以及工作階段或前景狀態行為。
由索引模型根據 Issue 內容生成。
評估
- 技術堆疊
- android, java
- 領域
- mobile-dev, performance
- Issue 類型
- 重構
- 難度
- 5/5
- 預估耗時
- 一週以上
- 活躍度
- 冷清
- 描述清晰度
- 基本清楚
- 新手友好度
- 35/100