rive-app / rive-app/rive-android

RiveAnimationView.Builder ignores playback if autoplay is set to false

Open
#345 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Kotlin
Stars
538
Forks
66
PR merge metrics
No merged PRs in 30d

Description

<-- Thanks for using Rive!

If something isn't working like you expected, please:

If you think you found a bug or if you can't find what you're looking for
in our docs, fill out the template below.

-->

Description

<-- A clear and concise description of what the problem is. -->

I may have found a bug. The RiveAnimationVew.Builder is ignoring playback when autoplay is set to false. However, when creating a RiveAnimationView object and setting rive resource with said object and same parameters as builder it works.

Provide a Repro

<--
Please provide the most minimal repro you can:

  • If the problem is small enough, paste a code snippet
  • Otherwise, you can attach a ZIP archive or paste a link to a GitHub repository with the app bundle
    that is reproducing the issue
// Composable wrapper around view
AndroidView(
            modifier = Modifier.align(Alignment.Center),
            factory = { context ->
                RiveAnimationView(context).apply {
                    setRiveResource(
                        resId = if (isDarkMode) R.raw.promo_bell_dark else R.raw.promo_bell_light,
                        animationName = BELL_ANIMATION_NAME,
                        autoplay = false
                    )
                }
                // The builder below won't play while the code above does play.
                /*RiveAnimationView.Builder(context)
                    .setResource(
                        if (isDarkMode) R.raw.promo_bell_dark else R.raw.promo_bell_light
                    )
                    .setAutoplay(false)
                    .setAnimationName(BELL_ANIMATION_NAME)
                    .build()*/
            },
            update = { view ->
                if (triggerAnimation) {
                    view.play(
                        animationName = BELL_ANIMATION_NAME,
                        loop = Loop.ONESHOT,
                    )
                    Log.d("ASDF", "Play animation ${view.controller.isActive}")
                } else {
                    Log.d("ASDF", "No op")
                }
            }
        )

-->

Source .riv/.rev file

<--
Attaching runtime-exported .riv file that reproduces the issue is immensely helpful for our team
to identify the problem as fast as possible and fix it.
Please also include the source (.rev)
by downloading a backup from the Editor.

N.B. Because GitHub only supports certain file types use a ZIP archive to upload .riv/.rev files
to this issue.

You can also privately share the .riv/.rev file with us at hello@rive.app.
-->

Expected behavior

<-- A clear and concise description of what you expected to happen. -->

The RiveAnimationView.Builder should work the same as creating a RiveAnimationView object from scratch. What's the point of having a builder if it behaves differently than the object it was meant to create?

Screenshots

<-- If applicable, add screenshots to help explain your problem. -->

Screenshot

Device & Versions (please complete the following information)
  • Device: [e.g. Android Emulator, Pixel 4a]
  • SDK Level [e.g. Android SDK API Level 30]

-Device: Samsung Galaxy S10
-SDK Level: 12

Additional context

<-- Add any other context about the problem here. -->
Rive animation file.zip

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by inspecting RiveAnimationView.Builder and compare it with the direct setRiveResource path shown in the AndroidView repro. Reproduce the issue with autoplay set to false and verify that the builder honors the setting and behaves like a directly created RiveAnimationView.

Written by the indexing model from the issue text.

Assessment

Tech stack
android, kotlin
Domain
mobile-dev
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.