For a full story of what I'm doing:
• I have a ViewModel with LiveData that holds the state of the last time the androidx.window library has told us of an update to window properties (to get foldable state information). We're using LiveData as this viewmodel is consumed by some legacy code not in compose
• On the compose side we observeAsState this window information, and do have some visual differences based on this object which has some additional properties we could compute separately but its convenient to have them together (like window orientation)
• The androidx.window library sends multiple updates in quick succession when you change orientation of the device on devices like the Samsung Fold, it tells you once some generic information, then quickly in a second update it gives you correct information about the foldable display properties. Its not easy to just discard the first update since you don't know if another is going to come.
in end it seems like there is a recompose timing / versioning flaw here, any suggestions or known issue which such a pattern? I still haven't seen any of the samples use the androidx.window windowLayoutInfo async APIs (well they briefly did and they were quickly removed to use synchronous alternatives, not sure if they hit bugs like this or just didn't like the flicker that this library kind of pushes on you)
I tried using StateFlow instead of LiveData, same issue occurs (actually seems like it happens a bit more often with StateFlow)