You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Feb 25, 2025. It is now read-only.
AccessibilityManager.notifyAccessibilityStateChanged() use post to call listener.onAccessibilityStateChanged(),if post and FlutterEngine.destroy() occur at the same time,it may be post->FlutterEngine.destroy->FlutterJNI.nativePlatformViewId=null->listener.onAccessibilityStateChanged(),and app will crash with FlutterJNI.ensureAttachedToNative as #33511
Are you seeing the FlutterJNI.setSemanticsEnabled exception (from flutter/flutter#33511) in an app that uses the old version of the Flutter Android embedding (io.flutter.view.FlutterView)?
The new version of the embedding (io.flutter.embedding.android.FlutterView) should handle this correctly. FlutterView.onDestroyView callsFlutterView.detachFromFlutterEngine, which will remove the AccessibilityBridge listener. FlutterView.onDetach will destroy the FlutterEngine and detach FlutterJNI from its native peer.
The implementation of FlutterActivity and FlutterFragment will ensure that onDestroyView is called before onDetach. So the accessibility listener should no longer be invoked by the time FlutterJNI has been detached.
The old io.flutter.view.FlutterView class did not do this correctly. The old class removes the accessibility listener in its override of View.onDetachedFromWindow. This callback will happen after the Activity.onDestroy lifecycle event that triggers FlutterView.destroy and detaches FlutterJNI.
So in the old embedding there is an interval during which the accessibility manager may invoke the accessibility listener while it is still active and holding a detached FlutterJNI.
I have not been able to reproduce this exception locally. But if it affects the old embedding then I'd prefer to patch io.flutter.view.FlutterView.
Are you seeing the FlutterJNI.setSemanticsEnabled exception (from flutter/flutter#33511) in an app that uses the old version of the Flutter Android embedding (io.flutter.view.FlutterView)?
The new version of the embedding (io.flutter.embedding.android.FlutterView) should handle this correctly. FlutterView.onDestroyView callsFlutterView.detachFromFlutterEngine, which will remove the AccessibilityBridge listener. FlutterView.onDetach will destroy the FlutterEngine and detach FlutterJNI from its native peer.
The implementation of FlutterActivity and FlutterFragment will ensure that onDestroyView is called before onDetach. So the accessibility listener should no longer be invoked by the time FlutterJNI has been detached.
The old io.flutter.view.FlutterView class did not do this correctly. The old class removes the accessibility listener in its override of View.onDetachedFromWindow. This callback will happen after the Activity.onDestroy lifecycle event that triggers FlutterView.destroy and detaches FlutterJNI.
So in the old embedding there is an interval during which the accessibility manager may invoke the accessibility listener while it is still active and holding a detached FlutterJNI.
I have not been able to reproduce this exception locally. But if it affects the old embedding then I'd prefer to patch io.flutter.view.FlutterView.
yes,i can recurrent this bug locally with Huawei ,and i use v1.7.8 io.flutter.view.FlutterView,
For safety reasons,Huawei will close Accessibility when app quit completely.If phone low memory and try to kill some background app,onAccessibilityStateChanged and FlutterEngine.destroy will occur at the same time ,this will greatly increase the probability of crash
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
AccessibilityManager.notifyAccessibilityStateChanged() use post to call listener.onAccessibilityStateChanged(),if post and FlutterEngine.destroy() occur at the same time,it may be post->FlutterEngine.destroy->FlutterJNI.nativePlatformViewId=null->listener.onAccessibilityStateChanged(),and app will crash with FlutterJNI.ensureAttachedToNative as #33511