From 30fd0c4ac82edb8716c8b05239ae55909bc83b12 Mon Sep 17 00:00:00 2001 From: Zeya Peng Date: Fri, 16 Jan 2026 09:26:28 -0800 Subject: [PATCH] Log error when unsupported type is passed to interpolation outputRange (#55209) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/55209 ## Changelog: [Android] [Changed] - Log error when unsupported type is passed to interpolation outputRange Add error logging when unsupported value types (like PlatformColor) are passed to interpolation outputRange. This prevents a ClassCastException crash by detecting non-Number types and logging an error instead. Reviewed By: javache Differential Revision: D90863942 fbshipit-source-id: d6a3b2dbde859ae86a1bc4a5dfcc33a9ee369dd1 --- .../react/animated/InterpolationAnimatedNode.kt | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/animated/InterpolationAnimatedNode.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/animated/InterpolationAnimatedNode.kt index be57f0d95d8..236bf26239e 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/animated/InterpolationAnimatedNode.kt +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/animated/InterpolationAnimatedNode.kt @@ -8,6 +8,7 @@ package com.facebook.react.animated import androidx.core.graphics.ColorUtils +import com.facebook.common.logging.FLog import com.facebook.react.bridge.JSApplicationIllegalArgumentException import com.facebook.react.bridge.ReadableArray import com.facebook.react.bridge.ReadableMap @@ -44,6 +45,15 @@ internal class InterpolationAnimatedNode(config: ReadableMap) : ValueAnimatedNod outputType = OutputType.String outputRange = fromStringPattern(output) pattern = output.getString(0) + } else if (output != null && output.size() > 0 && output.getType(0) != ReadableType.Number) { + FLog.e( + TAG, + "Unsupported value type in interpolation outputRange: expected Number but got " + + "${output.getType(0)}. This may indicate PlatformColor or other unsupported " + + "values are being used. Interpolation will not work correctly.", + ) + outputType = OutputType.Number + outputRange = DoubleArray(output.size()) } else { outputType = OutputType.Number outputRange = fromDoubleArray(output) @@ -101,6 +111,8 @@ internal class InterpolationAnimatedNode(config: ReadableMap) : ValueAnimatedNod "InterpolationAnimatedNode[$tag] super: ${super.prettyPrint()}" companion object { + private const val TAG = "InterpolationAnimatedNode" + const val EXTRAPOLATE_TYPE_IDENTITY: String = "identity" const val EXTRAPOLATE_TYPE_CLAMP: String = "clamp" const val EXTRAPOLATE_TYPE_EXTEND: String = "extend"