Repository navigation
Conversation
|
🤖 Your WebAssembly Sample App stage site is ready! Visit it here: |
|
The build 247788 found UI Test snapshots differences: Details
|
Re-enable TextInputPlugin.OnProvideAutofillVirtualStructure so autofill services see each live TextBox as a virtual child (id, bounds, value, input type), and derive autofill hints from password mode and input scope. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
…unload Nothing called ITextBoxNotificationsProviderSingleton.OnEnteredVisualTree / OnLeaveVisualTree anymore, so the Android live TextBox list was always empty and the autofill virtual structure had no children. Call them from TextBoxCore load/unload, and make the Android registration idempotent. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
…tials can be saved The TextBoxes are virtual children of the render view, so the autofill framework never learned they went away (e.g. on navigation after login) and never offered to save the credentials. Report visibility on TextBox load/unload. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Google autofill did not recognize a plain text field as the username, so it only filled the password and never offered to save. Mark a text field that directly precedes a password field with AutofillHintUsername. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Assert one OnEnteredVisualTree per Loaded and one OnLeaveVisualTree per Unloaded for TextBox and PasswordBox, including reload and re-parenting, so the Android autofill live list can't silently go empty again. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The autofill structure listed every live TextBox of the process as Visible, in load order. List only the TextBoxes of the render view's window, report collapsed ones (and those of a page being navigated away from) as Gone, and order them on screen so the username hint goes to the field above the password field. Visibility changes are now also reported after layout, so collapsing a login form lets the autofill framework offer to save. Co-Authored-By: Claude Opus 5.5 <[email protected]>
An exception in OnProvideAutofillVirtualStructure or Autofill crossed back into Java and crashed the app, and Autofill read TextValue without checking the value type. Move the duplicated Autofill of the three render views into TextInputPlugin, catch and log failures, and only fill text values into enabled, editable TextBoxes of the view's window. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The NotifyValueChanged debug trace printed the text of every input, PasswordBox included. Log the virtual id instead. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1769961 to
89b9446
Compare
| catch (Exception e) | ||
| { | ||
| if (this.Log().IsEnabled(LogLevel.Error)) | ||
| { | ||
| this.Log().Error($"{nameof(OnProvideAutofillVirtualStructure)} failed", e); | ||
| } | ||
| } |
| catch (Exception e) | ||
| { | ||
| if (this.Log().IsEnabled(LogLevel.Error)) | ||
| { | ||
| this.Log().Error($"{nameof(Autofill)} failed", e); | ||
| } | ||
| } |
|
The build 248099 found UI Test snapshots differences: Details
|
|
Tick the box to add this pull request to the merge queue (same as
|
|
🤖 Your WebAssembly Sample App stage site is ready! Visit it here: |
|
The build 248466 found UI Test snapshots differences: Details
|
ajpinedam
left a comment
There was a problem hiding this comment.
I reviewed this and checked the main points on a Pixel 6 (API 34, Google autofill) with a Debug SamplesApp built from 89b9446987. Good news first: the basic flow works on API 34 too. Google recognizes both fields, and the save dialog appears once the form is removed.
Three things reproduced on the device (details inline):
- The password still reaches logcat, through
TextInputConnection.OnTextInputHostChangedon the sameNotifyValueChangedpath. - The save prompt is lost when a field is collapsed and the app goes to the background and comes back, because the render views don't override
IsVisibleToUserForAutofill(int). - The username hint can land on the wrong field: a "First name | Last name" row above the password, or a right-to-left row.
Other points, from reading the code:
- None of the Android-only logic has an automated test: structure order, hints, Gone, which fields
Autofillaccepts, the API 27/28 paths. Moving the order and hint selection into a pure helper would make it unit-testable. Otherwise, could the PR say which API levels and render views were run? FinishAutofillContextis still under#if falseinTextBoxCore.Input.cs:775. Is that intended? Autofill was turned off in 163100d (uno-private#631) with no recorded reason, and the removed comment called the derived hints "not really correct", so it would help to say why it's fine to bring it back now.- The "page being navigated away from" case can't trigger:
IsLeavingFrameis only true inside the try/finally ofFrame.MoveFocusFromCurrentContent. Those fields become Gone because they unload, which works, but the comment onIsEffectivelyVisibleand the PR text describe something else. - The input-scope-to-hint table repeats the iOS one (
InputScopeHelper.UIKit.cs), and they already differ. Maybe track a shared model on #26610 before WebAssembly and Desktop add more copies. - Nits: the new test could take
[GitHubWorkItem]and clear the window content in afinally; the sample's instructions only mention iOS; four commit subjects are over 50 characters.
| // Resolves the text input plugin of the render view owning the given XamlRoot's window. | ||
| // TODO #8341: the foreground-activity fallback is ambiguous once multiple windows exist. | ||
| private static TextInputPlugin? GetTextInputPlugin(XamlRoot? xamlRoot = null) | ||
| internal static TextInputPlugin? GetTextInputPlugin(XamlRoot? xamlRoot = null) |
There was a problem hiding this comment.
The autofill paths now use this to decide which view owns a TextBox, so the fallback to BaseActivity.Current matters. Take a TextBox whose window is gone, or whose XamlRoot is null at Unloaded: it's treated as belonging to the foreground activity, listed in that activity's structure, and it accepts fills there.
A strict match without the fallback would be safer for GetAutofillFields and Autofill.
| LiveTextBoxes.Add(textBox); | ||
| LiveTextBoxesMap.Add(textBox.GetHashCode(), textBox); | ||
| // Unloaded runs before the next Loaded (also when re-parenting), but never register an instance twice. | ||
| if (LiveTextBoxesMap.TryAdd(textBox.GetHashCode(), textBox)) |
There was a problem hiding this comment.
The id is GetHashCode(), which isn't unique. With TryAdd, a TextBox whose hash collides with another is silently left out; the old Add threw instead. When that TextBox unloads, Remove(hash) on line 90 drops the other TextBox's entry.
It's rare, but cheap to guard: only remove the entry when the map value is the same instance.
| internal static bool IsEffectivelyVisible(TextBoxCore textBox) | ||
| => textBox.Owner.Visibility == Visibility.Visible && textBox.Owner.AreAllAncestorsVisible(); | ||
|
|
||
| private void ReportVisibility(TextBoxCore textBox, bool isVisible) |
There was a problem hiding this comment.
Reproduced on the device. Android re-reads the visibility of every tracked field through View.IsVisibleToUserForAutofill(int), both when the activity resumes (AutofillManager.onVisibleForAutofill) and when it rebuilds its tracked list. The default returns true, and the Android docs say views with virtual children must override it. None of the three render views do.
Combined with the dedupe here, a field reported Gone before a resume becomes visible again for Android, and it is never reported again.
Steps:
- Type a username, then collapse it.
- Press Home and come back.
- Type the password, then remove the form.
There is no save prompt. With verbose autofill logs:
- on resume,
autofillClientGetViewVisibility(): [true, true]; - when the form is removed, only the password's
isVisible=false; finishSessionLockedis never called.
The same steps without Home/back show the save dialog.
Overriding IsVisibleToUserForAutofill in the render views, returning IsEffectivelyVisible for the matching TextBox and false for unknown ids, should fix it.
| } | ||
| } | ||
|
|
||
| private void OnLayoutUpdated(object? sender, object e) |
There was a problem hiding this comment.
Once a TextBox loads, this walks the ancestors of every live TextBox after every layout pass, in every app. That includes API 26, where the virtual visibility call does nothing, and devices with no autofill service.
It costs nothing at idle, since UpdateLayout returns early. But it runs every frame during layout animations, which goes against the note in TextBoxCore.IME.cs:143.
Could the subscription be limited to API ≥ 27 with AutofillManager.IsEnabled, or ideally to an active autofill session?
| { | ||
| this.LogDebug()?.Debug($"NotifyValueChanged: {newValue}"); | ||
| // Never log the value: it can be a password. | ||
| this.LogDebug()?.Debug($"NotifyValueChanged: {virtualId}"); |
There was a problem hiding this comment.
The value is still logged two lines down. _inputConnection?.OnTextInputHostChanged() logs OnActiveTextInputHostChanged: {_activeHost.Text} at Debug (TextInputConnection.cs:109), and for a PasswordBox Text is the password.
On the device, typing in a PasswordBox printed OnActiveTextInputHostChanged: Secr3tPwA right next to NotifyValueChanged: -387129234 (SamplesApp turns on Debug for Uno.UI.Runtime.*). CommitText (:586) and SetComposingText (:848) log typed text too.
Could those log the length instead? Otherwise the commit message should say it only fixes this one line.
| && ReferenceEquals(AndroidSkiaTextBoxNotificationsProviderSingleton.GetTextInputPlugin(textBox.Owner.XamlRoot), this) | ||
| && values.ValueAt(i) is AutofillValue { IsText: true } value) | ||
| { | ||
| textBox.Text = value.TextValue ?? string.Empty; |
There was a problem hiding this comment.
textBox.Text = … runs app code: TextChanging handlers and two-way bindings. If it throws, the catch below ends the loop, so the remaining fields (often the password) aren't filled. The error also only goes to the Uno log, which release apps usually have off.
Catching per field and calling Application.Current?.RaiseRecoverableUnhandledException(e), as NativeApplication.cs:185 does, would fill the other fields and surface the error.
Also, this accepts fields that the structure reports as Gone. Checking IsEffectivelyVisible here would make it match the structure.
| child.SetEnabled(textBox.Owner.IsEnabled && !textBox.IsReadOnly); | ||
| child.SetVisibility(isVisible ? ViewStates.Visible : ViewStates.Gone); | ||
|
|
||
| var isBeforePassword = isVisible && i + 1 < fields.Count && fields[i + 1] is { IsVisible: true, TextBox.IsPassword: true }; |
There was a problem hiding this comment.
This picks the next field in screen order, not the field above the password. On the device:
- With a "First name | Last name" row above a password, Google's fill response and save info treat Last name as the username.
- In a
FlowDirection="RightToLeft"user | password row, the user field gets no hint and Google ignores it.
Fields with an unmapped input scope (Number, Url, Search) right before a password also get the username hint.
Could this be limited to a field directly above the password, overlapping it horizontally? Or it could wait until there's an explicit hint API.
GitHub Issue: related to #26610 (Android part)
PR Type:
🐞 Bugfix
What changed? 🚀
On Skia Android, autofill services (1Password, Google) saw no username/password fields: the render view's autofill structure had no children.
Autofill structure
TextInputPlugin.OnProvideAutofillVirtualStructurewas disabled (#if false). It now exposes each TextBox/PasswordBox as a virtual child: id, bounds relative to the render view, current value, input type, enabled state. Every child is marked sensitive, like a nativeEditText, so typed text is stripped from fill requests and only sent for saving. The id is the one already used byNotifyViewEntered,NotifyValueChangedandView.Autofill.Gone.TextContentType. A visible plain text field directly above a visible password field gets the username hint (Google autofill does not recognize it otherwise). Other fields get no hint.Live TextBox list and visibility
ITextBoxNotificationsProviderSingleton.OnEnteredVisualTree/OnLeaveVisualTreeanymore, so the Android live TextBox list was always empty.TextBoxCorenow calls them on load/unload.NotifyViewVisibilityChanged, API 27+) on load/unload and after layout, so the save prompt can show once the form is gone, whether it is navigated away from or collapsed.Hardening
OnProvideAutofillVirtualStructureandAutofillare guarded: an exception is logged instead of crossing back into Java. The three render views' duplicatedAutofillnow share one implementation that only fills text values into enabled, editable TextBoxes of its window.NotifyValueChangeddebug trace no longer prints the input text (it included PasswordBox values).Scope: Android only. #26610 also covers the other Skia targets (iOS, WebAssembly, Desktop); they are not addressed here. Follow-ups not in this PR: a way for a TextBox to opt out of autofill, a public API to set hints explicitly, and highlighting autofilled fields.
Validation
Given_TextBox.When_Loaded_And_Unloaded_Then_Platform_Notified_Of_Visual_Tree_Changes(TextBox and PasswordBox): checks the enter/leave notifications across load, unload, reload and re-parenting. Passes on Skia Desktop, fails without theTextBoxCorecalls.PasswordBox_AutoFillsamples and a standalone login repro:Samples:
PasswordBoxTests/PasswordBox_AutoFill(plain TextBox above a PasswordBox) exercises the username hint;TextBox/PasswordBox_AutoFillusesInputScope="EmailSmtpAddress", so it exercises the email hint, and now shows live value readouts to see what autofill wrote.PR Checklist ✅
Screenshots Compare Test Runresults.🤖 Generated with Claude Code