-
Notifications
You must be signed in to change notification settings - Fork 6k
Notify framework to clear input connection when app is backgrounded (#35054). #9498
Notify framework to clear input connection when app is backgrounded (#35054). #9498
Conversation
|
I assume this also fixes the case of a user opening a flutter activity, focuses on text, backs out of that flutter activity while keeping the same engine, then relaunches the same activity with the same engine and focuses on text again (assuming the same problem would exist there too)? |
| * The TextInputPlugin instance should not be used after calling this. | ||
| */ | ||
| public void destroy() { | ||
| if (inputTarget.type != InputTarget.Type.NO_TARGET) { |
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.
We should only do this when the target is a FRAMEWORK_CLIENT (if the target is a PLATFORM_VIEW _currentConnection on the framework side is probably null).
a4fda95 to
53190bf
Compare
|
I updated the PR with a different approach that utilizes I also renamed the Android side message from 'clearClient' to 'onConnectionClosed'. I'm still dubious about where and how I'm invoking |
xster
left a 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.
LGTM. Let's add tests
shell/platform/android/io/flutter/embedding/engine/systemchannels/TextInputChannel.java
Show resolved
Hide resolved
shell/platform/android/io/flutter/plugin/editing/TextInputPlugin.java
Outdated
Show resolved
Hide resolved
mklim
left a 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.
LGTM modulo tests
|
|
||
| textInputChannel.onConnectionClosed(mClient); | ||
|
|
||
| if (onConnectionClosed != null) { |
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.
nit: This is final and never null, so I think it's okay to just always run this. Not a big deal and it doesn't hurt to be safe though.
related: annotations may be worthwhile in the constructor?
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.
Good point, I'll add annotations.
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.
The parameters are now annotated and the if-statement has been removed.
|
Rebasing to resolve conflicts. |
818f8dc to
29155ee
Compare
|
@matthew-carroll is this mergeable? |
|
I have to figure out why the tests are failing and fix them. |
45b0f62 to
52041d0
Compare
mklim
left a 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.
There are a lot of files in a testing/embedding/android/focus_new_activity_back/ that look like they've been generated as part of a tool/IDE and shouldn't be committed to source, including binary files and apk build files. I think we probably want to apply flutter/flutter's gitignore here.
New unit test LG.
| @@ -0,0 +1 @@ | |||
| android_intent=/Users/mattcarroll/.pub-cache/hosted/pub.dartlang.org/android_intent-0.3.1+1/ | |||
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.
Pretty sure this should be reverted. We probably should add files with this extension to the .gitignore.
|
+1. It's a bit hard to review since all the build intermediaries are checked in. |
fb54ca2 to
4e81b70
Compare
|
LGTM |
[email protected]:flutter/engine.git/compare/21ae92651a38...3e10d92 git log 21ae926..3e10d92 --no-merges --oneline 2019-08-19 [email protected] Roll src/third_party/dart 0e201edeeb..9f13d07670 (27 commits) 2019-08-19 [email protected] Notify framework to clear input connection when app is backgrounded (#35054) (flutter/engine#9498) 2019-08-19 [email protected] Re-enable firebase test and don't use google login (flutter/engine#11228) 2019-08-19 [email protected] Update tflite_native and language_model revisions to match the Dart SDK (flutter/engine#11230) 2019-08-19 [email protected] Roll src/third_party/skia f8221786d088..8566dda51b42 (4 commits) (flutter/engine#11220) 2019-08-19 [email protected] Update metal layer drawable size on relayout. (flutter/engine#11224) 2019-08-19 [email protected] Make firebase testlab always pass (flutter/engine#11226) The AutoRoll server is located here: https://autoroll.skia.org/r/flutter-engine-flutter-autoroll Documentation for the AutoRoller is here: https://skia.googlesource.com/buildbot/+/master/autoroll/README.md If the roll is causing failures, please contact the current sheriff ([email protected]), and stop the roller if necessary.
…ounded (flutter#35054) (flutter#9498)" This reverts commit 4003fbc.
…ounded (flutter#35054) (flutter#9498)" This reverts commit 4003fbc.
Problem:
Flutter is not setup to handle backgrounding and then foregrounding an app when an input control has focus. The issue is visible in the new embedding because the new embedding loosens platform restrictions around
FlutterActivitycontinuity.Repro Steps:
The issue is that Flutter is unaware that the app was backgrounded and therefore expects the same input connection to exist when re-foregrounded. But on the Android side, the input connection was lost when the app was backgrounded and therefore needs to be recreated when foregrounded again.
Solution:
When
FlutterActivitygoes to the background and detaches from theFlutterEngineinstance, instruct the framework to clear the input client. By clearing it, when the user taps on the control after being re-foregrounded, Flutter will request a new input connection and things should continue as expected.Corresponding Framework PR:
flutter/flutter#35100