Skip to content

test: fix GalleryNavigationTest flake on Android 30 - #7

Merged
thisislvca merged 3 commits into
refactor/rename-to-albafrom
test/fix-gallery-navigation-api30
Oct 17, 2026
Merged

thisislvca merged 3 commits into
refactor/rename-to-albafrom
test/fix-gallery-navigation-api30

Conversation

@thisislvca

@thisislvca thisislvca commented Oct 17, 2026 •

Copy link
Copy Markdown
Owner

GalleryNavigationTest.libraryLeadsWithPhotosAndDestinationsPreserveTheirOwnState failed intermittently on API 30 CI after recreate(): the library grid was at the top, so the tile was never displayed.

Root cause: a restored LazyGridState only holds an index. If the grid is first measured against fewer items than that index (another tab's results still showing after the tab switch, or an unloaded catalog), the index is clamped and the scroll resets. Reproduced on CI with a 30x repeated copy of the test (failure: scroll=0 right after tapping the Library tab); 0 failures in 30 repeats after the fix.

Fix: GridAnchor remembers the first visible photo id and offset per grid, saves it, and re-applies it once the photo is present; user scrolling cancels it. GridAnchorTest covers the clamp deterministically (fails without the fix).

A restored LazyGridState only holds an index. When the grid is first measured against fewer items than that (another tab's results still showing, or a catalog that has not loaded), the index is clamped and the scroll resets to the top. On slow CI emulators this made GalleryNavigationTest lose the library position after recreate().

Remember the first visible photo id and offset per grid, save it, and re-apply it once the photo is present. A user scroll cancels the pending restore.
@thisislvca
thisislvca force-pushed the test/fix-gallery-navigation-api30 branch from dba6b9a to f4b318c Compare October 17, 2026 18:15
@thisislvca
thisislvca merged commit 40ba2d1 into refactor/rename-to-alba Oct 17, 2026
4 checks passed
@thisislvca
thisislvca deleted the test/fix-gallery-navigation-api30 branch October 17, 2026 20:50
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