Skip to content

fix: keep native scroll adjustments precise - #602

Open
chrispader wants to merge 1 commit into
LegendApp:mainfrom
chrispader:fix/precise-scroll-adjust-anchor
Open

chrispader wants to merge 1 commit into
LegendApp:mainfrom
chrispader:fix/precise-scroll-adjust-anchor

Conversation

@chrispader

@chrispader chrispader commented Nov 9, 2026 •

Copy link
Copy Markdown

ScrollAdjust places its anchor view 10,000,000 points down, so native maintainVisibleContentPosition anchors to it. Native layout stores positions as 32-bit floats, and at that size a float only holds whole points. Each scroll adjustment was rounded by up to half a point, while the items above the viewport moved by the exact amount, so the visible content shifted by the difference, about 1 to 2 px on Android. With a bias of 1,000,000, the anchor's position stays precise to 1/16 of a point.

// An item above the viewport measures 131.9 points smaller than estimated.
Math.fround(10_000_000 - 131.9); // 9999868: the anchor moves by 132 points
Math.fround(1_000_000 - 131.9); // 999868.125: the anchor moves by 131.875 points

The bias also sets how far the list can scroll, because native MVCP only anchors to the view while it sits below the scroll offset. Each adjustment moves the anchor and the scroll offset together, so prepended content doesn't use up the range. Only content that is scrolled through without an adjustment does, such as the initial data and appended items. 1,000,000 points is about 10,000 rows of 100 points. If you'd rather trade some precision for range, 2,097,152 doubles it and still rounds to a quarter point.

We hit this in Expensify/App#100733, which moves the chat message list to LegendList. On Android, a chat that opens at a linked message moved up by 1 to 2 px when the rows above it were measured. Expensify currently carries this fix as a patch.

Reproduction

  1. On Android, render a list whose items render smaller than estimatedItemSize, with maintainVisibleContentPosition enabled.
  2. Scroll to the middle of the list.
  3. Wait until the items above the viewport are measured.
  4. Verify the items on screen don't move.

🤖 Generated with Claude Code

@chatgpt-codex-connector

Copy link
Copy Markdown
Codex Review Summary: ❌ Failed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ❌ Failed 2026-11-09T11:06:04.627227Z
We couldn’t complete this review. Comment @codex review to try again.
7901cbd PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Credits must be used to enable repository wide code reviews.

chrispader added a commit to margelo/Expensify that referenced this pull request Nov 9, 2026
LegendList anchors native scroll adjustments to a view placed 10,000,000 points down. Native layout stores positions as 32-bit floats, which hold that value only to whole points, so each adjustment was rounded while the items moved by the exact amount. On Android, a chat opened at a linked message moved up by 1-2 px when the rows above it were measured. Patch the anchor down to 1,000,000 points, as proposed upstream in LegendApp/legend-list#602.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
chrispader added a commit to margelo/Expensify that referenced this pull request Nov 9, 2026
LegendList anchors native scroll adjustments to a view placed 10,000,000 points down. Native layout stores positions as 32-bit floats, which hold that value only to whole points, so each adjustment was rounded while the items moved by the exact amount. Patch the anchor down to 1,000,000 points, as proposed upstream in LegendApp/legend-list#602.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ScrollAdjust placed its anchor view 10,000,000 points down so native maintainVisibleContentPosition always anchors to it. Native layout stores positions as 32-bit floats, which hold values of that size only to the nearest whole point. Each adjustment was rounded by up to half a point while the items moved by the exact amount, so the visible content shifted by one or two pixels when items above the viewport changed size. A bias of 1,000,000 keeps the anchor below the scroll offset and keeps positions precise to 1/16 of a point.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@chrispader
chrispader force-pushed the fix/precise-scroll-adjust-anchor branch from 7901cbd to 1142f27 Compare November 11, 2026 12:15
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