Repository navigation
fix(text): 화면 밀도가 바뀌면 마운트된 Text 를 새 밀도로 다시 그린다 - #17
Merged
Merged
Conversation
Summary: Pull Request resolved: react#59049 When an Android app handles density changes itself (`density` in `android:configChanges`), its surface is laid out again at the new density, but some mounted views keep sizes from the old one: - Padding and overflow insets are sent to views in pixels, but only when their dp values change, which a density change usually doesn't do. A `TextInput` keeps its old pixel padding, so its text and placeholder can be clipped. - Paragraph state only updates when the text, its attributes or its measured size change, so `Text` keeps the layout it built at the old density and draws at the old size. With the new `fixTextLayoutOnPixelDensityChange` feature flag on, padding and overflow insets are re-sent when the pixel density changes (zero insets are skipped: they are zero pixels at any density), and paragraph state is rebuilt. Both text paths are covered: with `enablePreparedTextLayout`, the paragraph prepares a new layout at the new density (the prepared text cache is keyed by density) and its state now updates when only the density changed; without it, the state records the density too. The flag is off by default. **How to use:** return `true` from your app's feature flag overrides, before React Native starts: ``` override fun fixTextLayoutOnPixelDensityChange(): Boolean = true ``` Changelog: [Internal] Reviewed By: javache Differential Revision: D124076552 fbshipit-source-id: f103c71785298a9d06888548c38049dc8847a62a (cherry picked from commit d026c0f)
zeta 앱은 MainActivity 에 configChanges="density" 를 넣어 화면 밀도가 바뀌어도 Activity 를 다시 만들지 않는다. 그러면 이미 마운트된 Text 가 옛 밀도의 글꼴 px 로 그려지고 새 frame 에 잘린다. 상류 react#59049 수정은 flag 뒤에 있고 기본값이 false 라, fork 에서는 기본값을 true 로 둔다 (상류 expectedReleaseValue 도 true). 앱은 loadReactNative 의 override 를 쓰므로 앱 쪽에서 따로 켜지 않는다. 변경한 tarball 경로를 allowed-tarball-diff.txt 에 추가한다. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Important Draft PR not reviewedDraft PRs are not automatically reviewed by default.
To automatically review draft PRs, update your CodeRabbit configuration: reviews:
auto_review:
drafts: true
|
kdwkr
marked this pull request as ready for review
December 2, 2026 07:21
This was referenced Dec 2, 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.
Summary:
zeta 앱은 MainActivity
configChanges에density를 넣습니다(scatterlab/zeta-frontend#9241). 그래서 화면 밀도가 바뀌어도(디스플레이 크기,wm density) Activity를 다시 만들지 않습니다. 이때 이미 마운트된Text는 옛 밀도의 글꼴 px로 그려지고, 새 frame에 잘립니다. 에뮬레이터wm density 240/400에서 "Cha", "Ho"처럼 잘리는 것을 확인했습니다.원인
ParagraphShadowNode::updateStateIfNeeded(content)(ParagraphShadowNode.cpp:168-176)는 attributedString이 같으면 state를 그대로 둡니다.TextView가 옛 밀도로 만든 spannable을 계속 씁니다.pointScaleFactor로 다시 잡히므로 글자가 잘립니다.:154)도 size, attributedString, paragraphAttributes만 비교합니다.수정
cherry-pick -x했습니다. 다음 두 동작이 들어갑니다.pointScaleFactor를 넣어 비교하고, 밀도가 바뀌면 state를 갱신합니다(prepared 경로와 non-prepared 경로 모두).FabricMountingManager가 밀도가 바뀌면 padding과 overflowInset을 다시 보냅니다.fixTextLayoutOnPixelDensityChangeflag 뒤에 있고 기본값이 false입니다(expectedReleaseValue: true). fork에서는 기본값을 true로 둡니다. 앱은loadReactNative의 override를 쓰므로 앱 쪽에서 켜기가 번거롭습니다.충돌 처리
yarn featureflags --update로 다시 생성했습니다.scripts/cxx-api/api-snapshots/*Frameworks*.api3개: fork에 없는 파일이라 넣지 않았습니다.FabricMountingManagerTestHelper.*,FabricMountingManagerInstrumentationTest.kt) 4개: 넣지 않았습니다. fork에 없는 중간 상류 커밋(synchronouslyUpdateAnimatedProps등)에 의존하고, fork에서는 상류 테스트 CI가 돌지 않습니다..github/scatterlab/allowed-tarball-diff.txt에 추가했습니다.넣지 않은 것
enablePreparedTextLayout이 기본 false라 해당 경로를 타지 않습니다.릴리스(prebuilt, npm publish)는 이 PR에 포함하지 않습니다.
Changelog:
[ANDROID] [FIXED] - 화면 밀도가 바뀌어도 Activity를 다시 만들지 않는 앱에서 마운트된 Text가 옛 밀도로 그려져 잘리던 문제
Test Plan:
yarn featureflags --update재생성이 깨끗한지 확인했습니다. 다시 생성해도 diff가 없습니다.adb shell wm density 240→400→reset순서로 바꿨을 때 채팅 목록 제목, 탭 라벨, DebugInfo 오버레이 글자가 새 밀도 크기로 다시 그려지고 잘리지 않는다🤖 Generated with Claude Code