fix(android): Image defaultSource & loadingIndicatorSrc broken with props 2.0
#55210
+63
−34
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary:
Fixes crashes using
component on android with props 2.0 enabled using feature flag:
Crash stack
On android we pass the
defaultSourceandloadingIndicatorSrcas strings. however, when enabling prop diffing this causes crashes, as the prop diff mechanism is parsing them toImageSourceas defined inImageProps.h.W/o props 2.0 diffing we simply return the props as we receive them from JS (with those sources as string):
react-native/packages/react-native/ReactAndroid/src/main/jni/react/fabric/FabricMountingManager.cpp
Line 341 in c12806c
With props diffing …
react-native/packages/react-native/ReactAndroid/src/main/jni/react/fabric/FabricMountingManager.cpp
Line 309 in c12806c
… We actually transform them to the c++ object:
react-native/packages/react-native/ReactCommon/react/renderer/components/image/ImageProps.cpp
Lines 210 to 215 in c12806c
react-native/packages/react-native/ReactCommon/react/renderer/components/image/ImageProps.h
Lines 29 to 30 in c12806c
react-native/packages/react-native/ReactCommon/react/renderer/imagemanager/primitives.h
Lines 47 to 74 in c12806c
This throws errors and crashes the app:
Screen.Recording.2026-01-19.at.19.42.05.mov
I think the proper solution here is to pass the full objects down, with or without props 2.0 diffing and handle the objects in native code correctly. This way android aligns with the iOS implementation too.
Changelog:
[ANDROID] [FIXED] - fixed
defaultSourceandloadingIndicatorSrccausing a crash whenenablePropsUpdateReconciliationAndroidis enabled[ANDROID] [BREAKING] - Changed
ReactImageView#setDefaultSource(String?)toReactImageView#setDefaultSource(ReadableMap?)[ANDROID] [BREAKING] - Changed
ReactImageView#setLoadingIndicatorSource(String?)toReactImageView#setLoadingIndicatorSource(ReadableMap?)Test Plan:
Recordings:
debug.mov
release.mov
Note: this uses the example setup from this PR in the recordings: