Skip to content

fix(ios): stop the AutoFill Passwords bar blinking while typing - #84

Open
shivapoudel wants to merge 1 commit into
ionic-team:mainfrom
shivapoudel:fix/ios-autofill-bar-blink
Open

shivapoudel wants to merge 1 commit into
ionic-team:mainfrom
shivapoudel:fix/ios-autofill-bar-blink

Conversation

@shivapoudel

@shivapoudel shivapoudel commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

Description

On iOS 27, typing in a username or password field inside the Capacitor WebView makes the QuickType bar's AutoFill Passwords key blink on every keystroke. This PR keeps the bar steady without changing the page or turning AutoFill off.

Keyboard.m gets a steadyAutofillBar hook, installed once from load, on -[UIKeyboardAutocorrectionController setAutocorrectionList:]:

  • While the list on screen has an AutoFill candidate, an empty list (no predictions, no corrections) is held for 100 ms.
  • If UIKit sets another list in that time (it does, 5–10 ms later), the held one is dropped. Otherwise it is applied late, so a real change to an empty bar still shows.
  • A nil list (keyboard going away) and every other list pass straight through.
  • If the class or selector is missing, nothing is swizzled and behaviour is unchanged.
  • The private class and selector names are built from joined strings, the same way the plugin's existing WKContentView swizzles are.

The example app gets a username and a password field (autocomplete="username" / "current-password") to reproduce it.

Context

The system log shows the cause. On each keystroke in an AutoFill field, UIKit calls setAutocorrectionList: twice:

  1. With an empty TIAutocorrectionList.
  2. About 5–10 ms later, from _UIKeyboardStateManager pushAutocorrections, with the AutoFill list again (one TIKeyboardCandidateSingle with isAutofillCandidate == YES).

A frame drawn between the two shows an empty bar. That is the blink.

A native UITextField with textContentType = .username never gets the empty list, and neither does Safari. The difference seems to be the WKWebView path: WKContentView is a textSuggestionDelegate. It looks like a UIKit/WebKit bug; I'm also filing it with Apple. Until that is fixed, apps can only avoid it with autocomplete="off", which removes the Passwords key.

How the empty list looks varies:

  • In a larger Angular app its predictions is nil.
  • In a bare WKWebView and in this example app it is @[].

So "empty" here means nil or zero predictions, with no corrections.

Calling the autocorrectionList getter from inside the setter deadlocks (it waits on the keyboard task queue). So the hook tracks what is on screen only from the lists passed to the setter.

This is new in iOS 27. iOS 26 sets no list per keystroke; see Tests. Reproduced on:

  • iOS 27.0 (Xcode 27.0, iPhone 18 Pro Max simulator), in this repo's example app.
  • A production Capacitor 8 app, on both a physical iPhone and the simulator.

Type of changes

  • Fix (non-breaking change which fixes an issue)
  • Feature (non-breaking change which adds functionality)
  • Refactor (cosmetic changes)
  • Breaking change (change that would cause existing functionality to not work as expected)

Platforms affected

  • Android
  • iOS
  • Web

Tests

iOS 27.0. Tested with the example app in this repo, on an iPhone 18 Pro Max simulator (Xcode 27.0):

  1. Open the app, scroll down and tap Username (AutoFill). The keyboard shows the Passwords key.

  2. Type test@exa one character at a time.

  3. Watch the bar, and stream the log:

    xcrun simctl spawn booted log stream --level debug --predicate 'process == "App"'

    Grep it for setAutocorrectionList and Keyboard inserts text.

In the sequences below, | is a key insert, E is an empty list applied, and P is the AutoFill list applied.

Build Sequence Blink frames in a 30 fps recording
main (f28aef4) EEP|EP|EP|EP|EP|EP|EP|EP|EP 2
this PR EEP|P|P|P|P|P|P|P|P 0

The EE before the first P is the keyboard's initial state and is unchanged. With the fix, no empty list reaches the bar between keystrokes. A 30 fps recording catches only some of the 5–10 ms gaps, which is why main shows 2 blink frames for 8 keys, not 8. On a device it is visible on most keys.

Also checked:

  • In the production app, with the fix, the bar stays steady (0 blink frames in 676) and tapping Passwords still opens the password picker (Face ID prompt).
  • npm run lint and npm run verify:ios pass.

iOS 26.0 (iPhone 17 Pro simulator, same example app): the bug does not happen there, and this change does nothing there.

  • The hook installs, but UIKit sets the list only when the field gains focus (nil, empty, AutoFill), never per keystroke. With temporary logging the sequence was N E P | | | |.
  • There is no empty list after an AutoFill list, so nothing is ever held. Recordings of main and of this PR both show 0 blink frames.

So this is a regression in iOS 27. On older iOS, or wherever the private names are missing, the change is a no-op.

Screenshots (if appropriate)

Three consecutive frames from the main recording while typing. The middle one is the blink:

blink-frames

🤖 Generated with Claude Code

In a WKWebView, typing in a username or password field makes UIKit set an
empty suggestion list on every keystroke and put the AutoFill "Passwords"
key back about 5-10 ms later. A frame drawn in between shows the QuickType
bar empty, so the bar blinks as the user types. Native text fields and
Safari do not set the empty list.

While the bar shows an AutoFill key, hold an empty list for 100 ms: the
next list replaces it, or it is applied late. A nil list (keyboard going
away) is never held. If the private class or selector is missing, nothing
is swizzled.

The example app gets a username and a password field to reproduce it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@shivapoudel
shivapoudel force-pushed the fix/ios-autofill-bar-blink branch from 664e5d0 to 207c474 Compare October 9, 2026 06:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant