See https://github.com/Kotlin/kotlinx.coroutines/pull/1648#issuecomment-574259404 by @Thomas-Vos
I've a bit minimized it to this test:
@Test
fun testFlowCombine() = runTest {
withContext(Dispatchers.Default) {
val flow = flowOf(1)
val combo = combine(flow, flow) { a, b -> a + b }
assertEquals(2, combo.first())
}
}
It crashes due to freezing on coroutine's state machine inside implementation of combine.
This also applies to other operators like flatMapConcat(). That's a bit problematic with the approach described in KaMPKit (recently promoted on the Jetbrains blog, see init in BreedModel.kt):
mainScope.launch {
dbHelper.selectAllItems().asFlow()
.flatMapConcat { dbHelper.selectAllItems().asFlow() } // for testing
.map { q ->
val itemList = q.executeAsList()
ItemDataSummary(itemList.maxBy { it.name.length }, itemList)
}
}
Doesn't happen on Android, only iOS.
I've finally managed to fix it. Pushed to native-mt branch.
Fixed in 1.3.9-native-mt
Most helpful comment
I've finally managed to fix it. Pushed to
native-mtbranch.