Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit d41e10b

Browse files
Release the AccessibilityBridge when destroying a legacy FlutterView (#20610)
1 parent ccaee70 commit d41e10b

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

shell/platform/android/io/flutter/view/FlutterView.java

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -432,6 +432,7 @@ public void destroy() {
432432
if (!isAttached()) return;
433433

434434
getHolder().removeCallback(mSurfaceCallback);
435+
releaseAccessibilityNodeProvider();
435436

436437
mNativeView.destroy();
437438
mNativeView = null;
@@ -749,9 +750,7 @@ protected void onAttachedToWindow() {
749750
@Override
750751
protected void onDetachedFromWindow() {
751752
super.onDetachedFromWindow();
752-
753-
mAccessibilityNodeProvider.release();
754-
mAccessibilityNodeProvider = null;
753+
releaseAccessibilityNodeProvider();
755754
}
756755

757756
// TODO(mattcarroll): Confer with Ian as to why we need this method. Delete if possible, otherwise
@@ -776,6 +775,13 @@ public AccessibilityNodeProvider getAccessibilityNodeProvider() {
776775
}
777776
}
778777

778+
private void releaseAccessibilityNodeProvider() {
779+
if (mAccessibilityNodeProvider != null) {
780+
mAccessibilityNodeProvider.release();
781+
mAccessibilityNodeProvider = null;
782+
}
783+
}
784+
779785
@Override
780786
@TargetApi(Build.VERSION_CODES.N)
781787
@RequiresApi(Build.VERSION_CODES.N)

0 commit comments

Comments
 (0)