After updating from CMP 1.11.0-alpha03 to 1.11.0-a...
# compose-ios
m
After updating from CMP 1.11.0-alpha03 to 1.11.0-alpha04, my vector path animations have this annoying glitch (iOS only) where paths are being falsely drawn from the origin. Is this a known issue? If so, is there a workaround?
🙌 1
i
No. Please file a report.
1.11.0-alpha03 to 1.11.0-alpha04
This version includes skia update from m138 to m144 (6 months diff from upstream), so it looks like it's most likely something there
It had a big refactor of Path API (on skia side) 🤔 It passed all our tests, so we will be very grateful for the reproducer
m
This reproduces the problem:
Copy code
import androidx.compose.animation.core.LinearEasing
import androidx.compose.animation.core.RepeatMode
import androidx.compose.animation.core.animateFloat
import androidx.compose.animation.core.infiniteRepeatable
import androidx.compose.animation.core.rememberInfiniteTransition
import androidx.compose.animation.core.tween
import androidx.compose.foundation.Canvas
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.remember
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.Path
import androidx.compose.ui.graphics.PathMeasure
import androidx.compose.ui.graphics.drawscope.Stroke
/**
 * ULTRA-MINIMAL reproduction for a stroke animation glitch on iOS (CMP 1.11.0-alpha04).
 * 
 * If the bug is present, you will see a red line swinging from the top-left origin (0,0)
 * to the stroke, like a clock hand. 
 * 
 * On fixed versions (or 1.11.0-alpha03), there should be only a clean, floating segment.
 */
@Composable
fun StrokeBugReproduction(modifier: Modifier = Modifier) {
    // A path that is far from (0,0)
    val path = remember {
        Path().apply {
            moveTo(300f, 300f)
            lineTo(800f, 800f)
        }
    }
    
    val pathMeasure = remember(path) {
        PathMeasure().apply { setPath(path, false) }
    }
    // Re-using a persistent path object
    val segmentPath = remember { Path() }
    val transition = rememberInfiniteTransition()
    val progress by transition.animateFloat(
        initialValue = 0f,
        targetValue = 1f,
        animationSpec = infiniteRepeatable(
            animation = tween(2000, easing = LinearEasing),
            repeatMode = RepeatMode.Restart
        )
    )
    Canvas(modifier = modifier.fillMaxSize()) {
        segmentPath.reset()
        val length = pathMeasure.length
        
        // Start from 50% marker to force a non-zero start point
        val startDistance = length * 0.5f
        val stopDistance = length * progress
        if (stopDistance > startDistance) {
            // BUG: startWithMoveTo = true is ignored on iOS, defaulting to (0,0)
            pathMeasure.getSegment(startDistance, stopDistance, segmentPath, true)
            
            drawPath(
                path = segmentPath,
                color = Color.Red,
                style = Stroke(width = 10f)
            )
        }
    }
}
👀 1
thank you color 1
Should I still go ahead with the bug report?
i
I'm already looking at it, but yes it's better to create something trackable
m
CMP-9969 UI glitch when animating path (CMP 1.11.0-alpha04)
thank you color 1
i