I'm facing a super weird bug (I guess) which trigg...
# compose
s
I'm facing a super weird bug (I guess) which triggers an endless recomposition, it took me a while to narrow it down to a minimal reproducible example (15 LOC snippet in first comment)... Edit: https://issuetracker.google.com/issues/230530875
👀 2
Copy code
class Model(val resultState: State<String>): CoroutineScope by GlobalScope

@Composable
fun Bug() {
    println("[${System.currentTimeMillis()}] Recomposition...")
    
    val resultState = produceState(initialValue = "initial") { value = "loaded" }
    
    val model = remember { Model(resultState) }
    
    LazyColumn { 
        model.resultState.value
    }
}
Key points to reproduce: 1.
Bug
must not be `inline`; 2.
Model
must be (by delegation) a
CoroutineScope
or have a
CoroutineScope
property; 3.
Model::resultState
must be accessed within a
LazyColumn
or
LazyRow
scope.
Output:
Copy code
I/System.out: [1651057113536] Recomposition...
I/System.out: [1651057113558] Recomposition...
I/System.out: [1651057113570] Recomposition...
I/System.out: [1651057113586] Recomposition...
I/System.out: [1651057113603] Recomposition...
I/System.out: [1651057113619] Recomposition...
[...]