Skip to content

Check Android mount coordinates for overflow without fenv calls - #60566

Open
ide wants to merge 1 commit into
react:mainfrom
expo:@ide/android-mount-scale-overflow
Open

ide wants to merge 1 commit into
react:mainfrom
expo:@ide/android-mount-scale-overflow

Conversation

@ide

@ide ide commented Dec 4, 2026

Copy link
Copy Markdown
Contributor

Summary:

FabricMountingManager converts each layout coordinate of a mount item to pixels with scale, which cleared the floating-point status flags before the multiplication and tested them twice after it to log an overflow or an underflow. Each of those is a libm call that reads or writes the Arm floating-point status register (FPSR). scale now tests the product: an infinite result from a finite coordinate is an overflow. A product that underflows is below FLT_MIN and rounds to zero pixels, so scale no longer logs it.

Changelog:

[INTERNAL] [CHANGED] - Check Android mount coordinates for overflow without fenv calls.

Test Plan:

ReactAndroid builds, and RNTester's Release build mounts its screens on an arm64 Android 16 emulator. On that emulator, a benchmark that scales 65,536 coordinates with both versions measured a median of 21.6 to 33.4 ns per call before and 0.4 to 0.9 ns after, over three runs. The rounded pixel values match, and both versions log an overflow for 3e38 * 2.625.

@github-actions github-actions Bot added the Meta Review Required This PR is considered risky and requires Meta to import it to do more testing before merging. label Dec 4, 2026
@ide
ide marked this pull request as ready for review December 4, 2026 20:56
`FabricMountingManager` converts each layout coordinate of a mount item to pixels with `scale`, which cleared the floating-point status flags before the multiplication and tested them twice after it to log an overflow or an underflow. Each of those is a libm call that reads or writes the Arm floating-point status register (FPSR). `scale` now tests the product: an infinite result from a finite coordinate is an overflow. A product that underflows is below `FLT_MIN` and rounds to zero pixels, so `scale` no longer logs it.

ReactAndroid builds, and RNTester's Release build mounts its screens on an arm64 Android 16 emulator. On that emulator, a benchmark that scales 65,536 coordinates with both versions measured a median of 21.6 to 33.4 ns per call before and 0.4 to 0.9 ns after, over three runs. The rounded pixel values match, and both versions log an overflow for `3e38 * 2.625`.

Signed-off-by: James Ide <ide@expo.dev>
@ide
ide force-pushed the @ide/android-mount-scale-overflow branch from 8cb381f to d5ab271 Compare December 5, 2026 01:18
@github-actions

github-actions Bot commented Dec 5, 2026

Copy link
Copy Markdown

Visual regression

No visual differences at d5ab2714ea78.

ios: no capture

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

Meta Review Required This PR is considered risky and requires Meta to import it to do more testing before merging.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant