https://kotlinlang.org logo
#compose
Title
# compose
a

agrosner

08/17/2022, 1:21 PM
has anyone run into an issue like this one. We get this from backgrounding, and reopening the app. we thought it might be a memory leak. and the stacktrace doesnt quite help with the issue. some code in 🧵
we remember our own custom indication instance:
Copy code
@Composable
    override fun rememberUpdatedInstance(interactionSource: InteractionSource): IndicationInstance {
    
//..
remember(interactionSource) {
            PressableIndicationInstance(
                isPressed = isPressed,
                cornerRadiusSizeInPx = cornerRadiusSize,
                scale = scale,
                overlayColor = color,
                overlayOpacity = config.overlayOpacity,
                hasOverlay = config.hasOverlay
            )
        }
}
nothing too crazy.
our indication instance draws this:
Copy code
override fun ContentDrawScope.drawIndication() {
            if (isPressed.value) {
                scale(scale = scale.value) {
                    (this as ContentDrawScope).drawContent()
                    val color = overlayColor.copy(alpha = overlayOpacity)
                    val style = if (hasOverlay) Fill else Stroke()
                    if (cornerRadiusSizeInPx == 0.0f) {
                        drawRect(color = color, size = size, style = style)
                    } else {
                        drawRoundRect(
                            color = color,
                            size = size,
                            cornerRadius = CornerRadius(
                                cornerRadiusSizeInPx,
                                cornerRadiusSizeInPx,
                            ),
                            style = style
                        )
                    }
                }
            } else {
                drawContent()
            }
        }
nothing crazy. and its provided as a composition local
how does one go about debugging it?
it happens in these steps (when inside a fragment):
Copy code
ON_CREATE
 ON_START 
 ON_RESUME
 ON_PAUSE 
 ON_STOP
 ON_START 
 ON_RESUME
after second resume from stop, crash
4 Views