Skip to content

fix(Android): Theoretical measurement jump race condition - #898

Merged
szydlovsky merged 2 commits into
mainfrom
@szydlovsky/potential-measurement-jump-fix
Dec 2, 2026
Merged

szydlovsky merged 2 commits into
mainfrom
@szydlovsky/potential-measurement-jump-fix

Conversation

@szydlovsky

Copy link
Copy Markdown
Collaborator

Summary

Together with a recent fix for Android input's measurement jumps, Claude has found a theoretical race condition that could lead to a one-frame measurement jump which visually would look exactly like what React Native has.

It's so difficult to achieve that neither me nor Argent could reproduce it, but based on code analysis it's possible and fix is super cheap.

It can happen when, at the same time:

  • input's width changes
  • content update happens
  • user scrolls the input

Basically, when an Android input's width changed, MeasurementStore briefly dropped its saved maxTextHeight (used for the mentioned fix). A content update on the UI thread landing in that gap could make the loss stick, re-enabling the one-line scroll jump until the next layout pass; the fix keeps the value in that rewrite.

Test Plan

--

Screenshots / Videos

--

Compatibility

OS Implemented
iOS ❌
Android ✅
Web ❌

Checklist

  • E2E tests are passing
  • Required E2E tests have been added (if applicable)

@szydlovsky
szydlovsky requested a review from exploIF December 1, 2026 17:59
@coderabbitai

coderabbitai Bot commented Dec 1, 2026 •

Copy link
Copy Markdown

Explain Change →

Important

Review skipped

Review was skipped as selected files did not have any reviewable changes.

Run configuration

Commits

Reviewing files that changed from the base of the PR and between da9645e and 3bced52.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review

No actionable comments were generated in the recent review.

Walkthrough

When the cached measurement is recalculated after a width change, the replacement parameters now preserve the existing maxTextHeight.

Changes: Measurement update

Layer / File(s) Summary
Preserve maximum text height
android/src/main/java/com/swmansion/enriched/textinput/MeasurementStore.kt
The width-change recalculation carries the existing maxTextHeight into the replacement MeasurementParams.

Estimated code review effort: 1 (Trivial) | ~3 minutes

Change: Bug fix

Merge Risk: Minimal · previous review da964

This is a small Android fix that keeps the saved maximum text height when the input width changes. It is expected to prevent a brief measurement jump. No concrete merge-blocking risk was found.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the Android measurement jump race condition fix, which matches the single-file change that keeps maxTextHeight when MeasurementStore recalculates a cached measurement after a width cha…
Description check Passed The description explains the theoretical race between input width changes, content updates, and user scrolling. It states that MeasurementStore dropped maxTextHeight and that the fix keeps the value d…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title names the Android measurement jump race condition fix, which matches the single-file change that keeps maxTextHeight when MeasurementStore recalculates a cached measurement after a width change. It is specific and states the main change, so it passes.

Full details: Description check

Explanation

The description explains the theoretical race between input width changes, content updates, and user scrolling. It states that MeasurementStore dropped maxTextHeight and that the fix keeps the value during the rewrite, which matches the changed file. It lacks a test plan, but the check is lenient and the description is on-topic, so it passes.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between db60605 and da9645e.

Files selected for processing: 1

  • android/src/main/java/com/swmansion/enriched/textinput/MeasurementStore.kt

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 0 remain after this review.

@szydlovsky
szydlovsky merged commit 6fc0ad9 into main Dec 2, 2026
9 checks passed
@szydlovsky
szydlovsky deleted the @szydlovsky/potential-measurement-jump-fix branch December 2, 2026 11:43
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.

2 participants