Repository navigation
Conversation
`SafeAreaInsetsObserver` reports a view's safe-area insets only when an edge moves more than one physical pixel from the last report, to match iOS's precision while the view moves. A change within that threshold was dropped for good. The last frame of a transition often moves a view by its last pixel, so a screen that slid in from the side kept reporting the one-pixel inset it had on the frame before it stopped. Which frames the observer saw decided whether this happened, so the same screen could end with different insets each time it opened. Hold a change within the threshold and request another frame. If the insets are the same on that frame, they have settled and are reported. If they moved again, they are held again, so a view that moves less than a pixel per frame still sends nothing until it stops or moves past the threshold. Insets within 0.01 px of the last report count as unchanged, so a settled view sends nothing more. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary:
SafeAreaInsetsObserverreports a view's safe-area insets only when an edge moves more than one physical pixel from the last report, to match iOS's precision while the view moves. A change within that threshold is dropped for good. The last frame of a transition often moves a view by its last pixel, so a screen that slides in from the side can keep reporting the one-pixel inset it had on the frame before it stopped. Whether this happens depends on which frames the observer sees, so the same screen can end with different insets each time it opens.This change holds a change within the threshold and requests another frame (
postInvalidateOnAnimation):The threshold while the view moves is unchanged.
Changelog:
[ANDROID] [FIXED] - Report a view's safe-area insets when its last sub-pixel change settles
Test Plan:
SafeAreaInsetsObserverTest.lastPixelOfASlideIn_isReportedOnceTheViewHoldsStillmoves a view in by 3, 1 and 0 px oftranslationX. It expects the last pixel to be reported asright: 0on the frame after the view stops, and no further report on the frame after that.Run for this branch on
upstream/main94aee19ac9: ktfmt--dry-run --set-exit-if-changedon the two changed Kotlin files (clean) andgit diff --check(clean).Run on this base (2026-11-28):
SafeAreaInsetsObserver.ktfrommainand the new test kept: 40 tests, 1 failed (lastPixelOfASlideIn_isReportedOnceTheViewHoldsStill).Not run: a device or emulator check.
🤖 Generated with Claude Code