Repository navigation
[iOS] Show the RefreshView indicator when refreshing starts before the view is on screen - #40660
Conversation
…e view is on screen UIKit drops a UIRefreshControl.BeginRefreshing made before the view is in a window, so IsRefreshing=true set in a page constructor, on Appearing or before a push never showed the indicator. MauiRefreshView now begins refreshing only when it is in a window, and otherwise starts on the first layout pass inside one, from the stored IsRefreshing value rather than after a delay. In that case the control begins before the offset is applied, since the opposite order doubled the offset on the first layout, and the scroll position isn't restored when it ends because it wasn't final yet. Fixes dotnet#32244
This comment has been minimized.
This comment has been minimized.
|
Hey there @marcelomoresco! Thank you so much for your PR! Someone from the team will get assigned to your PR shortly and we'll get it reviewed. |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
…arts The refresh that starts on the first layout pass used the stored start position without capturing it, so a view that left the window and came back scrolled was offset from a stale value. The position is now always captured, and it is restored when the refresh ends if it was final or the content was scrolled. When the deferred refresh starts with the content resting at a top inset, it is offset from that inset so the whole indicator is revealed. The device tests now check the revealed extent and the settled offset with and without a top inset, a pending refresh on reattach while scrolled, and a pending refresh cancelled before being in a window.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Expert Review — 0 findings
Reviewed commit ad6db23.
The deferred start ran on every layout pass while the refresh control was not refreshing. If UIKit did not keep the control refreshing, each start changed the content offset, triggered another layout and started again, which hung the RefreshView UI tests on Mac Catalyst. The start is now a one-shot that is armed when IsRefreshing turns on outside a window and cleared when it turns off. The iOS 26 baseline of Issue30535 is updated: the refresh that begins while the page is covered now animates when the page returns, instead of showing a static indicator.
|
Fixed: the deferred start was restarting on every layout pass while the refresh control wasn't refreshing yet, which hung Mac Catalyst. It's now one-shot (new device test PendingRefreshStartsOnlyOnce). Also updated the iOS 26 Issue30535 baseline, since a normal refresh with the view already on screen also animates gray there. Commit de47b8a. |
This comment has been minimized.
This comment has been minimized.
|
Thanks, the Mac Catalyst timeouts weren't a layout loop: the app stays responsive while the refresh indicator spins, but the Catalyst Appium session has no waitForIdleTimeout (iOS uses 5s), so a programmatic refresh that never ends keeps every command waiting. Before this PR those refreshes were requested off-window and dropped by UIKit, so nothing spun. Since the issue is iOS-only, a03ef39 keeps the previous behavior on Mac Catalyst and limits the deferred-start tests to iOS. It also updates the iOS 18 baseline of Issue30535, where the indicator now animates like in the iOS 26 one. Could you re-run the tests? |
1 similar comment
|
Thanks, the Mac Catalyst timeouts weren't a layout loop: the app stays responsive while the refresh indicator spins, but the Catalyst Appium session has no waitForIdleTimeout (iOS uses 5s), so a programmatic refresh that never ends keeps every command waiting. Before this PR those refreshes were requested off-window and dropped by UIKit, so nothing spun. Since the issue is iOS-only, a03ef39 keeps the previous behavior on Mac Catalyst and limits the deferred-start tests to iOS. It also updates the iOS 18 baseline of Issue30535, where the indicator now animates like in the iOS 26 one. Could you re-run the tests? |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Expert Review — No more findings
Reviewed commit a03ef39.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Merged by MAUI Autopilot to resolve merge conflicts.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Expert Review — No more findings
Reviewed commit 32977e7.
Selected Tests🧪 Test selection — click to expand
🧪 UI tests —
|
| Platform | Categories |
|---|---|
| iOS | RefreshView |
| MacCatalyst | RefreshView |
🧪 Device tests — Controls.RefreshView, Core.RefreshView on iOS, MacCatalyst
❌ Could not queue maui-pr-devicetests: Azure Pipelines did not start maui-pr-devicetests for the dispatch branch run-devicetests/pr40660-46538780389 within 10 minutes. Comment /review run-tests again, or use /azp run maui-pr-devicetests for the full suite.
GPT-6.2 Sol: Run Core and Controls RefreshView device tests on iOS and Mac Catalyst for native refresh behavior and control integration.
MAI Code 2: iOS-family RefreshView native lifecycle changes; runs Core and Controls RefreshView device tests on iOS and Mac Catalyst.
🧪 Running — 2 categories on iOS, MacCatalyst
| Platform | Categories |
|---|---|
| iOS | Controls.RefreshView, Core.RefreshView |
| MacCatalyst | Controls.RefreshView, Core.RefreshView |
⏭️ Skipped — what neither suite runs
UI tests — 76 categories, 2 platforms
Platforms not run: Android, Windows
Categories not run: Accessibility, ActionSheet, ActivityIndicator, Animation, AppLinks, Border, BoxView, Brush, Button, CarouselView, CollectionView1, CollectionView2, CollectionView3, CollectionView4, CollectionView5, CollectionView6, CollectionView7, Cells, CheckBox, ContextActions, CustomRenderers, DatePicker, Dispatcher, DisplayAlert, DisplayPrompt, DragAndDrop, Entry, Editor, Effects, Essentials, FlyoutPage, Focus, Fonts, Frame, Gestures, GraphicsView, Image, ImageButton, IndicatorView, InputTransparent, IsEnabled, IsVisible, Label, Layout, Lifecycle, ManualReview, Maps, Navigation, Page, Performance, Picker, ProgressBar, RadioButton, SafeAreaEdges, Shadow, ScrollView, SearchBar, Shape, Slider, SoftInput, Stepper, Switch, SwipeView, Shell1, Shell2, TabbedPage, TableView, TimePicker, TitleView, ToolbarItem, Triggers, ViewBaseTests, VisualStateManager, Window, WebView, Material3
Each skipped platform and category is listed as a maui-pr-uitests (skipped) … status on this commit. Use /azp run maui-pr-uitests for the full suite.
Device tests — 103 categories, 2 platforms
Platforms not run: Android, Windows
Categories not run: Controls.Accessibility, Controls.Animations, Controls.Application, Controls.Behavior, Controls.Border, Controls.BoxView, Controls.Button, Controls.CarouselView, Controls.CheckBox, Controls.CollectionView, Controls.Compatibility, Controls.ContentView, Controls.DatePicker, Controls.Dispatcher, Controls.Editor, Controls.Element, Controls.Entry, Controls.FlexLayout, Controls.FlyoutPage, Controls.Frame, Controls.Gesture, Controls.HybridWebView, Controls.Image, Controls.Label, Controls.Layout, Controls.Lifecycle, Controls.Map, Controls.Mapper, Controls.Memory, Controls.MenuFlyout, Controls.Modal, Controls.NavigationPage, Controls.Page, Controls.PageTransitions, Controls.Path, Controls.Picker, Controls.RadioButton, Controls.ScrollView, Controls.SearchBar, Controls.Shape, Controls.Shell, Controls.Slider, Controls.SwipeView, Controls.Switch, Controls.TabbedPage, Controls.TemplatedView, Controls.TextInput, Controls.Toolbar, Controls.View, Controls.VisualElement, Controls.VisualElementTree, Controls.WebView, Controls.Window, Controls.WindowOverlay, Controls.Xaml, Core.ActivityIndicator, Core.Animation, Core.Application, Core.Border, Core.BoxView, Core.Button, Core.CheckBox, Core.ContentView, Core.DatePicker, Core.Dispatcher, Core.Editor, Core.Element, Core.Entry, Core.FlowDirection, Core.FlyoutView, Core.Fonts, Core.Formatting, Core.Graphics, Core.GraphicsView, Core.Image, Core.ImageButton, Core.ImageSource, Core.IndicatorView, Core.Label, Core.Layout, Core.Lifecycle, Core.MauiContext, Core.Memory, Core.NavigationPage, Core.Page, Core.Picker, Core.ProgressBar, Core.RadioButton, Core.ScrollView, Core.SearchBar, Core.ShapeView, Core.Slider, Core.Stepper, Core.SwipeView, Core.Switch, Core.TimePicker, Core.View, Core.WebView, Core.Window, Core.WindowOverlay, Graphics, Essentials, BlazorWebView
Each skipped platform and project is listed as a maui-pr-devicetests (skipped) … status on this commit. Use /azp run maui-pr-devicetests for the full suite.
🤖 Why these tests — AI rationale (GPT-6.2 Sol + MAI Code 2)
UI tests
Each model chose independently; every test that runs was selected by at least one of them.
| Platform | GPT-6.2 Sol | MAI Code 2 |
|---|---|---|
| Android | — | — |
| iOS | RefreshView |
RefreshView |
| MacCatalyst | RefreshView |
RefreshView |
| Windows | — | — |
GPT-6.2 Sol — Run RefreshView UI tests on iOS and Mac Catalyst for refresh indicator startup and scroll positioning.
- The updated iOS snapshots cover the indicator when a page opens.
- MauiRefreshView defers startup only on iOS, but its immediate refresh path also runs on Mac Catalyst.
- No Android, Windows, or unrelated control behavior changed.
MAI Code 2 — iOS RefreshView deferred-start fix; runs RefreshView UI tests on iOS and Mac Catalyst.
Platform/iOS/MauiRefreshView.cschanges RefreshView lifecycle, layout, and scroll-offset behavior on iOS and shared iOS/Mac Catalyst compilation.- The iOS snapshot updates exercise the existing RefreshView UI scenario.
- RefreshView is selected on iOS and Mac Catalyst; Android and Windows are deliberately excluded because the changed native implementation is iOS-family specific.
- No broader categories are included because the change is isolated from other controls and base layout infrastructure.
Device tests
Each model chose independently; every test that runs was selected by at least one of them.
| Platform | GPT-6.2 Sol | MAI Code 2 |
|---|---|---|
| Android | — | — |
| iOS | Core.RefreshView, Controls.RefreshView |
Core.RefreshView, Controls.RefreshView |
| MacCatalyst | Core.RefreshView, Controls.RefreshView |
Core.RefreshView, Controls.RefreshView |
| Windows | — | — |
GPT-6.2 Sol — Run Core and Controls RefreshView device tests on iOS and Mac Catalyst for native refresh behavior and control integration.
- Core.RefreshView covers deferred startup, cancellation, and scroll restoration; the new cases are iOS-only.
- Keep Core and Controls on Mac Catalyst for the shared immediate path and native layout overrides.
- No other device units or platforms are affected.
MAI Code 2 — iOS-family RefreshView native lifecycle changes; runs Core and Controls RefreshView device tests on iOS and Mac Catalyst.
- The Core
MauiRefreshViewiOS-family handler changes, so both Core.RefreshView handler coverage and Controls.RefreshView behavior coverage are relevant. - The added device tests validate deferred start, reattachment, cancellation, and restoration logic; they are iOS-specific while the production file is also compiled for Mac Catalyst.
- Android and Windows plus unrelated device categories are excluded because no affected code or tests target those platforms or controls.
Generated by /review run-tests. A targeted run is a fast signal, not full-suite certification.
MAUI Autopilot — Ready for maintainer reviewResults
|
Target Branch
Targets
net11:mainnow targets .NET 12, which this SDK can't build; MauiRefreshView.cs and the test are identical on both branches.Description of Change
UIKit drops
UIRefreshControl.BeginRefreshingcalled before the view is in a window, soIsRefreshing=trueset in a page constructor,Appearing, or before a push never showed the indicator.MauiRefreshViewnow begins refreshing only while in a window; otherwise it starts on the first layout pass once it is, from the storedIsRefreshingvalue (not a delay like the earlier #33029 approach). The start offset is always captured on that first layout, and it's only restored at completion if it was final or the content had scrolled — this also covers a reattach while scrolled and a deferred start at a top inset.Adds overrides of existing UIView methods (
MovedToWindow,LayoutSubviews), hence thePublicAPI.Unshippedentries for ios/maccatalyst — no new callable member.Verification
iOS 26.5 simulator, 24 cases before/after: constructor, Appearing, push, empty CollectionView, no NavigationPage, and tab switch all go from "no indicator" to a visible 60pt indicator and restore correctly; a ScrollView under the safe area with the refresh set before entering the screen also now shows the indicator (it stays hidden only when the refresh is set with the view already loaded). All other already-working cases unchanged.
Follow-up fix (
ad6db23c8) verified on the iOS 26.5 simulator by replicating the device tests' logic in a sample app: the previous head failed at a top inset of 100 and on reattach while scrolled; the new one passes those plus the cancellation-before-attach case. The 24 earlier cases are unchanged except 2 that improved.Unchanged either way (out of scope, worth noting): no indicator with a large title; RefreshColor doesn't apply on the first refresh.
Not verified: device tests (compile only — Xcode 26.6), physical device, Mac Catalyst, iOS < 26, UI test.
Issues Fixed
Fixes #32244