Skip to content

fix(mobile): Android diff no longer stalls when comment cards scroll into view - #25994

Closed
bartlomiejbloniarz wants to merge 1 commit into
pingdotgg:mainfrom
bartlomiejbloniarz:fix/android-diff-comment-scroll
Closed

bartlomiejbloniarz wants to merge 1 commit into
pingdotgg:mainfrom
bartlomiejbloniarz:fix/android-diff-comment-scroll

Conversation

@bartlomiejbloniarz

Copy link
Copy Markdown
Contributor

Problem

On Android, scrolling a pull request's changes stalls whenever a comment card is on screen. Each frame takes over a second when the comments are long, as bot reviews often are. Reproduce with software-mansion/react-native-reanimated#10880: open SharedTransitions.cpp and scroll past its comments on lines 375–395.

Change

A comment card shows one line of its comment, cut to fit with "...". The cut removed one character at a time and re-measured the remaining text after each removal, on every frame. A 9,000-character comment meant thousands of text measurements per card per frame.

The cut now asks Android's text measurement for the fitting length in one call (Paint.breakText). It also no longer splits an emoji or other surrogate pair in half. Notice rows use the same helper and get the same speedup.

Scope and approval

A small fix for an obvious performance bug in the Android diff view. It changes one helper and adds a regression test. iOS draws comment cards differently and is not affected.

Verification

  • New test ellipsizingALongCommentDoesNotRemeasureItPerCharacter counts text measurements for one long comment. It fails before the fix (6,181 measurements) and passes after. The whole Android native suite (apps/mobile/modules/t3-review-diff/tests/run-android.sh) passes.
  • Pixel 5 emulator (API 35, GPU-accelerated), PR above, same scroll gestures over the long comments, frame times from dumpsys gfxinfo:
BeforeAfter
Median frame1,400 ms17 ms
99th percentile frame2,950 ms34 ms

Android emulator, software-mansion/react-native-reanimated#10880, SharedTransitions.cpp, same swipes from line 233 down past the comments

BeforeAfter
android-before.mp4
android-after.mp4

Not checked on a physical Android device.

Claude Opus 5.5 in Claude Code, run from T3 Code.

@github-actions github-actions Bot added vouch:unvouched Author is not yet trusted in the VOUCHED list. size:XS 0-9 changed lines (additions + deletions). labels Oct 27, 2026
@macroscopeapp

macroscopeapp Bot commented Oct 27, 2026

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Approved at 20b9c56

Macroscope's review found this PR approvable — This is a narrowly scoped Android performance fix that replaces repeated text measurements in existing comment and notice rendering with a single fitting calculation, while adding a focused regression test. It does not change product defaults or introduce new capabilities, schemas, infrastructure, or sensitive-area behavior.

You can add or adjust custom eligibility rules. Learn more.

@coderabbitai

coderabbitai Bot commented Oct 27, 2026

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
Commits

Reviewing files that changed from the base of the PR and between 36d4d71 and 20b9c56.

Files selected for processing: 2
  • apps/mobile/modules/t3-review-diff/android/src/main/java/expo/modules/t3reviewdiff/T3ReviewDiffView.kt
  • apps/mobile/modules/t3-review-diff/tests/android/src/test/kotlin/expo/modules/t3reviewdiff/ReviewDiffGeometryTest.kt

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

Walkthrough

The Android ellipsize helper now uses Paint.breakText to find a fitting prefix and avoids ending the prefix on a high surrogate. A test checks its text measurement count, ellipsis, and output width.

Changes: Android comment ellipsizing

Layer / File(s) Summary
Prefix measurement and validation
apps/mobile/modules/t3-review-diff/android/src/main/java/expo/modules/t3reviewdiff/T3ReviewDiffView.kt, apps/mobile/modules/t3-review-diff/tests/android/src/test/kotlin/expo/modules/t3reviewdiff/ReviewDiffGeometryTest.kt
ellipsize is now module-visible and uses Paint.breakText to select a prefix. The test checks that a long comment uses at most two text measurements, ends with ..., and fits within 300 pixels.

Priority: High

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Suggested reviewers: juliusmarminge

Merge Risk: Minimal · up to 20b9c

No merge-blocking risk was identified in the reviewed changes.

Pre-merge checks: Passed 4
Check name Status Explanation
Description check Passed The description includes all required sections. It explains the Android performance problem, the Paint.breakText fix, scope and approval rationale, focused test results, emulator verification, before-…
Title check Passed The title clearly and concisely describes the main change: preventing Android diff scrolling stalls when comment cards enter view.
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: Description check

Explanation

The description includes all required sections. It explains the Android performance problem, the Paint.breakText fix, scope and approval rationale, focused test results, emulator verification, before-and-after metrics, and the physical-device limitation.

Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Comment @coderabbitai help to get the list of available commands.

@bartlomiejbloniarz

Copy link
Copy Markdown
Contributor Author

Closing as superseded by #26174, which fixes the same quadratic measurement and also caps the measured text.

@bartlomiejbloniarz
bartlomiejbloniarz deleted the fix/android-diff-comment-scroll branch October 27, 2026 23:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:XS 0-9 changed lines (additions + deletions). vouch:unvouched Author is not yet trusted in the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant