Skip to content

Fix Android display metrics refresh on density changes#57295

Open
nikhilpakhloo wants to merge 1 commit into
react:mainfrom
nikhilpakhloo:fix/android-display-metrics-density
Open

Fix Android display metrics refresh on density changes#57295
nikhilpakhloo wants to merge 1 commit into
react:mainfrom
nikhilpakhloo:fix/android-display-metrics-density

Conversation

@nikhilpakhloo

@nikhilpakhloo nikhilpakhloo commented Jun 20, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes Android display metrics getting stale when a React Native surface moves to a display/window with a different density, such as Samsung DeX, freeform windows, external monitors, or ChromeOS.

DisplayMetricsHolder was initialized once and could keep using the main display density, while Fabric/root layout could use the current display density. This caused text sp -> px conversion to use the wrong scale, making text render too large and clip.

Changes

  • Refresh DisplayMetricsHolder when Android configuration/display metrics change.
  • Request relayout and emit Dimensions updates when display metrics change.
  • Keep Fabric pixel density in sync with refreshed display metrics.
  • Initialize root-view display metrics from the visual/root context instead of application context.
  • Add tests for display metrics change detection.

Changelog:

[ANDROID] [FIXED] - Keep display metrics in sync when Android display density changes

Test Plan

  • Ran ktfmtFormat.
  • Ran git diff --check.
  • Attempted targeted Android unit test, but local Windows codegen setup failed before tests ran due to buildCodegenCLI / tar path handling.

@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 Jun 20, 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 Jun 20, 2026
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