Hi, folks! A few users of our app are reporting a ...
# coroutines
e
Hi, folks! A few users of our app are reporting a very weird issue, which seems to be caused by a some `StateFlow`s not emitting their initial values. What we are doing is that in our ViewModel we have a big
combine
of 17 (it's our main screen, if that justifies the high number 😅) Flows, only one of them is a cold flow, one is a
SharedFlow
with
replay = 1
, and the rest are `StateFlow`s. This `combine`'s result we turn into a
StateFlow
using the
stateIn
operator, and then we call
collectAsStateWithLifecycle()
on it in Compose. Here I created a gist to illustrate better what I mean. We managed to reproduce the issue on an old Moto C running Android 7, but only when we restart the Activity (that's our MVP hacky way to switch accounts 😄). However, the users that reported this issue didn't have access to the account switching feature yet, so for them it happened when simply just opening the app. Either way, the only thing we managed to figure out is that the initial state from
stateIn
gets emitted and collected in Compose, and only like 4 of the 17 flows emit something (we can see that if we add
.onEach { println(it) }
on all flows that are part of the big
combine
). But the other flows, which are all `StateFlow`s, are not emitting their initial values 😐 We are currently stuck here, we don't know how can we even debug further. Did anyone else encounter something similar before? Or how would you debug this issue to find the root cause? Any leads are greatly appreciated 🙏
🙏 2