Commit 585b28c
fix(android): skip null gradient color stop positions instead of warning (#58636)
Summary:
`processBackgroundImage` emits `position: null` for every color stop that has no explicit position, which is the common case (`linear-gradient(red, blue)`). On Android, `LinearGradient` and `RadialGradient` pass that value straight to `LengthPercentage.setFromDynamic`, which logs
```
W ReactNative: Unsupported type for radius property: Null
```
once per such stop on every props update. A static view logs it on each render; an animated `backgroundImage` (e.g. Reanimated CSS animations) floods logcat at frame rate. The value itself is handled correctly (`null` position → evenly spaced), so this is purely log noise, but it drowns out real warnings.
`BackgroundPosition` already guards against `ReadableType.Null` before calling `setFromDynamic`; this change does the same for gradient color stops in both gradient parsers.
## Changelog:
[ANDROID] [FIXED] - Stop logging "Unsupported type for radius property: Null" for gradient color stops without an explicit position
Pull Request resolved: #58636
Test Plan:
Built React Native from source (`includeBuild('../node_modules/react-native')`) in an app that animates `backgroundImage` on Android (Pixel 9 Pro emulator, API 37) and counted the warning in `adb logcat` over an identical ~90 s run:
- before: 1386 occurrences of `Unsupported type for radius property: Null`
- after: 0 occurrences
Gradients with and without stop positions render the same as before. `yarn format-check-kotlin` (ktfmt) passes on the changed files.
Reviewed By: Abbondanzo
Differential Revision: D121621185
Pulled By: javache
fbshipit-source-id: 7baeea9e373dd03db9b911c6a57d9cb90e33a8661 parent ab37398 commit 585b28c
2 files changed
Lines changed: 10 additions & 2 deletions
File tree
- packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/style
Lines changed: 5 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
72 | 72 | | |
73 | 73 | | |
74 | 74 | | |
75 | | - | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
76 | 80 | | |
77 | 81 | | |
78 | 82 | | |
| |||
Lines changed: 5 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
128 | 128 | | |
129 | 129 | | |
130 | 130 | | |
131 | | - | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
132 | 136 | | |
133 | 137 | | |
134 | 138 | | |
| |||
0 commit comments