PatilShreyas/Capturable

View needs to be laid out before calling drawToBitmap()

Closed this issue · 2 comments

Hi, rare crash, but it happened 2 times on different devices (Android 10 and 12, both Samsung devices).

Fatal Exception: java.lang.IllegalStateException
View needs to be laid out before calling drawToBitmap()
androidx.core.view.ViewKt.drawToBitmap (ViewKt.java:236)
dev.shreyaspatil.capturable.CapturableKt$drawToBitmapPostLaidOut$lambda-2$$inlined$doOnLayout$1.onLayoutChange (View.kt:415)
android.view.View.layout (View.java:23768)
android.view.ViewGroup.layout (ViewGroup.java:7277)
androidx.compose.ui.viewinterop.AndroidViewHolder.onLayout (AndroidViewHolder.android.kt:201)
android.view.View.layout (View.java:23750)
android.view.ViewGroup.layout (ViewGroup.java:7277)

It might be an issue related to some of the frameworks changes done by a vendor, but anyway, would be nice to have some workaround.

Thanks for raising this. Can you give us your device details?

We always make sure that the view is laid on the layout before drawing the View to Bitmap. Not sure exactly why it's happening in your case.

Closing this due to inactivity. Feel free to re-open with more details.