Skip to content

Commit 73e0acc

Browse files
authored
Fix synchronous props for PlatformColor on Android (#8687)
## Summary This PR fixes the following error on Android that happens when trying to animate color (e.g. `backgroundColor`) using synchronous props mechanism (with `ANDROID_SYNCHRONOUSLY_UPDATE_UI_PROPS` Reanimated static feature flag enabled) and passing an instance of `PlatformColor` which is an object, not an integer: <img width="441" height="785" alt="Screenshot 2025-12-02 at 12 13 54" src="https://github.com/user-attachments/assets/9c3cb97b-705d-4456-999c-f701b40ad32f" /> ## Test plan
1 parent e03713e commit 73e0acc

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

docs/docs-reanimated/docs/guides/feature-flags.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ When enabled, non-layout styles will be applied using the `synchronouslyUpdateVi
132132

133133
2. The changes are applied via `synchronouslyUpdateViewOnUIThread` are not synchronized with changes applied by `ShadowTree::commit` which may lead to minor inconsistencies of animated styles or animated components in a single animation frame.
134134

135-
Currently, only the following styles can be updated using the fast path: `opacity`, `elevation`, `zIndex`, `backgroundColor`, `tintColor`, `borderRadius` (all sides), `borderColor` (all sides) and `transform` (all transforms). All remaining styles, if present, will be updated via `ShadowTree::commit`.
135+
Currently, only the following styles can be updated using the fast path: `opacity`, `elevation`, `zIndex`, `backgroundColor` (excluding `PlatformColor`), `tintColor` (excluding `PlatformColor`), `borderColor` (all sides, excluding `PlatformColor`), `borderRadius` (all sides) and `transform` (all transforms). All remaining styles, if present, will be updated via `ShadowTree::commit`.
136136

137137
This feature flag works only on Android and has no effect on iOS. For more details, see [PR #7823](https://github.com/software-mansion/react-native-reanimated/pull/7823).
138138

packages/react-native-reanimated/Common/cpp/reanimated/NativeModules/ReanimatedModuleProxy.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -812,9 +812,10 @@ void ReanimatedModuleProxy::performOperations(const bool isTriggeredByEvent) {
812812

813813
for (const auto &[shadowNode, props] : updatesBatch) {
814814
bool hasOnlySynchronousProps = true;
815-
for (const auto &key : props.keys()) {
815+
for (const auto &[key, value] : props.items()) {
816816
const auto keyStr = key.asString();
817-
if (!synchronousProps.contains(keyStr)) {
817+
if (!synchronousProps.contains(keyStr) ||
818+
((keyStr == "color" || keyStr.find("Color") != std::string::npos) && !value.isInt())) {
818819
hasOnlySynchronousProps = false;
819820
break;
820821
}

0 commit comments

Comments
 (0)