InputMethodManager / InsetsController log messages on each typed character on Android
It appears that with every character typed we send a request to the platform to show soft keyboard.
Steps to Reproduce
- Execute
flutter runon the code sample using an Android device - Type in the text field
Expected results: No logs shown on each typed character
Actual results: Every character typed produces the following log:
D/InputMethodManager(32033): showSoftInput() view=io.flutter.embedding.android.FlutterView{c4be627 VFE...... .F...... 0,0-1080,2214 #1 aid=1073741824} flags=0 reason=SHOW_SOFT_INPUT
D/InsetsController(32033): show(ime(), fromIme=true)
Here's the call stack:
I/flutter (32033): updateEditingValue
I/flutter (32033): _formatAndSetValue
I/flutter (32033): _handleSelectionChanged
I/flutter (32033): requestKeyboard
I/flutter (32033): _openInputConnection
D/InputMethodManager(32033): showSoftInput() view=io.flutter.embedding.android.FlutterView{c4be627 VFE...... .F...... 0,0-1080,2214 #1 aid=1073741824} flags=0 reason=SHOW_SOFT_INPUT
D/InsetsController(32033): show(ime(), fromIme=true)
Code sample
import 'package:flutter/material.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(primarySwatch: Colors.blue),
home: const MyHomePage(title: 'Flutter Demo Home Page'),
);
}
}
class MyHomePage extends StatefulWidget {
const MyHomePage({Key? key, required this.title}) : super(key: key);
final String title;
@override
State<MyHomePage> createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: Text(widget.title)),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
const Text('You have pushed the button this many times:'),
Text(
'Type here',
style: Theme.of(context).textTheme.headline4,
),
const Expanded(
child: TextField(maxLines: null),
),
],
),
),
);
}
}
Logs
% flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel master, 3.7.0-14.0.pre.31, on macOS 13.1 22C65 darwin-arm64, locale en-ES)
[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.1)
[✓] Xcode - develop for iOS and macOS (Xcode 14.1)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2021.3)
[✓] VS Code (version 1.74.2)
[✓] Connected device (3 available)
[✓] HTTP Host Availability
Hi @tgucio, I believe this is a duplicate of https://github.com/flutter/flutter/issues/9471.
Kindly follow up in the issue linked above for updates.
If you disagree, kindly leave a comment below and I will reopen this.
Thank you
@danagbemava-nc thanks for digging the other issue up. I don't think it's the same though: that one talks about API calls on an inactive InputConnection. This one is about unnecessary showSoftInput requests.
Thanks for the info.
Reproducible using the code sample provided above.
logs
Launching lib/main.dart on M2007J20CG in debug mode...
✓ Built build/app/outputs/flutter-apk/app-debug.apk.
Connecting to VM Service at ws://127.0.0.1:54180/LeM9vvThMpU=/ws
E/com.example.mu(11034): open libmigui.so failed! dlopen - dlopen failed: library "libmigui.so" not found
D/DecorView[](11034): onWindowFocusChanged hasWindowFocus true
D/InputMethodManager(11034): showSoftInput() view=io.flutter.embedding.android.FlutterView{5c3496c VFED..... .F....ID 0,0-1080,2270 #1 aid=1073741824} flags=0 reason=SHOW_SOFT_INPUT
I/AssistStructure(11034): Flattened final assist data: 372 bytes, containing 1 windows, 3 views
D/InsetsController(11034): show(ime(), fromIme=true)
W/Choreographer(11034): Frame time is 0.01436 ms in the future! Check that graphics HAL is generating vsync timestamps using the correct timebase.
D/InputMethodManager(11034): showSoftInput() view=io.flutter.embedding.android.FlutterView{5c3496c VFED..... .F...... 0,0-1080,2270 #1 aid=1073741824} flags=0 reason=SHOW_SOFT_INPUT
D/InsetsController(11034): show(ime(), fromIme=true)
D/InputMethodManager(11034): showSoftInput() view=io.flutter.embedding.android.FlutterView{5c3496c VFED..... .F...... 0,0-1080,2270 #1 aid=1073741824} flags=0 reason=SHOW_SOFT_INPUT
D/InsetsController(11034): show(ime(), fromIme=true)
D/InputMethodManager(11034): showSoftInput() view=io.flutter.embedding.android.FlutterView{5c3496c VFED..... .F...... 0,0-1080,2270 #1 aid=1073741824} flags=0 reason=SHOW_SOFT_INPUT
D/InsetsController(11034): show(ime(), fromIme=true)
D/InputMethodManager(11034): showSoftInput() view=io.flutter.embedding.android.FlutterView{5c3496c VFED..... .F...... 0,0-1080,2270 #1 aid=1073741824} flags=0 reason=SHOW_SOFT_INPUT
D/InsetsController(11034): show(ime(), fromIme=true)
D/InputMethodManager(11034): showSoftInput() view=io.flutter.embedding.android.FlutterView{5c3496c VFED..... .F...... 0,0-1080,2270 #1 aid=1073741824} flags=0 reason=SHOW_SOFT_INPUT
D/InsetsController(11034): show(ime(), fromIme=true)
Application finished.
Exited
flutter doctor -v
[✓] Flutter (Channel stable, 3.3.10, on macOS 13.1 22C65 darwin-arm, locale en-GB)
• Flutter version 3.3.10 on channel stable at /Users/nexus/dev/sdks/flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision 135454af32 (3 weeks ago), 2022-12-15 07:36:55 -0800
• Engine revision 3316dd8728
• Dart version 2.18.6
• DevTools version 2.15.0
[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.0)
• Android SDK at /Users/nexus/Library/Android/sdk
• Platform android-33, build-tools 33.0.0
• Java binary at: /Applications/Android Studio.app/Contents/jre/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 11.0.13+0-b1751.21-8125866)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS (Xcode 14.1)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Build 14B47b
• CocoaPods version 1.11.3
[✓] Chrome - develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[✓] Android Studio (version 2021.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
• Java version OpenJDK Runtime Environment (build 11.0.13+0-b1751.21-8125866)
[✓] VS Code (version 1.74.2)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 3.56.0
[✓] Connected device (3 available)
• M2007J20CG (mobile) • adb-5dd3be00-22GXB2._adb-tls-connect._tcp. • android-arm64 • Android 12 (API 31)
• macOS (desktop) • macos • darwin-arm64 • macOS 13.1 22C65 darwin-arm
• Chrome (web) • chrome • web-javascript • Google Chrome 108.0.5359.124
[✓] HTTP Host Availability
• All required HTTP hosts are available
• No issues found!
[!] Flutter (Channel master, 3.7.0-14.0.pre.40, on macOS 13.1 22C65 darwin-arm64, locale en-GB)
• Flutter version 3.7.0-14.0.pre.40 on channel master at /Users/nexus/dev/sdks/flutters
! Warning: `flutter` on your path resolves to /Users/nexus/dev/sdks/flutter/bin/flutter, which is not inside your current Flutter SDK checkout at /Users/nexus/dev/sdks/flutters. Consider adding /Users/nexus/dev/sdks/flutters/bin to the front of your path.
! Warning: `dart` on your path resolves to /Users/nexus/dev/sdks/flutter/bin/dart, which is not inside your current Flutter SDK checkout at /Users/nexus/dev/sdks/flutters. Consider adding /Users/nexus/dev/sdks/flutters/bin to the front of your path.
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision a562fe2d8a (5 hours ago), 2023-01-04 23:53:41 -0500
• Engine revision b9b0193ea8
• Dart version 3.0.0 (build 3.0.0-85.0.dev)
• DevTools version 2.20.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 33.0.0)
• Android SDK at /Users/nexus/Library/Android/sdk
• Platform android-33, build-tools 33.0.0
• Java binary at: /Applications/Android Studio.app/Contents/jre/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 11.0.13+0-b1751.21-8125866)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS (Xcode 14.1)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Build 14B47b
• CocoaPods version 1.11.3
[✓] Chrome - develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[✓] Android Studio (version 2021.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
• Java version OpenJDK Runtime Environment (build 11.0.13+0-b1751.21-8125866)
[✓] VS Code (version 1.74.2)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 3.56.0
[✓] Connected device (3 available)
• M2007J20CG (mobile) • adb-5dd3be00-22GXB2._adb-tls-connect._tcp. • android-arm64 • Android 12 (API 31)
• macOS (desktop) • macos • darwin-arm64 • macOS 13.1 22C65 darwin-arm64
• Chrome (web) • chrome • web-javascript • Google Chrome 108.0.5359.124
[✓] HTTP Host Availability
• All required HTTP hosts are available
! Doctor found issues in 1 category.
We are also facing this issue, this is leading to a lot of jank in our app
facing the same issue.. please solve it asap..
is there any workaround until the team fixes the issue?
facing the same issue.. please solve it asap..
update: i debugged for hours.. in the end it wasn't the cause of the error...
Explaining my error (you can read if you're interested): i made mistake while calling a custom search button that i made.. before constructor i mistakenly added an underscore (_)... then it got solved... pretty sad... hours of debugging down to the drain...
I am facing the same issue. Any fix?
Use WillPopScope in sub widget and test again
`Doctor summary (to see all details, run flutter doctor -v): [✓] Flutter (Channel stable, 3.13.8, on macOS 13.6 22G120 darwin-x64, locale zh-Hans-CN) [✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0) [✓] Xcode - develop for iOS and macOS (Xcode 15.0) [✓] Chrome - develop for the web [✓] Android Studio (version 2022.3) [✓] IntelliJ IDEA Community Edition (version 2022.2.3) [✓] VS Code (version 1.83.0) [✓] Connected device (3 available) [✓] Network resources
• No issues found! heweideMacBook-Pro:ios hewei$ heweideMacBook-Pro:ios hewei$ heweideMacBook-Pro:ios hewei$ flutter doctor -v [✓] Flutter (Channel stable, 3.13.8, on macOS 13.6 22G120 darwin-x64, locale zh-Hans-CN) • Flutter version 3.13.8 on channel stable at /Users/hewei/Development/flutter • Upstream repository https://github.com/flutter/flutter.git • Framework revision 6c4930c4ac (6 days ago), 2023-10-18 10:57:55 -0500 • Engine revision 767d8c75e8 • Dart version 3.1.4 • DevTools version 2.25.0 • Pub download mirror https://pub.flutter-io.cn • Flutter download mirror https://storage.flutter-io.cn
[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0) • Android SDK at /Users/hewei/Library/Android/sdk • Platform android-34, build-tools 34.0.0 • Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java • Java version OpenJDK Runtime Environment (build 17.0.6+0-17.0.6b829.9-10027231) • All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS (Xcode 15.0) • Xcode at /Applications/Xcode.app/Contents/Developer • Build 15A240d • CocoaPods version 1.13.0
[✓] Chrome - develop for the web • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[✓] Android Studio (version 2022.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 • Java version OpenJDK Runtime Environment (build 17.0.6+0-17.0.6b829.9-10027231)
[✓] IntelliJ IDEA Community Edition (version 2022.2.3) • IntelliJ at /Applications/IntelliJ IDEA CE.app • 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
[✓] VS Code (version 1.83.0) • VS Code at /Applications/Visual Studio Code.app/Contents • Flutter extension version 3.74.0
[✓] Connected device (3 available) • sdk gphone64 x86 64 (mobile) • emulator-5554 • android-x64 • Android 12 (API 32) (emulator) • macOS (desktop) • macos • darwin-x64 • macOS 13.6 22G120 darwin-x64 • Chrome (web) • chrome • web-javascript • Google Chrome 118.0.5993.88
[✓] Network resources • All expected network resources are available.
• No issues found! `
the same issue, all my TextField Widget , run in simulator, when i use the mouse click TextField, the keyboard pop but hide right now. click again and repeat. after many times (20? 30?), the input focus succeed, and can input now.
the Logcat and the run log:
showSoftInput() view=io.flutter.embedding.android.FlutterView{99d6bab VFE...... .F...... 0,0-1080,2116 #1 aid=1073741824} flags=0 reason=SHOW_SOFT_INPUT
also, i had tried to use WillPopScope wrapper the Build or TextField widget, it does't work.
i find when touch text field , the debugPrint code message on initState function of the main.dart run twise, like follow:
D/EGL_emulation(13977): app_time_stats: avg=195.35ms min=9.49ms max=565.35ms count=5 I/flutter (13977): PPPPPPPPPPPPPPPPPPPPPPP: I/flutter (13977): 56.0 I/flutter (13977): 0.0 I/flutter (13977): 56.0 I/flutter (13977): PPPPPPPPPPPPPPPPPPPPPPP: I/flutter (13977): 56.0 I/flutter (13977): 0.0 I/flutter (13977): 56.0
but i do other things, just only out put the right things
my issue is when i try to type somethink into my textfield or fromField it throws this in the run section "InputMethodManager( 7886): showSoftInput() view=io.flutter.embedding.android.FlutterView{7ccca76 VFE...... .F...... 0,0-1080,2274 #1 aid=1073741824} flags=0 reason=SHOW_SOFT_INPUT" its super weird ıve tryed to upgrade my flutter version but that did not worked also changing the sdk to 34 did not work either
Edit
i upgraded my Android studip from giraffe to hedgedog and for some reason it worked maybe downloading a old release and then updating it or staigth up re installing the hole thing works