Kunzisoft / KeePassDX

Lightweight vault and password manager for Android, KeePassDX allows editing encrypted data in a single file in KeePass format and fill in the forms in a secure way.
https://www.keepassdx.com/
GNU General Public License v3.0
4.51k stars 267 forks source link

Autofill selection dialog keeps disappearing in Firefox #725

Closed hbiel closed 2 years ago

hbiel commented 3 years ago

Describe the bug The Autofill Dialog keeps disappearing making it impossible to select an entry. Sometimes it's working but it seems very inconsistent.

In a Reddit thread (https://www.reddit.com/r/Bitwarden/comments/futrca/autofill_dialog_keeps_disappearing_on_android/ ) the same thing is being reported for Bitwarden. One comment mentions the available screen space might be a problem and recommends minimizing the keyboard.

When it's working the selection dialog is rendered quite a bit above the selected field. Maybe this is related. Screenshot_20200926-200653

To Reproduce Steps to reproduce the behavior:

  1. Open login page in Browser (e.g. Firefox and https://store.steampowered.com/login)
  2. At first the selection dialog mostl time is appearing corrently
  3. Click on username / password entry field
  4. Now the Keyboard opens and the Autofill selection dialog only flashes for a second
  5. Sometimes closing and reopening the app helps and the selection dialog is being shown again

Expected behavior The Autofill selection dialog is being shown consitently

Keepass Database

KeePassDX:

Android:

Additional context

J-Jamet commented 3 years ago

Linked to https://github.com/Kunzisoft/KeePassDX/issues/681 The problem seems to come from firefox. But Bitwarden manages to keep a popup active, we have to find the trick.

J-Jamet commented 3 years ago

~It seems that Android SDK 30 solve the problem. #723~

Issue still appearing with SDK 30

hbiel commented 3 years ago

Awesome, looking forward to this. Thanks for your work!

hbiel commented 3 years ago

I compiled a debug version from develop (commit 9947a23) and could not verify the fix. It seemed to be slightly better though. For example i could do a long press on the field and the dialog would show up in some cases. I don't know if this is the intended behaviour in Android. It was still very inconsistent though.

I never did any Android development before so i might have done something wrong in the process... I wonder if your build will work better.

auanasgheps commented 3 years ago

Since I've seen the same issue in #681 just wanted to add the usual drill : this issue does not happen when using Keepass2Android. So even if it's a Firefox fault, it has been work-arounded in some way.

hbiel commented 3 years ago

I just tested it again on keepass2android and it's showing the same issue for me. It seems to be working better on Chrome now though. Which is kinda ironic because it never really worked in Chrome and is the reason I switched to Firefox.

auanasgheps commented 3 years ago

Can you try Brave? It's based on Chromium and I currently don't see the issue there. I can't see this issue in Chrome either, only in Firefox.

J-Jamet commented 3 years ago

I agree, this is a firefox exclusive problem. It is inconsistent and moreover corrected in Firefox ~Beta~ Nightly. So in any case, even if API 30 doesn't completely fix the problem, Firefox will fix its code.

hbiel commented 3 years ago

Firefox Beta shows the same behaviour for me. So if it's working there for you there might be something wrong on my end. Is there anything I can do so you can take a deeper look into this?

J-Jamet commented 3 years ago

Sorry, I mean Firefox Nightly. I can try to solve the problem more finely on KeePassDX but basically it will be a method to artificially slow down the display by returning a later response in onFillRequest(). I don't really like this way of doing things.

ghost commented 3 years ago

corrected in Firefox Nightly. Firefox will fix its code.

I doubt future update of Firefox will resolve this issue because my test results are very weird.

app(ARM64) version test result
Firefox 81.1.1 & 81.1.3 reproduced
Fennec F-Droid 81.1.1 not reproduced
Firefox Beta 81.1.0-beta.1 (9/2) & 82.0.0-beta.4 reproduced
Firefox Nightly 81.0a1 (200828 12:14) & 83.0a1 (201006 17.38) not reproduced
Firefox Focus not reproduced

Android

J-Jamet commented 3 years ago

Indeed, I had also tested with version 83.0a1 (83.0a120200922094538) The versions which do not work correctly must therefore be versions between 81.1.0 and 82.X on Android 11 (But I don't know what exactly causes this issue). So, I can artificially extend the response time (but I don't like this method) or I can try to implement autofill using the keyboard (but it will be experimental https://developer.android.com/guide/topics/text/ime-autofill)

ghost commented 3 years ago

therefore be versions between 81.1.0 and 82.X on Android 11

This issue is not reproduced on Firefox Focus, Fennec F-Droid and Firefox Nightly whose GeckoView version is 81. Moreover this issue was reported as occurring on Android 9(#681) and 10(#725)

hbiel commented 3 years ago

Sorry, I mean Firefox Nightly. I can try to solve the problem more finely on KeePassDX but basically it will be a method to artificially slow down the display by returning a later response in onFillRequest(). I don't really like this way of doing things.

Thanks for clarifying. In Firefox Nightly i finally got the same results as you. In this case I hope this will find its way into the stable release.

I agree with you that artificially slowing things down is not the right way.

Autofilling via the keyboard might be worth looking into regardless. I might not be able to test this though since I'm still on Android 10.

J-Jamet commented 3 years ago

This issue is not reproduced on Firefox Focus, Fennec F-Droid and Firefox Nightly whose GeckoView version is 81. Moreover this issue was reported as occurring on Android 9(#681) and 10(#725)

You're right, I forgot. I just looked at Bitwarden's code, I think I now know how to fix the problem without waiting for a response. It is possible that the onFillRequest is called several times in a very short time, so if we lock the first call and wait for the first response that should solve the problem (I did a promising first test).

J-Jamet commented 3 years ago

OK, I created the branch https://github.com/Kunzisoft/KeePassDX/tree/feature/Autofill_Disappearing with the fix. I haven't tested on all other browsers yet, but seems to work on most (to check). The small side effect is that the cancel signal is called many times on the bugged Firefox and the response method can only be called one time during an autofill service connection cycle.

hbiel commented 3 years ago

Thank you for your effort! I compiled your fix and did a quick test.

It's certainly better but still a bit inconsistent in Firefox (Nightly seems to working fine as before). Sometimes the dialog does not show at all or is being shown longer than before but still being closed shortly after. You can trigger this behaviour when switching back and fourth between the user and password field.

I didn't quite get the downsides you mentioned. Maybe they even got something to do with this new behaviour!? Also I can't really tell if these tradeoffs are worth it.

J-Jamet commented 3 years ago

You can trigger this behaviour when switching back and fourth between the user and password field.

@hbiel It sometimes happens but compared to before it's still much better, and you just have to lower the keyboard if the popup does not appear again.

I have tried several different codes and this is the best setup I have to fix the Firefox bug. So I will apply this fix.

J-Jamet commented 3 years ago

Fix merged in develop branch.

hbiel commented 3 years ago

You can trigger this behaviour when switching back and fourth between the user and password field.

@hbiel It sometimes happens but compared to before it's still much better, and you just have to lower the keyboard if the popup does not appear again.

I have tried several different codes and this is the best setup I have to fix the Firefox bug. So I will apply this fix.

Yeah, it definitely is much better than before. I just reported it because you mentioned some side effects to the fix. I couldn't really tell if those where of any significance and wanted to help you decide if it would be worth it.

So anyway thank you very much for taking the time to look into this. I've been waiting for years for an Autofill experience like this without giving up Keepass. Great work!

auanasgheps commented 3 years ago

Hey, I've been testing extensively Firefox Beta (83) with KeePassDX 2.92. It's still hit and miss - on some site is perfect, on others doesn't even show up. Is this "expected" for now?

J-Jamet commented 3 years ago

on some site is perfect, on others doesn't even show up

"On others" is not precise enough for testing.

auanasgheps commented 3 years ago

Hey, no problem, I was just chatting.

Shall we keep the conversation here? I'll get the issue recorded and write down the websites.

J-Jamet commented 3 years ago

I don't understand. Of course we can continue the discussion since we are in the process of doing so. I'm just saying I can't debug anything if I don't know what site you're talking about.

auanasgheps commented 3 years ago

I think we got lost in translation. I was vague because I was asking if you wanted to troubleshoot :)

auanasgheps commented 3 years ago

Here's https://amazon.it behaving as i mentioned. https://imgur.com/a/sA3YlUw

I've done several attempts because they represent what I get during normal use

sophie-kuehn commented 3 years ago

Sadly this is still not fixed at least on the Galaxy S7 with Android 8. Using KeepassDX 2.9.6 with current Firefox Nightly. No popup appears at all.

J-Jamet commented 3 years ago

@sophiekuehn I just checked, and it works great with an Android 8 emulator, Firefox Nightly 201229, KeePassDX 2.9.6 android8_Firefoxnightly201229

sophie-kuehn commented 3 years ago

Fancy. Same Nightly build. Same App Version. Android 8.0.0? Tried again. No chance. It's working for other apps, so it can't be a wrong setup on my end.

Screenshot_20201230-123951_Firefox Nightly

J-Jamet commented 3 years ago

Is the service activated? And there is no site in the list of blocked items? https://github.com/Kunzisoft/KeePassDX/wiki/AutoFill

sophie-kuehn commented 3 years ago

Block lists are empty. Both for apps and sites. The service is active. As i said. The popup appears in other apps but not Firefox.

J-Jamet commented 3 years ago

In this case, I don't know, maybe a setting in Firefox. I tested with Android 8.1.0 but it shouldn't change anything. If it works in the other apps, the autofill service is functional so the problem comes from firefox.

sophie-kuehn commented 3 years ago

https://developer.android.com/about/versions/oreo/android-8.1

Android 8.1 (API level 27) provides several improvements to the Autofill Framework that you can incorporate into your apps.

PS: it's certainly some Firefox bug, since it was working before the fenix upgrade. But this workaround here seams not to be working in my case.

firedim commented 2 years ago

new development from Firefox devs https://bugzilla.mozilla.org/show_bug.cgi?id=1715549