rive-app / rive-app/rive-android

Compose runtime does not work in Paparazzi/JVM screenshot tests

Open
#460 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

Description

The new Compose runtime path (rememberRiveWorker(), rememberRiveFile(), Rive(...)) does not work in Paparazzi/JVM screenshot tests.

This makes it hard to add screenshot coverage for Compose screens that use Rive. Today we have to replace Rive with placeholders/static stand-ins in Paparazzi instead of rendering the actual animation output.

This seems related to Rive's broader Compose testing support, but different from #444:

  • #444 = Compose UI test / Espresso idleness once the runtime is already running
  • this issue = the runtime fails during initialization in a JVM screenshot-test environment
Minimal repro
@Test
fun riveCompose_screenshot() {
    paparazzi.snapshot {
        MaterialTheme {
            NativeThumbsUpRive(modifier = Modifier.size(96.dp))
        }
    }
}

@Composable
private fun NativeThumbsUpRive(modifier: Modifier = Modifier) {
    val worker = rememberRiveWorker()
    when (val fileResult = rememberRiveFile(RiveFileSource.RawRes.from(R.raw.thumbs_up), worker)) {
        is Result.Success -> {
            Rive(
                file = fileResult.value,
                modifier = modifier,
                playing = true,
            )
        }
        else -> Unit
    }
}
Actual result

The runtime fails to initialize:

app.rive.RiveInitializationException: Failed to create Rive worker
Caused by: java.lang.RuntimeException: Method eglGetDisplay in android.opengl.EGL14 not mocked.
See https://developer.android.com/r/studio-ui/build/not-mocked for details.

at android.opengl.EGL14.eglGetDisplay(EGL14.java)
at app.rive.core.RenderContextGL$Companion.createDisplay(RenderContext.kt:125)
at app.rive.core.RenderContextGL.<init>(RenderContext.kt:105)
at app.rive.core.CommandQueue.<init>(CommandQueue.kt:137)
at app.rive.RememberRiveWorkerKt.createRiveWorker(rememberRiveWorker.kt:157)
at app.rive.RememberRiveWorkerKt.rememberRiveWorker(rememberRiveWorker.kt:57)
Expected result

Either:

  1. the Compose runtime should work in Paparazzi/layoutlib/JVM screenshot tests, or
  2. this environment should be documented as unsupported
Why this matters

Paparazzi is a common screenshot-test stack for Android Compose UI. Without support for this environment, teams using the new Compose runtime cannot verify actual Rive output in screenshot tests and have to fall back to placeholders or device-only coverage.

Related
  • #444 — Compose UI test / Espresso idleness with the Compose runtime
  • #316 — historical test-environment failure on an older runtime path
Versions
  • observed on rive-android 11.6.1 and 11.7.0
  • Compose runtime path only (rememberRiveWorker() + rememberRiveFile() + Rive(...))

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 minimal Paparazzi test and the stack-trace entry points in RenderContext.kt and rememberRiveWorker.kt. Reproduce the EGL14 failure in the JVM screenshot-test environment, then determine whether the Compose runtime can support it there or whether the environment should be documented as unsupported. Done means the test renders actual Rive output or the limitation is clearly documented.

Written by the indexing model from the issue text.

Assessment

Tech stack
android, kotlin
Domain
mobile, testing-qa
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.