Application crashes (EXC_CRASH (SIGABRT)) when displaying an animation with state machine in SwiftUI
Application crashes (EXC_CRASH (SIGABRT)) when displaying an animation with state machine in SwiftUI.
Some of our users have reported an immediate application crash when a Rive animation is displayed. Analysis of crash reports seem to indicate that this is caused by a call from the RiveRuntime framework, causing a NSInvalidArgumentException
, see snippet below: (Full crash reports are available if needed)
"exception" : {"codes":"0x0000000000000000, 0x0000000000000000","rawCodes":[0,0],"type":"EXC_CRASH","signal":"SIGABRT"}, "termination" : {"flags":0,"code":6,"namespace":"SIGNAL","indicator":"Abort trap: 6","byProc":"Application","byPid":1045}, "asi" : {"libsystem_c.dylib":["abort() called"]}, "exceptionReason" : {"arguments":["-[__NSArrayM insertObject:atIndex:]"],"format_string":"*** %s: object cannot be nil","name":"NSInvalidArgumentException","type":"objc-exception","composed_message":"*** -[__NSArrayM insertObject:atIndex:]: object cannot be nil","class":"NSException"}, "extMods" : {"caller":{"thread_create":0,"thread_set_state":0,"task_for_pid":0},"system":{"thread_create":0,"thread_set_state":0,"task_for_pid":0},"targeted":{"thread_create":0,"thread_set_state":0,"task_for_pid":0},"warnings":0}, "lastExceptionBacktrace" : [ {"imageOffset":978358,"symbol":"__exceptionPreprocess","symbolLocation":226,"imageIndex":9}, {"imageOffset":81565,"symbol":"objc_exception_throw","symbolLocation":48,"imageIndex":7}, {"imageOffset":123841,"symbol":"-[__NSArrayM insertObject:atIndex:]","symbolLocation":1762,"imageIndex":9}, {"imageOffset":35776,"symbol":"-[RiveStateMachineInstance stateChanges]","symbolLocation":178,"imageIndex":1},
We're new to Rive so we might be doing something wrong, still the issue doesn't happen on our development machines.
Below you can see a stripped down version of our code:
struct ContentView: View { @EnvironmentObject var appState: AppState let property1 = false let min = 1.0 let max = 3.0 @State private var property2 = 1.0 @State var timer = Timer.publish(every: 60, tolerance: 1, on: .main, in: .common).autoconnect() @StateObject var riveViewModel = RiveViewModel( fileName: "animation", stateMachineName: "Default State Machine" ) var body: some View { VStack { if appState.showAnimation { riveViewModel.view() .backgroundStyle(.clear) } } .onAppear(perform: { riveViewModel.setInput("Property1", value: property1) riveViewModel.setInput("Property2", value: property2) riveViewModel.setInput("Property3", value: false) }) .onHover { hover in if (hover) { riveViewModel.setInput("Property3", value: true) property2 = min } else { riveViewModel.setInput("Property3", value: false) } } .onReceive(timer) { value in if property2 < max { property2 += 1 } } .onChange(of: property2) { riveViewModel.setInput("Property2", value: property2) } } }
Devices: Mac14,2, Mac15,6, MacBookPro18,3, MacBookPro15,2
OS Version: macOS 14.5 (23F79)
RiveRuntime: 5.13.2
Unfortunately, we cannot reproduce this issue ourselves, which makes it hard to troubleshoot. However, several users have experienced this unexpected behavior. We are open to test/validate any suggestions with our testers.
FYI we also posted this issue in the GitHub repo: https://github.com/rive-app/rive-ios/issues/330
HI
Thanks David, I've just created a ticket (RIV-4794) and uploaded a test project we created. We haven't been able to reproduce, but again are open to any ideas.
Amazing tool by the way, really enjoy working with it so far.
We've tried the latest version but it doesn't seem to fix the issue.
My colleagues tells me it seems to happen in this piece of code (line 347) within Rive SDK. Perhaps in some way the state name is nil
?
Yes, we're on 5.14.3, I think they're the same, will check to be sure.