mirror of
https://github.com/facebook/react-native.git
synced 2026-11-18 20:19:07 +00:00
Fix NPE in ReactProgressBarViewManager.measure() with nullable params (#57035)
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/57035 Match `ViewManager.measure()`'s Java signature (which has always accepted nullable `localData`/`props`/`state`) and the sibling `ReactSwitchManager.kt` pattern. The Kotlin migration in D49551193 (2024-07) wrongly tightened the override on `ReactProgressBarViewManager` to non-null `ReadableMap`, which threw NPE on entry whenever the C++ side passed `nullptr` for `localData` or `state` — which `AndroidProgressBarMeasurementsManager::measure` has always done. The latent bug was masked by Yoga's measure cache plus the now-removed `AndroidProgressBarMeasurementsManager` measurement cache (removed in D60192289, 2025-06). D105720159's CSS Flexbox §4.5 auto-min-size probe reliably bypasses Yoga's cache by calling `node->measure(... AtMost 0 ...)` per flex item, exposing the NPE and crashing Airwave on Android (T273821098, P2359486686). Fix: change `localData`/`props`/`state` to nullable `ReadableMap?` and use safe call on `props?.getString(...)`. This unblocks D105720159 from being re-landed. Changelog: [Android][Fixed] - Fix NullPointerException in `ReactProgressBarViewManager.measure()` when invoked with null `localData` or `state` (for example, from the upcoming CSS Flexbox §4.5 auto-min-size probe in Yoga). Reviewed By: javache Differential Revision: D107178838 fbshipit-source-id: a3db84aaf3178e97151d9446813d9cd6d70ec024
This commit is contained in:
1 parent
1a4a1393d5
commit
ef683f7010
1 file changed
+4
-4
+4
-4
@@ -100,16 +100,16 @@ internal class ReactProgressBarViewManager :
|
||||
|
||||
override fun measure(
|
||||
context: Context,
|
||||
localData: ReadableMap,
|
||||
props: ReadableMap,
|
||||
state: ReadableMap,
|
||||
localData: ReadableMap?,
|
||||
props: ReadableMap?,
|
||||
state: ReadableMap?,
|
||||
width: Float,
|
||||
widthMode: YogaMeasureMode,
|
||||
height: Float,
|
||||
heightMode: YogaMeasureMode,
|
||||
attachmentsPositions: FloatArray?,
|
||||
): Long {
|
||||
val style = getStyleFromString(props.getString(PROP_STYLE))
|
||||
val style = getStyleFromString(props?.getString(PROP_STYLE))
|
||||
val value =
|
||||
measuredStyles.getOrPut(style) {
|
||||
val progressBar = createProgressBar(context, style)
|
||||
|
||||
Reference in new issue
Block a user