Skip to content

RiveException: Accessing disposed C++ object Artboard. #359

Open

Description

@thorbenprimke

<-- Thanks for using Rive!

If something isn't working like you expected, please:
The library's code is causing a crash.

-->

Description

It looks like during a cleanup in the Rive code, a native exception is triggered.

Also this exception has the entire stacktrace in the message rather than the stacktrace itself. This caused Instabug to not display a stacktrace.

java.lang.Throwable: 
app.rive.runtime.kotlin.core.errors.RiveException: Accessing disposed C++ object Artboard. 
    Dispose_Trace.Start(Unknown Source)
    app.rive.runtime.kotlin.core.NativeObject.dispose(Unknown Source:14)
    app.rive.runtime.kotlin.core.NativeObject.release(Unknown Source:15)
    app.rive.runtime.kotlin.core.NativeObject.dispose(Unknown Source:41)
    app.rive.runtime.kotlin.core.NativeObject.release(Unknown Source:15)
    app.rive.runtime.kotlin.core.File.release(Unknown Source:3)
    app.rive.runtime.kotlin.controllers.RiveFileController.setFile(Unknown Source:28)
    app.rive.runtime.kotlin.RiveAnimationView.setRiveResource$lambda$11(Unknown Source:2)
    app.rive.runtime.kotlin.RiveAnimationView.g(Unknown Source:0)
    c4.a.invoke(Unknown Source:19)
    app.rive.runtime.kotlin.RiveAnimationView.loadFileFromResource(Unknown Source:152)
    app.rive.runtime.kotlin.RiveAnimationView.setRiveResource(Unknown Source:42)
    app.rive.runtime.kotlin.RiveAnimationView.setRiveResource$default(Unknown Source:96)
    p0.i.invoke(Unknown Source:2612)
    x3.k1.b(Unknown Source:79)
    mn.L0.c(Unknown Source:197)
    mn.K0.invokeSuspend(Unknown Source:12)
    Tl.a.resumeWith(Unknown Source:5)
    jn.J.run(Unknown Source:121)
    jn.W.F0(Unknown Source:23)
    jn.h.p(Unknown Source:78)
    jn.h.C(Unknown Source:32)
    jn.h.resumeWith(Unknown Source:16)
    mn.L0.n(Unknown Source:103)
    mn.L0.l(Unknown Source:8)
    Hf.k.d(Unknown Source:13)
    Hf.k.n(Unknown Source:31)
    vh.Q0.g(Unknown Source:73)
    vh.A.invoke(Unknown Source:142)
    Lf.x.C(Unknown Source:14)
    Lf.f.i(Unknown Source:104)
    Nf.f.i(Unknown Source:11)
    com.pinterest.shuffles.composer.ui.util.multitouch.l.onTouch(Unknown Source:512)
    android.view.View.dispatchTouchEvent(View.java:15072)
    android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:3923)
    android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:3597)
    com.pinterest.shuffles.composer.ui.widget.SceneViewContainer.dispatchTouchEvent(Unknown Source:43)
    android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:3923)
    android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:3597)
    android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:3923)
    android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:3597)
    android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:3923)
    android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:3597)
    android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:3923)
    android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:3597)
    android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:3923)
    android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:3597)
    android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:3923)
    android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:3597)
    android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:3923)
    android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:3597)
    android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:3923)
    android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:3597)
    android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:3923)
    android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:3597)
    android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:3923)
    android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:3597)
    com.android.internal.policy.DecorView.superDispatchTouchEvent(DecorView.java:1016)
    com.android.internal.policy.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1962)
    android.app.Activity.dispatchTouchEvent(Activity.java:4265)
    i.C.dispatchTouchEvent(Unknown Source:2)
    de.v.dispatchTouchEvent(Unknown Source:4)
    com.android.internal.policy.DecorView.dispatchTouchEvent(DecorView.java:974)
    android.view.View.dispatchPointerEvent(View.java:15335)
    android.view.ViewRootImpl$ViewPostImeInputStage.processPointerEvent(ViewRootImpl.java:7820)
    android.view.ViewRootImpl$ViewPostImeInputStage.onProcess(ViewRootImpl.java:7593)
    android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:6927)
    android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:6984)
    android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:6950)
    android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:7148)
    android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:6958)
    android.view.ViewRootImpl$AsyncInputStage.apply(ViewRootImpl.java:7205)
    android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:6931)
    android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:6984)
    android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:6950)
    android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:6958)
    android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:6931)
    android.view.ViewRootImpl.deliverInputEvent(ViewRootImpl.java:10422)
    android.view.ViewRootImpl.doProcessInputEvents(ViewRootImpl.java:10270)
    android.view.ViewRootImpl.enqueueInputEvent(ViewRootImpl.java:10226)
    android.view.ViewRootImpl$WindowInputEventReceiver.onInputEvent(ViewRootImpl.java:10554)
    android.view.InputEventReceiver.dispatchInputEvent(InputEventReceiver.java:259)
    android.os.MessageQueue.nativePollOnce(Native Method)
    android.os.MessageQueue.next(MessageQueue.java:335)
    android.os.Looper.loopOnce(Looper.java:186)
    android.os.Looper.loop(Looper.java:313)
    android.app.ActivityThread.main(ActivityThread.java:8751)
    java.lang.reflect.Method.invoke(Native Method)
    com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:571)
    com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1135)
    Current_Trace.Start(Unknown Source)
    app.rive.runtime.kotlin.core.NativeObject.getCppPointer(Unknown Source:30)
    app.rive.runtime.kotlin.core.Artboard.draw(SourceFile:3)
    app.rive.runtime.kotlin.renderers.RiveArtboardRenderer.draw(Unknown Source:55) 

Provide a Repro

I don't have a repro but this happens in production and has been happening.

Image

Expected behavior

Not trigger a crash

Device & Versions (please complete the following information)

  • Device: Many devices
  • SDK Level: Many OS versions

If you need anything else, let me know and I'll try to get it. This crash existed with 9.x versions and is now in 10.0.1 as well.

Activity

  1. amberkira commented on Apr 7, 2025

    @amberkira

    I have the same problem in my production when using it in recyclerView. is there any workaround?

  2. BinarySatan commented on Jul 16, 2025

    @BinarySatan

    I have the same problem

  3. umberto-sonnino commented on Jul 16, 2025

    @umberto-sonnino
    Contributor

    Hi @thorbenprimke, @amberkira, and @BinarySatan

    Thanks for the report and your patience!

    This looks very much like a race condition we fixed in in https://github.com/rive-app/rive-android/releases/tag/10.0.5. The stack trace points to the crash occurring during a resource swap, which matches the scenario we addressed. Could you update to the latest version of the runtime and see if this is still occurrning?

    On the other hand, if you're already on the latest, to help us nail this down, could you provide a few more details about how you're using RiveAnimationView when this crash occurs?

    • How are you loading/updating the Rive file? The stack trace strongly suggests the crash happens during a resource swap. Are you frequently calling setRiveResource() or programmatically changing the Rive file/artboard on the view?
    • What is the user flow that leads to this? For example, is the user quickly navigating between different screens where a RiveAnimationView is created and destroyed? Or perhaps tapping a button that reloads the animation content?
    • Could you share a code snippet? A self-contained reproduction case would be the most helpful, but even just the relevant code snippets of how you are setting up and managing your RiveAnimationView in your Activity/Fragment/Composable would be really helpful!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions