rive-react-native icon indicating copy to clipboard operation
rive-react-native copied to clipboard

BlendState is coming in as UnknownState on iOS

Open WooMinGy opened this issue 2 years ago • 2 comments

react : 18.2.0 react-native : 0.72.4 rive-react-native : 6.1.1

image

My Rive layers are set up as described above. On Android, when I look at the stateName with console.log in onStateChanged, I see BlendState comes in fine, but on iOS, BlendState is coming in as UnknownState. Is this a known issue? All my Rive files that contain state are coming in with BlendState as UnknownState

image

image

WooMinGy avatar Nov 07 '23 01:11 WooMinGy

Thanks for bringing this up! Looks like a bug in the underlying rive-ios runtime. This would probably be a breaking change there; until the underlying iOS runtime is updated to change this to BlendState, I might recommend two options in the meantime, with preference for the second:

  1. Keep a temporary check for UnkownState for now like in your screenshot and handle it like you would if it came in as BlendState.
  2. Are you familiar with Rive Events? It's a new feature introduced in the past few months whereby you can report a homemade "Rive Event" (created in the Rive File) with whatever metadata you need (string, numerical, boolean data). The Event can be reported in different ways, such as on a state transition, as a key in a timeline animation, or at the start/end of a state animation playing. I think the first way on state transition might make the most sense here, where the Rive Event reports on the transition to the blend state. More on that here: https://help.rive.app/editor/events and https://help.rive.app/runtimes/rive-events. This may be a cleaner solution for you than checking state names in onStateChange.

zplata avatar Nov 20 '23 15:11 zplata

@zplata Thank you for recommending the approach using Rive Events. For now, I have implemented the first method as a temporary solution, but I plan to consider the second method when updating the Rive-related code in my app next time. Thank you :)

WooMinGy avatar Dec 04 '23 07:12 WooMinGy