@@ -4,23 +4,43 @@ import androidx.compose.foundation.layout.Arrangement
44import androidx.compose.foundation.layout.Box
55import androidx.compose.foundation.layout.Column
66import androidx.compose.foundation.layout.fillMaxSize
7+ import androidx.compose.foundation.layout.Row
78import androidx.compose.material3.Button
89import androidx.compose.material3.Scaffold
10+ import androidx.compose.material3.Switch
911import androidx.compose.material3.Text
1012import androidx.compose.runtime.Composable
13+ import androidx.compose.runtime.LaunchedEffect
1114import androidx.compose.runtime.getValue
1215import androidx.compose.runtime.mutableStateOf
1316import androidx.compose.runtime.remember
1417import androidx.compose.runtime.setValue
1518import androidx.compose.ui.Alignment
1619import androidx.compose.ui.Modifier
1720import androidx.compose.ui.unit.dp
21+ import androidx.compose.animation.core.withInfiniteAnimationFrameMillis
1822import io.github.vinceglb.confettikit.compose.ConfettiKit
23+ import kotlin.time.Duration.Companion.milliseconds
24+ import kotlin.time.TimeSource
1925
2026@Composable
2127fun App () {
2228 var isAnimating by remember { mutableStateOf(false ) }
2329 var index by remember { mutableStateOf(0 ) }
30+ var simulateLag by remember { mutableStateOf(false ) }
31+
32+ if (simulateLag) {
33+ LaunchedEffect (Unit ) {
34+ while (true ) {
35+ withInfiniteAnimationFrameMillis {
36+ val start = TimeSource .Monotonic .markNow()
37+ while (start.elapsedNow() < 40 .milliseconds) {
38+ // Busy-loop to simulate main-thread jank
39+ }
40+ }
41+ }
42+ }
43+ }
2444
2545 Scaffold {
2646 Box (
@@ -39,6 +59,17 @@ fun App() {
3959 ) {
4060 Text (" Fiesta 🥳" )
4161 }
62+
63+ Row (
64+ verticalAlignment = Alignment .CenterVertically ,
65+ horizontalArrangement = Arrangement .spacedBy(8 .dp),
66+ ) {
67+ Text (" Simulate lag" )
68+ Switch (
69+ checked = simulateLag,
70+ onCheckedChange = { simulateLag = it },
71+ )
72+ }
4273 }
4374
4475 if (isAnimating) {
0 commit comments