-
Notifications
You must be signed in to change notification settings - Fork 26.8k
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
[Android] Autofill from saved credentials doesn't work #137760
Comments
Hi @TatsuUkraine. When you setup details, have you also set those up in the system "autofill service" settings and provide relevant information to the autofill service for it to work ? |
@dam-ease sorry, not sure that I understood the question( for this example I didn't do any native configuration for Android, basically this issue appears only when app looses focus either because of biometric auth or because you go into the password manager. If biometric auth is not requested, and you using password suggestions from the keyboard quick action - all works fine |
@dam-ease I already replied😅 |
@dam-ease I added video to the description to better explain what is going on. On a video when screen goes black - it asks for biometric verification. On a video there are 3 attempts:
Autofill works only when app doesn't go to background (3rd try) |
I guess the time you replied and the time the label updated were the same. Screen.Recording.2023-11-03.at.17.55.12.mov |
It seems biometric verification doesn't affect behavior a lot. If I disable biometric check for password usages only one difference is that there is no scenario 2 (from my prev comment). So it seems autofill just stops working when the app goes to background and the text field loses focus, either because of password manager bottom sheet or because of biometric check screen-20231103-160500.2.mp4Also, one note, I'm not entirely sure, since I didn't check this explicitly, but I think all was working in prev stable release |
I am seeing this same behavior while using 1password. Once the manager is unlocked, 1password can fill as expected from the small "account choosing" modal, but still cannot fill from the "open 1password" option. It seems this happens any time my app is pushed to the background by the password manager. IF I force the focusNode for the username field to never loose focus by requesting focus when the focusNode is not in focus, it will autofill. It seems like the password manager does not/cannot regain focus on the textfield before it attempts to push the username/password text.
Edit: Screen_Recording_20231120_152145.mp4 |
I started to notice this issue once my device got Android 14 update. on Android 13 it was working fine. |
Developed a workaround using a combination of FocusNodes, listeners, and watching LifeCycle changes. It seems to be working for me.
Example:
(Thanks to @davidpryor for mentioning forcing focus). |
This comment was marked as duplicate.
This comment was marked as duplicate.
This comment was marked as duplicate.
This comment was marked as duplicate.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
Can also confirm that the workaround works. Thanks a lot for this! However, I also have a small nitpick to it - flutter/packages/flutter/lib/src/widgets/framework.dart Lines 998 to 999 in 5187b45
So the
|
This works for |
another possible workaround (depends on what kind of form you have on the screen) import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
class InactiveFocusScopeObserver extends StatefulWidget {
final Widget child;
const InactiveFocusScopeObserver({
super.key,
required this.child,
});
@override
State<InactiveFocusScopeObserver> createState() => _InactiveFocusScopeObserverState();
}
class _InactiveFocusScopeObserverState extends State<InactiveFocusScopeObserver> {
final FocusScopeNode _focusScope = FocusScopeNode();
AppLifecycleListener? _listener;
FocusNode? _lastFocusedNode;
@override
void initState() {
_registerListener();
super.initState();
}
@override
Widget build(BuildContext context) => FocusScope(
node: _focusScope,
child: widget.child,
);
@override
void dispose() {
_listener?.dispose();
_focusScope.dispose();
super.dispose();
}
void _registerListener() {
/// optional if you want this workaround for any platform and not just for android
if (defaultTargetPlatform != TargetPlatform.android) {
return;
}
_listener = AppLifecycleListener(
onInactive: () {
_lastFocusedNode = _focusScope.focusedChild;
},
onResume: () {
_lastFocusedNode = null;
},
);
_focusScope.addListener(_onFocusChanged);
}
void _onFocusChanged() {
if (_lastFocusedNode?.hasFocus == false) {
_lastFocusedNode?.requestFocus();
_lastFocusedNode = null;
}
}
} so it can be used with any number of fields that may potentially suffer from this bug InactiveFocusScopeObserver(
child: FormWithTheFeildsThatMayLooseFocus(),
) |
The workaround mentioned in this thread works fine for android. But I haven't been able to get iOS to work. The save password prompt doesn't show up. Does any one here have a working solution for iOS? Please share. |
Our clients reported exactly the same issue, but we can replicate it even without having biometric auth enabled for autofill. Using inline autofill (via keyboard), try to not directly autofill credentials, but via IME, open autofill app, and try autofilling from there. It indeed looks like the issue is lost focus. We replicated that on Google Password Manager and on Bitwarden everytime. |
I can't reproduce the issue with biometric authentication on: video.mp4 |
Additional note: flutter/packages/flutter/lib/src/widgets/focus_manager.dart Lines 1524 to 1533 in 6826fc0
It doesn't seem that moving the app to the background affects the in-app focus on Android (at least not in the framework). |
@LongCatIsLooong In which version of flutter did you test it? I am testing it on version 3.19.6, and I can reproduce the issue, in my case it happens with Samsung Account on a physical device, using biometric authentication, it does not autocomplete the textfields (email and password). |
UPDATE: On version 3.22.0 works fine |
Looks like the first bad commit is 04e284a. The issue went away when the commit was reverted. |
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
To unpack this a bit: That engine commit was reverted in flutter/engine@500ae6c. That revert rolled into flutter/flutter in commit d35c08e, which was part of Flutter 3.22.0 but not 3.19.6 (the previous release). |
We're facing the same issue with password autofill. Using Flutter 3.22.1 |
All works fine for me on Android after update to 3.22.1. Fields aren't loosing focus during biometric verification in password manager. Login and password prefilled correctly in the form |
@LongCatIsLooong I don't know why bot reopened the issue, sorry 😅 |
Might be a sign ! 😄 On Android Username is not saved to Google Password Manager for me, only suggested password While on iOS existing password autofill does not fill the fields anymore (but I will investigate and open an issue) |
Jup, works for me on android, but I still have the same old issues on iOS build |
Is there an existing issue for this?
Steps to reproduce
Device for testing
Google Pixel 7 pro, Android 14 (34)
Expected results
Form prepopulates with the selected username/password combination
Actual results
Input loses focus and nothing happens.
Form can be prepopulated only if login/password combination is selected from Keyboard quick actions and no biometric check is requested
Code sample
Code sample (very simple autofillgroup with 2 inputs)
Screenshots or Video
Video
screen-20231103-102820.2.mp4
Logs
Logs
Flutter Doctor output
Doctor output
The text was updated successfully, but these errors were encountered: