bug(keyboard): insets animation callbacks can run after handleOnDestroy cleared the listener on Android
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 初心者へのやさしさ
- 78/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 活発
- 領域
- mobile-dev
調査の方向性
Androidキーボードプラグインのコールバック Keyboard.java、onStart、onEnd から調べます。報告によると、teardown後にlistenerの呼び出しが発生する可能性があります。KeyboardPlugin.handleOnDestroy() がどのようにlistenerをクリアするかを確認し、既存の戻り値の動作を保ったまま、両方のコールバックでlistenerがnullの場合をガードします。teardown後に届いたコールバックが無視されれば完了です。issueではテストファイルは指定されていません。
索引モデルが issue の本文から書いたものです。
説明
Bug Report
Plugin(s)
@capacitor/keyboard 8.0.6 (same code in 9.0.0-next.3)
Capacitor Version
@capacitor/core: 8.6.0
@capacitor/android: 8.6.0
@capacitor/keyboard: 8.0.6
Platform(s)
Android
Current Behavior
When the activity is destroyed while an IME insets animation is running (for example a configuration change that relaunches the activity), InsetsController.cancelExistingAnimations dispatches onEnd to the plugin's WindowInsetsAnimationCompat.Callback during ViewRootImpl.dispatchDetachedFromWindow. By then KeyboardPlugin.handleOnDestroy() may already have called implementation.setKeyboardEventListener(null), and Keyboard's onStart/onEnd call keyboardEventListener.onKeyboardEvent(...) without a null check, so the callback can throw a NullPointerException during teardown.
On 8.0.3 the same teardown crashed one step earlier because ViewCompat.getRootWindowInsets(rootView) returned null:
java.lang.NullPointerException
at androidx.core.view.WindowInsetsCompat.isVisible (WindowInsetsCompat.java:711)
at com.capacitorjs.plugins.keyboard.Keyboard$1.onEnd (Keyboard.java:112)
at androidx.core.view.WindowInsetsAnimationCompat$Impl30$ProxyCallback.onEnd (WindowInsetsAnimationCompat.java:1099)
at android.view.InsetsController.cancelExistingAnimations (InsetsController.java:1915)
at android.view.ViewRootImpl.dispatchDetachedFromWindow (ViewRootImpl.java:6231)
at android.app.ActivityThread.handleDestroyActivity (ActivityThread.java:6047)
at android.app.ActivityThread.handleRelaunchActivityInner (ActivityThread.java:6322)
8.0.6 added if (insets == null) return;, which covers that case, but the listener can still be null at that point.
Expected Behavior
Insets animation callbacks that arrive after handleOnDestroy are ignored.
Code Reproduction
Teardown race: open the keyboard in any Capacitor app and trigger an activity relaunch (for example change the system font size or dark mode with a configuration the app does not handle) while the IME animation runs. We saw the 8.0.3 variant in production once in 28 days.
Other Technical Details
The fix we ship as a patch, in both callbacks:
WindowInsetsCompat insets = ViewCompat.getRootWindowInsets(rootView);
-if (insets == null) return;
+if (insets == null || keyboardEventListener == null) return;
(onStart returns super.onStart(animation, bounds) in the same condition.)
Additional Context
Happy to open a pull request against main with this change if you agree with the approach.
This report was prepared with AI assistance (Claude) on behalf of the app team.
- 主要言語
- Java
- スター
- 688
- フォーク
- 690
- 平均マージ
- 16時間 15分
- マージ済み PR(30日)
- 7
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
ionic-team/capacitor-plugins のほかの issue
-
platform: android
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
ionic-team/capacitor-plugins#2646 ·
メンテナーはふだん 1 日以内に返信
-
triage
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
ionic-team/capacitor-plugins#2639 ·
メンテナーはふだん 1 日以内に返信
-
platform: android
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
ionic-team/capacitor-plugins#2635 ·
メンテナーはふだん 1 日以内に返信
-
triage
難易度 2/5 1〜3時間 初心者へのやさしさ 80/100
ionic-team/capacitor-plugins#2627 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
triage
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
ionic-team/capacitor-plugins#2616 ·
メンテナーはふだん 1 日以内に返信
ionic-team/capacitor-plugins の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
federicoiosue/Omni-Notes#1044 ·
-
Bug
難易度 1/5 1時間未満 初心者へのやさしさ 68/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
メンテナーはふだん 1 日以内に返信
-
Terraform releases proxy leaves a temp folder behind on every cache refresh対応中かも @dhananjay6561 が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
terrakube-io/terrakube#4069 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信