rive-app / rive-app/rive-ios

Syncronously render the first animation frame for snapshot tests

Open
#263 5 comments 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Swift
Stars
822
Forks
104
PR merge metrics
No merged PRs in 30d

Description

Description

Rive animations don’t render their content for snapshot tests, for example when using Pointfreeco snapshot-testing.

Provide a Repro

It happens with any Rive animation. For example:

public struct RiveAnimationView: View {
  let riveFileData: Data

  public init(riveFileData: Data) {
    self.riveFileData = riveFileData
  }

  public var body: some View {
    RiveViewModel(
      RiveModel(
        riveFile: try! RiveFile(
          byteArray: [UInt8](riveFileData)
        )
      )
    )
    .view()
  }
}

Here is a complete example project where you can observe the bug: BlankRiveSnapshot.zip

Observed behavior

Rive animation is not rendered for the snapshot test. The view is simply blank.

Expected behavior

Rive animation should be rendered with its first frame visible on the snapshot test.

Additional context

I guess it happens because Rive internally works mostly asynchronously and non-blocking, which makes sense in a real app. It would be helpful to make this work somehow, even if it means modifying the Rive runtime behavior or environment. E.g. with my snapshot tests, I could pass in some extra parameter or environment to Rive, to make it render its first frame synchronously for the snapshot test.

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 with the BlankRiveSnapshot.zip reproduction and the Pointfreeco snapshot-testing integration described in the issue. Trace how Rive’s asynchronous rendering affects the first snapshot, then verify that the completed change shows the animation’s first frame synchronously in the snapshot test without disrupting normal runtime behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
swift
Domain
mobile-dev, testing
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.