R
20d ago

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

6 replies
D
R
20d ago

HI ! Thanks for the report! Shared this with our devs, hopefully this will be resolved soon. Cheers!

D
20d ago

If you can provide a simplified (and public) version of your animation that also causes a similar crash, feel free to post that here. I do want to acknowledge that you're having a hard time reproducing this in development, though! Otherwise, if you feel it might be best to look at the production file(s), you can use our portal to privately submit your file(s).

R
19d ago

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.

R
16d ago

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?

D
(edited) 15d ago

Just to confirm, you're using the latest v5.14.3? Do any latest crash reports showcase a similar stack trace?

R
15d ago

Yes, we're on 5.14.3, I think they're the same, will check to be sure.