-
Notifications
You must be signed in to change notification settings - Fork 28.6k
Typing in TextField crashes app on macOs if virtual keyboard is open while enabling #151428
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Thank you for the report. I can also reproduce the crash on my macOS machine (macOS app). I also checked this on Windows (app) and Web but the crash doesn't happen there. flutter doctor -v (stable and master)[✓] Flutter (Channel stable, 3.22.2, on macOS 14.1 23B74 darwin-x64, locale en-VN)
• Flutter version 3.22.2 on channel stable at /Users/huynq/Documents/GitHub/flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision 761747bfc5 (3 weeks ago), 2024-06-05 22:15:13 +0200
• Engine revision edd8546116
• Dart version 3.4.3
• DevTools version 2.34.3
[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
• Android SDK at /Users/huynq/Library/Android/sdk
• Platform android-34, build-tools 34.0.0
• ANDROID_HOME = /Users/huynq/Library/Android/sdk
• Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 17.0.10+0-17.0.10b1087.21-11572160)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS (Xcode 15.4)
• Xcode at /Applications/Xcode15.4.app/Contents/Developer
• Build 15F31d
• CocoaPods version 1.15.2
[✓] Chrome - develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[✓] Android Studio (version 2023.3)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/6351-dart
• android-studio-dir = /Applications/Android Studio.app/
• Java version OpenJDK Runtime Environment (build 17.0.10+0-17.0.10b1087.21-11572160)
[✓] VS Code (version 1.90.2)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 3.90.0
[✓] Connected device (3 available)
• iPhone (mobile) • d9a94afe2b649fef56ba0bfeb052f0f2a7dae95e • ios • iOS 15.8 19H370
• macOS (desktop) • macos • darwin-x64 • macOS 14.1 23B74 darwin-x64
• Chrome (web) • chrome • web-javascript • Google Chrome 126.0.6478.127
[✓] Network resources
• All expected network resources are available.
• No issues found! [!] Flutter (Channel master, 3.23.0-14.0.pre.157, on macOS 14.1 23B74 darwin-x64, locale en-VN)
• Flutter version 3.23.0-14.0.pre.157 on channel master at /Users/huynq/Documents/GitHub/flutter_master
! Warning: `flutter` on your path resolves to /Users/huynq/Documents/GitHub/flutter/bin/flutter, which is not inside your current Flutter SDK checkout at /Users/huynq/Documents/GitHub/flutter_master. Consider adding /Users/huynq/Documents/GitHub/flutter_master/bin to the front of your path.
! Warning: `dart` on your path resolves to /Users/huynq/Documents/GitHub/flutter/bin/dart, which is not inside your current Flutter SDK checkout at /Users/huynq/Documents/GitHub/flutter_master. Consider adding /Users/huynq/Documents/GitHub/flutter_master/bin to the front of your path.
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision ad6166a8b8 (3 hours ago), 2024-07-07 19:58:25 -0400
• Engine revision ca79a56a66
• Dart version 3.5.0 (build 3.5.0-323.0.dev)
• DevTools version 2.37.0
• If those were intentional, you can disregard the above warnings; however it is recommended to use "git" directly to perform update checks and upgrades.
[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
• Android SDK at /Users/huynq/Library/Android/sdk
• Platform android-34, build-tools 34.0.0
• ANDROID_HOME = /Users/huynq/Library/Android/sdk
• Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 17.0.10+0-17.0.10b1087.21-11572160)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS (Xcode 15.4)
• Xcode at /Applications/Xcode15.4.app/Contents/Developer
• Build 15F31d
• CocoaPods version 1.15.2
[✓] Chrome - develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[✓] Android Studio (version 2023.3)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/6351-dart
• android-studio-dir = /Applications/Android Studio.app/
• Java version OpenJDK Runtime Environment (build 17.0.10+0-17.0.10b1087.21-11572160)
[✓] VS Code (version 1.90.2)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 3.92.0
[✓] Connected device (2 available)
• macOS (desktop) • macos • darwin-x64 • macOS 14.1 23B74 darwin-x64
• Chrome (web) • chrome • web-javascript • Google Chrome 126.0.6478.127
! Error: iPhone has recently restarted. Xcode will continue when iPhone is unlocked. (code -14)
[✓] Network resources
• All expected network resources are available.
! Doctor found issues in 1 category. |
cc @dkwingsmt |
@dkwingsmt Interesting that using the virtual keyboard seems to enable semantics. Seems like we're missing one or more methods on our macOS platform node implementation based on the stack trace. |
Possibly the same issue since the crash looks the same: #152828 ... although my repro steps have nothing to do with a virtual keyboard ... |
Yeah the two reproduction have almost identical stacktrace. The culprit code looks like this: case ui::AXEventGenerator::Event::VALUE_CHANGED: {
if (ax_node.data().role == ax::mojom::Role::kTextField) {
// If it is a text field, the value change notifications are handled by
// the FlutterTextField directly. Only need to make sure it is the
// first responder.
FlutterTextField* native_text_field =
(FlutterTextField*)mac_platform_node_delegate->GetNativeViewAccessible();
id focused = mac_platform_node_delegate->GetFocus();
if (!focused || native_text_field == focused) {
[native_text_field startEditing]; /* CRASHED HERE */
}
break;
} Apparently the code assumes that the focused node is a There is another instance of
Considering how both reproduction involves enabling a disabled textfield, my guess is that when the text field is re-enabled, the text field object is recreated and the the focus is reassigned, but somehow the object is not created as a flutter text field but a bare native one, or the focus is give to the native one. cc @knopp who wrote this part of code in flutter/engine#33827. |
Thanks for the ping. I'll be looking into this tomorrow. |
The problem is that the accessibilty node in this case is created as |
Proof of concept PR here. Still needs tests. |
Test added. |
Fixes flutter/flutter#151428 *If you had to change anything in the [flutter/tests] repo, include a link to the migration guide as per the [breaking change policy].* ## Pre-launch Checklist - [x] I read the [Contributor Guide] and followed the process outlined there for submitting PRs. - [x] I read the [Tree Hygiene] wiki page, which explains my responsibilities. - [x] I read and followed the [Flutter Style Guide] and the [C++, Objective-C, Java style guides]. - [x] I listed at least one issue that this PR fixes in the description above. - [x] I added new tests to check the change I am making or feature I am adding, or the PR is [test-exempt]. See [testing the engine] for instructions on writing and running engine tests. - [x] I updated/added relevant documentation (doc comments with `///`). - [x] I signed the [CLA]. - [x] All existing and new tests are passing. If you need help, consider asking for advice on the #hackers-new channel on [Discord]. <!-- Links --> [Contributor Guide]: https://github.com/flutter/flutter/wiki/Tree-hygiene#overview [Tree Hygiene]: https://github.com/flutter/flutter/wiki/Tree-hygiene [test-exempt]: https://github.com/flutter/flutter/wiki/Tree-hygiene#tests [Flutter Style Guide]: https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo [C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style [testing the engine]: https://github.com/flutter/flutter/wiki/Testing-the-engine [CLA]: https://cla.developers.google.com/ [flutter/tests]: https://github.com/flutter/tests [breaking change policy]: https://github.com/flutter/flutter/wiki/Tree-hygiene#handling-breaking-changes [Discord]: https://github.com/flutter/flutter/wiki/Chat
I see that this issue is marked as "Closed" and fixed. However, I can reproduce this in 3.24 with the exact same sample code. I followed the same steps and the app crashed for me. Could you verify if this is still an issue? flutter doctor -v
|
It's fixed in main. I don't think the fix has been cherry picked to stable. |
Yeah, issues get fixed on main and are generally not cherry picked to stable. |
This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of |
Steps to reproduce
Some combinations of opening the keyboard later and bringing the app to the background and to the foreground again seem to avoid the bad state. But we didn't find a reproducible arrangement.
We were able to reproduce this with compiled binaries on the following systems:
Apple M1 Pro with macOs 14.4
Mac Mini X86-64 with macOs 11.7.10
Mac Mini X86-64 with macOs 10.15.7
Expected results
It is possible to enter characters into the text field while macOs the virtual keyboard is open without crashing the app
Actual results
When entering a character in the text field while using the macOs virtual keyboard, the app crashes.
Code sample
Code sample
Screenshots or Video
This shows the macOs virtual keyboard and the menu to open it.
Video showing the crash
TextField_enabled_bug.mov
Logs
Run console log
Flutter Doctor output
Doctor output
The text was updated successfully, but these errors were encountered: