-
Notifications
You must be signed in to change notification settings - Fork 28.9k
feature: make the text input plugin use the correct view on the Windows platform #163847
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
feature: make the text input plugin use the correct view on the Windows platform #163847
Conversation
ebf2e3f
to
a40000a
Compare
a40000a
to
95b35a0
Compare
I've noticed some errors that may be related to the text input plugin for multi view. After applying these changes to the
This issue wasn't introduced by this PR, as similar (though not identical) behavior can be observed in Files changed in the reference app: ref_app_lib.zip |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM from a text input standpoint. We already send the viewId as part of the TextInputConfiguration so this should just wire up. Is there an example app somewhere that I can use to test this out locally?
So two things appear to be happening here:
|
I have an example app that works with the multi window pull request. If you merge up this branch into flutter run --debug --local-engine-src-path C:/dev/flutter/engine/src/ --local-engine host_debug_unopt --local-engine-host host_debug_unopt .\lib\services\text_input\test.dart --enable-multi-window (replacing my paths with your paths, and I added test.dart to the import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
void main() {
final RegularWindowController controller1 = RegularWindowController(size: const Size(640, 480));
final RegularWindowController controller2 = RegularWindowController(size: const Size(640, 480));
runWidget(ViewCollection(
views: [
RegularWindow(controller: controller1, child: MyApp()),
RegularWindow(controller: controller2, child: MyApp()),
]
));
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Name Prompt',
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: NameInputScreen(),
);
}
}
class NameInputScreen extends StatefulWidget {
@override
_NameInputScreenState createState() => _NameInputScreenState();
}
class _NameInputScreenState extends State<NameInputScreen> {
final TextEditingController _controller = TextEditingController();
String? _name;
void _submitName() {
setState(() {
_name = _controller.text;
});
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: Text('Enter Your Name')),
body: Padding(
padding: const EdgeInsets.all(16.0),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
TextField(
controller: _controller,
decoration: InputDecoration(labelText: 'Name'),
),
SizedBox(height: 16),
ElevatedButton(
onPressed: _submitName,
child: Text('Submit'),
),
if (_name != null) ...[
SizedBox(height: 20),
Text(
'Hello, $_name!',
style: TextStyle(fontSize: 20, fontWeight: FontWeight.bold),
),
],
],
),
),
);
}
}
|
@loic-sharma What do you think about the issue brought up by Harlen #163847 (comment)? I might be mistaken, but since the Window (and thus the view) is being destroyed in another thread, we might encounter an invalid view ID in this thread by the time that we try to resolve the view. What do you think is appropriate here? |
Key events and text input requires multiple asynchronous roundtrips. I suspect synchronizing a view destruction with pending key/text events is hard when we have split UI/platform threads. @mattkae Can you reproduce this bug when Flutter Windows is in the merged thread mode that Matt Knopp added recently? @justinmc For the split UI/platform thread mode, can the framework handle this scenario (likely by warning and ignoring the exception) if the Windows embedder produces a better exception? |
That's what appears to be happening.
It still happens in this cases as far as I can tell. |
That's unfortunate. Why does that happen? Can we fix it? |
I would expect the error to still occur in merged thread mode because the method channels (like |
@hbatagelo also found the following: "When we close the window with a focused text field, the focus manager notifies the listeners that the focus has changed, and TextInput.clearClient is called as expected. However, the focus manager notifies the listeners a second time (no idea why), causing the text field to get focus again (TextInput.setClientis called, starting a new transaction). Then the view is destroyed, and focus changes once again, but now TextInput.clearClient is called for the destroyed view, leading to the exception" Seems like a bug (but perhaps an unrelated/deeper one with the focus manager that we should solve separately) |
@mattkae I finally was able to get set up on a Windows machine to try this (per #163847 (comment)), but what is I'm hoping to investigate what's going on with the second notification mentioned in #163847 (comment). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great, thanks!
…he Windows platform (flutter/flutter#163847)
…he Windows platform (flutter/flutter#163847)
…he Windows platform (flutter/flutter#163847)
…he Windows platform (flutter/flutter#163847)
…he Windows platform (flutter/flutter#163847)
…he Windows platform (flutter/flutter#163847)
…he Windows platform (flutter/flutter#163847)
…he Windows platform (flutter/flutter#163847)
…he Windows platform (flutter/flutter#163847)
…he Windows platform (flutter/flutter#163847)
…he Windows platform (flutter/flutter#163847)
…he Windows platform (flutter/flutter#163847)
…he Windows platform (flutter/flutter#163847)
…he Windows platform (flutter/flutter#163847)
…he Windows platform (flutter/flutter#163847)
What's new?
TextInput.setClient
method to expect a view ID, which is already being sent up by clients. This makes it so that the IME info shows on the text input correctly across views 🎉. Also - text input on windows works properly across views (although it was working before too)TextInputPlugin::HandleMethodCall
to resolve the viewWhat's fixed?
Pre-launch Checklist
///
).If you need help, consider asking for advice on the #hackers-new channel on Discord.