Repository navigation
Commit a613baf
Leave a view untransformed on iOS when its transform is not finite (#59133)
Summary:
A view whose transform holds a `NaN` disappears on iOS, together with the siblings drawn before it. On Android the same view renders untransformed and its siblings are unaffected. I hit it through Reanimated, whose `withTiming` computes a `NaN` for an `undefined` duration, but any transform computed as `NaN` does it.
`RCTCATransform3DFromTransformMatrix` copies the resolved matrix into a `CATransform3D` unchecked, so the `NaN` reaches Core Animation. Android's `BaseViewManager` reads each transform value through `sanitizeFloatPropertyValue` first, and on iOS `updateLayoutMetrics` already skips a non-finite frame because a `CALayer` cannot take one.
`RCTCATransform3DFromTransformMatrix` now returns the identity for a matrix with a non-finite entry, so `RCTViewComponentView` and the synchronous update in `RCTMountingManager` render the view untransformed, as Android does.
## Changelog:
[IOS] [FIXED] - Render a view untransformed when its transform is not finite, instead of hiding it and the siblings drawn before it
Pull Request resolved: #59133
Test Plan:
- `RCTViewComponentViewTests` gains three cases that set a transform through `updateProps`: a translate with `NaN` and a scale with infinity leave the layer's transform at the identity, and a finite translate is applied. I ran `React-RCTFabric`'s test spec on an iPad (iOS 27.0.1), with the spec enabled in RNTester's Podfile locally: all 22 `RCTViewComponentViewTests` pass with this change, and with `main`'s `RCTConversions.h` the `NaN` and infinity cases fail. The spec's one other failure, `RCTTextInputUtilsTest testCopyBackedTextInputPreservesTintColor`, fails the same way on `main` on that device.
- RNTester release builds of `main` and of this change on the same iPad, with a root component that renders a build label, a button, a view whose `translateX` becomes `NaN` after mount, and a second view. On `main` only the second view is drawn: the label, the button and the `NaN` view are gone. With this change all four are drawn and the `NaN` view sits untransformed. The before and after are in a comment below.
- clang-format 21.1.2 passes on both files.
Reviewed By: cipolleschi
Differential Revision: D126289250
Pulled By: vzaidman
fbshipit-source-id: d94e1aa110ab2d03ab66923dc435c5ef990df5571 parent fcd141c commit a613baf
2 files changed
Lines changed: 41 additions & 0 deletions
File tree
- packages/react-native/React
- Fabric
- Tests/Mounting
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| 8 | + | |
| 9 | + | |
8 | 10 | | |
9 | 11 | | |
10 | 12 | | |
| |||
152 | 154 | | |
153 | 155 | | |
154 | 156 | | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
155 | 163 | | |
156 | 164 | | |
157 | 165 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
204 | 204 | | |
205 | 205 | | |
206 | 206 | | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
207 | 240 | | |
208 | 241 | | |
209 | 242 | | |
| |||
0 commit comments