Repository navigation
Fix backwards write in DancingBotHeadlineText - #220
Merged
Merged
Conversation
The placeholder size was read in composition and written back from onTextLayout, so every text layout invalidated composition and the first frame used the 220.sp default. Size the placeholder in em instead, which is resolved against the auto-sized font during text layout.
riggaroo
marked this pull request as ready for review
November 16, 2026 17:30
tiwiz
approved these changes
Nov 18, 2026
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.
Fixes a backwards write in
DancingBotHeadlineText(Home screen headline with the inline dancing bot).Problem
placeHolderSizewas read during composition to size the inline bot (Placeholder(width = placeHolderSize, …)), then written back fromonTextLayoutafter the auto-sized text was laid out:That is a Composition-read → Layout-write backwards write. Every text layout invalidates composition and triggers another pass. The first frame always uses the hard-coded
220.spdefault, and after a size change the bot keeps its old size for one frame before snapping to the right size.Fix
Size the placeholder in
em. That is resolved against the auto-sized font during text layout itself, so there's no state, noonTextLayoutwrite-back and no extra pass:Before / after (resize, frame by frame, slowed down)
The frame right after the resize: before keeps the stale 232 dp bot over the text, after is already 180 dp:
How these were captured: a Robolectric test (
GraphicsMode.NATIVE, pausedmainClock, oneadvanceTimeByFrame()per capture) renderedDancingBotHeadlineTexton both commits and read the placeholder rects fromTextLayoutResult.Device check (real Home screen, Robolectric)
HomeScreenContentsrendered on 6 device configurations on both commits (LocalInspectionMode, the same wrapper the app's@Previews use). Once settled, AFTER is pixel-identical to BEFORE on every device, so theemchange causes no visual regression. The only difference is that BEFORE's wrong first frame is gone.Unfold, folded → unfolded in one composition (top: before, bottom: after). BEFORE renders one frame with the 220.sp default (bot too small) before 290 dp. AFTER is 290 dp immediately.
Settled Home screen on all 6 devices (before | after)
Caveats: preview images stand in for the bot and video card; no system bars or insets; the unfold is a container resize inside a fixed window, not a real configuration change.
Testing
./gradlew :feature:home:spotlessCheck :feature:home:compileReleaseKotlinpasses.Found with the
jetpack-compose-performanceagent skill.