androidandroid-webviewandroid-autofill-manager

Android webview Autofill Manager Issue


I'm seeing a bug where selecting to autofill passwords/credit card info from keyboard shortcuts into a webview is not working, the autofilled data is not set on the input. This is ONLY occurring with autofill options that suspend lifecycle, simple text based autofill (paste from clipboard) is working fine. I have been able to successfully validate that this can work in a sample project.

The pattern I'm seeing when selecting an autofill option is

Activity Paused
AutofillManager - onAuthenticationResult(): sessionId=2147483647 not active
Activity Resumed

I was able to trace the issue here to where it looks like the result is being ignored as the session is not active (2147483647 is max int). I'm unable to find anything obvious around lifecycle related calls to the webview in the app.

Anyone know what would cause this error or how do enable verbose or debug logging for this AutofillManager lib locally?

Thanks!


Solution

  • I was able to debug into this AutofillManager file by downloading the source into Android Studio. The breakpoints were like ~100 LOC off actually evaluation point though so it took a little to get setup in the right places.

    The problem was occurring because my webview was being created with applicationContext resulting in the onAuthenticationResult callback being sent to a sessionless ActivityManager that did not start the autofill request. Weird. Regardless should be using a UI based context here.