Skip to content

chore(rn-tester): add Playground reproducer for Android Fabric shared TextPaint typeface leak - #58783

Open
pangziqiang wants to merge 1 commit into
react:mainfrom
pangziqiang:repro/android-fabric-shared-textpaint-typeface
Open

pangziqiang wants to merge 1 commit into
react:mainfrom
pangziqiang:repro/android-fabric-shared-textpaint-typeface

Conversation

@pangziqiang

@pangziqiang pangziqiang commented Oct 1, 2026 •

Copy link
Copy Markdown

Summary

Adds an RNTester Playground reproducer for #57950.

On Android with the new architecture, Fabric measures every <Text> with one shared, thread-local
TextPaint. For text without an explicit font family/weight/style, TextLayoutManager.updateTextPaint()
restores the default with paint.reset(); paint.setTypeface(null). On some OEM ROMs that does not
restore the typeface — Paint.reset() keeps the resolved font and the following
Paint.setTypeface(null) is a no-op — so the paint keeps the last typeface that was set explicitly,
and every following plain <Text> is measured with it while ReactTextView renders with the real
system font. Line boxes come out ~24% too short and descenders / trailing glyphs are clipped.

Changelog:

[Internal] - Add an RNTester Playground reproducer for the Android Fabric shared TextPaint typeface leak (#57950)

How the reproducer works

No bundled font asset is needed: any explicit font family poisons the shared paint. The screen uses
the framework alias casual (Dancing Script, present since API 21) because its vertical metrics are
far from the default font's on every Android version, so the rows are trivially distinguishable:

  • R1: <Text style={{fontSize: 48, fontFamily: 'casual'}}>
  • R2/R3: plain <Text style={{fontSize: 48}}> — different strings from R1

R2/R3 must use different strings: RN caches text layouts per attributed string, and an identical
string silently reuses R1's layout (our first attempt had exactly this false negative).

Verdict: R2/R3 == R1 → leaked (reproduced); R2/R3 == default-font metrics → not affected.

Test Plan

Open the Playground example in RNTester and compare the metrics printed under the three rows.
onTextLayout metrics at fontSize 48, in px (ascender / descender / height):

device / ROM build R1 (casual) R2 (plain) R3 (plain) result
Xiaomi 17 Max, HyperOS 0.78.3 unpatched 49.7/23.7/73.3 49.7/23.7/73.3 49.7/23.7/73.3 reproduced
Xiaomi 17 Max, HyperOS with #58036 backported 49.7/23.7/73.3 50.3/13.7/64.0 50.3/13.7/64.0 fixed
Xiaomi Pad 4 Plus, stock AOSP 16 0.78.3 unpatched 49.5/23.5/73.0 45.0/14.0/59.0 45.0/14.0/59.0 not affected

Fix: #58036.

@meta-cla

meta-cla Bot commented Oct 1, 2026

Copy link
Copy Markdown

Hi @pangziqiang!

Thank you for your pull request and welcome to our community.

Action Required

In order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you.

Process

In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks!

@pangziqiang

pangziqiang commented Oct 1, 2026 via email

Copy link
Copy Markdown
Author

@meta-cla

meta-cla Bot commented Oct 1, 2026

Copy link
Copy Markdown

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks!

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Oct 1, 2026
@facebook-github-tools facebook-github-tools Bot added the Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team. label Oct 1, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant