Skip to content

fix(text): 화면 밀도가 바뀌면 마운트된 Text 를 새 밀도로 다시 그린다 - #17

Merged
kdwkr merged 2 commits into
scatterlab/0.88.1from
daewoon/text-density-refresh
Dec 2, 2026
Merged

kdwkr merged 2 commits into
scatterlab/0.88.1from
daewoon/text-density-refresh

Conversation

@kdwkr

@kdwkr kdwkr commented Dec 2, 2026

Copy link
Copy Markdown
Member

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를 그대로 둡니다.
    • 밀도만 바뀌면 dp 단위 attributedString은 같습니다.
    • 그래서 TextView가 옛 밀도로 만든 spannable을 계속 씁니다.
    • frame은 새 pointScaleFactor로 다시 잡히므로 글자가 잘립니다.
  • prepared 경로(:154)도 size, attributedString, paragraphAttributes만 비교합니다.

수정

  • 상류 수정 Refresh padding and text after a pixel density change (#59049) react/react-native#59049 (d026c0f)를 cherry-pick -x 했습니다. 다음 두 동작이 들어갑니다.
    • state에 pointScaleFactor를 넣어 비교하고, 밀도가 바뀌면 state를 갱신합니다(prepared 경로와 non-prepared 경로 모두).
    • FabricMountingManager가 밀도가 바뀌면 padding과 overflowInset을 다시 보냅니다.
  • 상류에서는 이 동작이 fixTextLayoutOnPixelDensityChange flag 뒤에 있고 기본값이 false입니다(expectedReleaseValue: true). fork에서는 기본값을 true로 둡니다. 앱은 loadReactNative의 override를 쓰므로 앱 쪽에서 켜기가 번거롭습니다.

충돌 처리

  • 생성 featureflags 파일 19개: fork 쪽을 기준으로 두고 yarn featureflags --update로 다시 생성했습니다.
  • scripts/cxx-api/api-snapshots/*Frameworks*.api 3개: fork에 없는 파일이라 넣지 않았습니다.
  • 상류 커밋의 테스트(FabricMountingManagerTestHelper.*, FabricMountingManagerInstrumentationTest.kt) 4개: 넣지 않았습니다. fork에 없는 중간 상류 커밋(synchronouslyUpdateAnimatedProps 등)에 의존하고, fork에서는 상류 테스트 CI가 돌지 않습니다.
  • 변경한 tarball 경로는 .github/scatterlab/allowed-tarball-diff.txt에 추가했습니다.

넣지 않은 것

릴리스(prebuilt, npm publish)는 이 PR에 포함하지 않습니다.

Changelog:

[ANDROID] [FIXED] - 화면 밀도가 바뀌어도 Activity를 다시 만들지 않는 앱에서 마운트된 Text가 옛 밀도로 그려져 잘리던 문제

Test Plan:

  • 로컬 네이티브 빌드와 기기 검증은 하지 않았습니다. 통합 QA는 prebuilt 릴리스 → zeta 핀 bump 뒤에 합니다.
  • yarn featureflags --update 재생성이 깨끗한지 확인했습니다. 다시 생성해도 diff가 없습니다.
  • 통합 QA 체크리스트 (zeta-frontend#9241 빌드, AVD pixel tablet):
    • adb shell wm density 240 → 400 → reset 순서로 바꿨을 때 채팅 목록 제목, 탭 라벨, DebugInfo 오버레이 글자가 새 밀도 크기로 다시 그려지고 잘리지 않는다
    • padding이 있는 뷰(TextInput, 버튼)의 안쪽 여백이 새 밀도에 맞는다
    • 밀도를 바꾸지 않은 평소 사용(스크롤, 채팅 입력)에서 텍스트 레이아웃이 달라지지 않는다

🤖 Generated with Claude Code

Bruno Ramos and others added 2 commits December 2, 2026 16:01
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>
@coderabbitai

coderabbitai Bot commented Dec 2, 2026

Copy link
Copy Markdown

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

@kdwkr
kdwkr marked this pull request as ready for review December 2, 2026 07:21
@kdwkr
kdwkr merged commit c247e4a into scatterlab/0.88.1 Dec 2, 2026
4 checks passed
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