Frequent flashes - Jetpack Compose
In Jetpack Compose, flashing content often uses LaunchedEffect
with infinite loop, or Timer
. Check if these objects are used to show more than three flashes per second.
If your app contains any videos, also check if these contain more than three flashes per second.
var isFlashing by remember { mutableStateOf(false) }
val coroutineScope = rememberCoroutineScope()
// Timer to control the flashing rate
// Flash every 1/3 second (3 times per second)
// Do not do this
LaunchedEffect(Unit) {
coroutineScope.launch {
while (true) {
delay(333) // 1/3 second
isFlashing = !isFlashing
}
}
}
Box(
modifier = Modifier
.fillMaxSize()
.background(if (isFlashing) Color.Black else Color.White)
contentAlignment = Alignment.Center
) {
Text(
text = "Flashing Content",
color = if (isFlashing) Color.White else Color.Black
)
}