App Check (Play Integrity) token request never completes after Play Store self-update; Auth and Realtime Database hang with it
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 43/100
- issue の種類
- バグ
- 明瞭さ
- おおむね明確
- 活発さ
- 活発
調査の方向性
Start by reading the App Check token caching and provider installation behavior described for DefaultFirebaseAppCheck in the issue, then trace the Play Integrity provider request path and its service binding. The issue reports no reproducer, so first investigate how a Play Store package update affects an in-flight request. Done means requests recover or fail instead of remaining pending, with coverage for the failure path.
索引モデルが issue の本文から書いたものです。
説明
[REQUIRED] Step 2: Describe your environment
- Android Studio version: not relevant (AGP 8.13.2)
- Firebase Component: App Check (Play Integrity provider), Auth, Realtime Database
- Component version: BoM 34.19.0 → firebase-appcheck 19.4.1, firebase-appcheck-playintegrity 19.4.1, com.google.android.play:integrity 1.4.0, firebase-auth 24.2.0, firebase-database 22.0.2, play-services-tasks 18.4.1
- Device: Samsung Galaxy Tab S5e (SM-T720), Android 13, screen permanently on, not in Doze, app exempt from battery optimization
- Play Store: 53.9.23-31, self-updated while our app was running
[REQUIRED] Step 3: Describe the problem
After the Play Store updated itself in the background, the App Check token request never completed – neither success nor failure. Because Firebase Auth waits for the App Check token without a timeout, the ID token request hung as well, and the Realtime Database stayed disconnected for more than 75 minutes although the network was fine. Only restarting the app process fixed it.
App Check is not enforced for any product in our project, so the app had no reason to wait at all.
Timeline (device time)
- 06:09:42 Play Store update installed. System log:
Force stopping com.android.vending … installPackageLI, thenForce stopping service ServiceRecord{… com.android.vending/com.google.android.finsky.integrityservice.IntegrityService}(pkg removed). The new Play Store process started at 06:10:07. - 06:27:07 Realtime Database reports disconnected (around the time the cached tokens expired).
- 06:29:29 Our watchdog calls
FirebaseAppCheck.getAppCheckToken(false)andFirebaseUser.getIdToken(false). Neither task ever completes. Logged every 5 minutes until 07:44:request still open after 4502 sfor both. - During that time: DNS and TCP to the database host and firestore.googleapis.com work (20 ms), network is validated, no Doze, screen on. Three
goOffline()/goOnline()cycles do not help. - 07:48 App process restarted → database connected within 4 seconds.
Thread dump while hanging (jdb, debug build)
Six threads like this one, all in Firebase Auth waiting for a task:
Firebase Blocking Thread #106:
[6] java.util.concurrent.CountDownLatch.await (CountDownLatch.java:232)
[7] com.google.android.gms.tasks.zzaa.zza (com.google.android.gms:play-services-tasks@@18.4.1:1)
[8] com.google.android.gms.tasks.Tasks.await (com.google.android.gms:play-services-tasks@@18.4.1:8)
[9] com.google.android.gms.internal.firebase-auth-api.zzafj.zza (com.google.firebase:firebase-auth@@24.2.0:9)
[10] com.google.android.gms.internal.firebase-auth-api.zzafj.zza (com.google.firebase:firebase-auth@@24.2.0:59)
[11] com.google.android.gms.internal.firebase-auth-api.zzagd.zza (com.google.firebase:firebase-auth@@24.2.0:59)
[12] com.google.android.gms.internal.firebase-auth-api.zzafk.zza (com.google.firebase:firebase-auth@@24.2.0:49)
[13] com.google.android.gms.internal.firebase-auth-api.zzaba.zzb (com.google.firebase:firebase-auth@@24.2.0:108)
[14] com.google.android.gms.internal.firebase-auth-api.zzaet.zzb (com.google.firebase:firebase-auth@@24.2.0:86)
[15] com.google.android.gms.internal.firebase-auth-api.zzadg.zza (com.google.firebase:firebase-auth@@24.2.0:13)
[16] com.google.android.gms.internal.firebase-auth-api.zzafw.run (com.google.firebase:firebase-auth@@24.2.0:3)
The IntegrityService handler thread in our process was idle (MessageQueue.nativePollOnce), i.e. no answer from the Play Store ever arrived.
Why the app cannot recover on its own
From the bytecode of firebase-appcheck 19.4.1:
DefaultFirebaseAppCheck.getToken(boolean)reusescachedTokenTaskas long as it is neither complete nor cancelled – also withforceRefresh = true. A provider task that never finishes therefore blocks every later App Check request for the lifetime of the process.installAppCheckProviderFactory()replaces the provider but does not resetcachedTokenTask, so installing the factory again does not help either.- Firebase Auth waits for the App Check token with
Tasks.await()without a timeout, so the hang spreads to Auth and from there to the Realtime Database.
Our guess for the root cause is that the Play Integrity client (IntegrityManagerFactory.create()) keeps its connection to the IntegrityService of the old Play Store package and does not rebind after the package was replaced, so the request is queued forever. We have not been able to confirm this from the outside.
Expected behavior
- The Play Integrity provider rebinds after the Play Store was updated, or fails the task with an error (e.g.
CANNOT_BIND_TO_SERVICE). - In any case, App Check token requests time out instead of staying pending forever, and Auth does not block on App Check without a timeout.
Steps to reproduce
We saw this once and have not reproduced it on purpose. What happened:
- App with App Check (Play Integrity provider), Auth and Realtime Database, running as a long-lived foreground service.
- Play Store updates itself while the app keeps running.
- Wait until the cached App Check token has to be renewed (e.g. on the next database reconnect).
getAppCheckToken()never completes;getIdToken()and the database connection hang with it.
Relevant Code
FirebaseApp.initializeApp(context);
FirebaseAppCheck.getInstance().installAppCheckProviderFactory(PlayIntegrityAppCheckProviderFactory.getInstance());
// later, after the Play Store update:
FirebaseAppCheck.getInstance().getAppCheckToken(false) // never completes
FirebaseAuth.getInstance().getCurrentUser().getIdToken(false) // never completes
Workaround on our side: we are removing App Check, as it is not enforced for our project anyway.
- 主要言語
- Java
- スター
- 2.6k
- フォーク
- 733
- 平均マージ
- 2日 15時間
- マージ済み PR(30日)
- 72
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
firebase/firebase-android-sdk のほかの issue
-
api: remoteconfig
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
firebase/firebase-android-sdk#8827 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
Crashlytics plugin writes build ID lists in directory listing order, so APKs can differ between machines対応中かも @mrober が 11 日前に担当しました。 オープンapi: crashlytics
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
firebase/firebase-android-sdk#8789 · コメント 1 件 · 担当者 1 名 ·
メンテナーはふだん 1 日以内に返信
-
api: auth
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
firebase/firebase-android-sdk#8505 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
api: firebaseai
難易度 4/5 3〜5日 初心者へのやさしさ 15/100
firebase/firebase-android-sdk#8835 ·
メンテナーはふだん 1 日以内に返信
-
api: auth
難易度 4/5 3〜5日 初心者へのやさしさ 25/100
firebase/firebase-android-sdk#8832 ·
メンテナーはふだん 1 日以内に返信
firebase/firebase-android-sdk の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 79/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
メンテナーはふだん 2 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 63/100
linagora/twake-calendar-side-service#1578 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 66/100
tchiotludo/akhq#3438 ·
メンテナーはふだん 1 日以内に返信
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 66/100
Paul-Austin-Oswego-CSC480-HCI521/gift-app#266 ·
メンテナーはふだん 1 日以内に返信