Is it possible to indicate to Paparazzi to wait a ...
# squarelibraries
j
Is it possible to indicate to Paparazzi to wait a few milliseconds to record the snapshot (I am showing an snackbar in Compose and Paparazzi can't get it)
b
I'm afk but there's a method where you can set the time you wanna start capturing. That might be the gif method. You can take only one frame later on kinda truck
j
Yeah, but gif is not compatible with compose
b
Try something like
paparazzi.gif(view, start = 500L, end = 500L, fps = 1)
j
I can't, I haven't a View with Compose
b
You cannot what?
j
I haven't a View, I have a composable, I can't use it with
gif
method
it only accepts
View
b
Copy code
fun snapshot(name: String? = null, composable: @Composable () -> Unit) {
    val hostView = ComposeView(context)
    // During onAttachedToWindow, AbstractComposeView will attempt to resolve its parent's
    // CompositionContext, which requires first finding the "content view", then using that to
    // find a root view with a ViewTreeLifecycleOwner
    val parent = FrameLayout(context).apply { id = android.R.id.content }
    parent.addView(hostView, LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)
    PaparazziComposeOwner.register(parent)
    hostView.setContent(composable)
    snapshot(parent, name)

    forceReleaseComposeReferenceLeaks()
  }
You can try to copy the hack it’s doing and pass the view to the gif method
👍 1
j
I will try, thank you :)
y
I tried a PR for this https://github.com/cashapp/paparazzi/pull/509, but my impression is that it surfaces a bunch of areas that integration with compose is still needed.
State changes, Launched effects, all didn't act predictably.
A 5 second video completes in 300ms (although the first test takes a 10 second hit form classloading?
The 300ms video doesn't ever get to a LaunchedEffect during the 5 second capture, while the slow run processes a launched effect after 2.5 seconds.
j
Thank you :) subscribed to all issues. I am not using launchedeffect as I delegate everything to the viewModel, if there is an snapshot I could try it next week
y
No idea, I'm external contributor. They will probably reject my PR as it would create juts more bugs raised for now.
👍 1
You may not use things like launched effects bit animations, or in my case a wear specific LazyColumn do. So things may or may not work.
As @Benoit Quenaudon said, you can copy the hack, hopefully it just works for you.
👍 1
j
@Benoit Quenaudon sorry for my late reply, I tried it, a tons of images are created and a video too, but there is no animation. I tried to increase to 3 seconds but no luck, no animation is shown.
b
Sorry I cannot help more than that. The best try would be to have a repro test and attach it to an issue on the github repo
j
I think it is better to get an official integration, but it is blocked as @yschimke mentioned on the issue. How is Square testing animations with Paparazzi? instead of testing an animation, setting a frame where the composable is visible (for example a snackbar)?
515 Views