Status Update
Comments
il...@google.com <il...@google.com>
wa...@reaktor.fi <wa...@reaktor.fi> #2
reemission of the same liveData is racy
th...@gmail.com <th...@gmail.com> #3
ap...@google.com <ap...@google.com> #4
jb...@google.com <jb...@google.com> #5
@Test
fun raceTest() {
val subLiveData = MutableLiveData(1)
val subject = liveData(testScope.coroutineContext) {
emitSource(subLiveData)
emitSource(subLiveData) //crashes
}
subject.addObserver().apply {
testScope.advanceUntilIdle()
}
}
ro...@gmail.com <ro...@gmail.com> #6
jb...@google.com <jb...@google.com> #7
I actually have a WIP fix for it:
if your case is the one i found (emitting same LiveData multiple times, as shown in #5) you can work around it by adding a dummy transformation.
val subLiveData = MutableLiveData(1)
val subject = liveData(testScope.coroutineContext) {
emitSource(subLiveData.map {it })
emitSource(subLiveData.map {it} )
}
ro...@gmail.com <ro...@gmail.com> #8
Branch: androidx-master-dev
commit af12e75e6b4110f48e44ca121466943909de8f06
Author: Yigit Boyar <yboyar@google.com>
Date: Tue Sep 03 12:58:11 2019
Fix coroutine livedata race condition
This CL fixes a bug in liveData builder where emitting same
LiveData source twice would make it crash because the second
emission registry could possibly happen before first one is
removed as source.
We fix it by using a suspending dispose function. It does feel
a bit hacky but we cannot make DisposableHandle.dispose async
and we do not want to block there. This does not mean that there
is a problem if developer disposes it manually since our emit
functions take care of making sure it disposes (and there is
no other way to add source to the underlying MediatorLiveData)
Bug: 140249349
Test: BuildLiveDataTest#raceTest_*
Change-Id: I0b464c242a583da4669af195cf2504e2adc4de40
M lifecycle/lifecycle-livedata-ktx/api/2.2.0-alpha05.txt
M lifecycle/lifecycle-livedata-ktx/api/current.txt
M lifecycle/lifecycle-livedata-ktx/api/public_plus_experimental_2.2.0-alpha05.txt
M lifecycle/lifecycle-livedata-ktx/api/public_plus_experimental_current.txt
M lifecycle/lifecycle-livedata-ktx/api/restricted_2.2.0-alpha05.txt
M lifecycle/lifecycle-livedata-ktx/api/restricted_current.txt
M lifecycle/lifecycle-livedata-ktx/src/main/java/androidx/lifecycle/CoroutineLiveData.kt
M lifecycle/lifecycle-livedata-ktx/src/test/java/androidx/lifecycle/BuildLiveDataTest.kt
ro...@gmail.com <ro...@gmail.com> #9
The issue in Empty
. But if you leave the app open and toggle the system dark mode, now the app will get recomposed with the new value2
.
If it helps, I can share the project, but it's really just the code from
th...@gmail.com <th...@gmail.com> #10
th...@gmail.com <th...@gmail.com> #11
Also, IMO, this is a core issue and should be marked as a high priority.
ap...@google.com <ap...@google.com> #13
Branch: androidx-main
commit 5f1bdbbffc8c06355b22fdfe72ef1cf666b0d904
Author: Jeremy Woods <jbwoods@google.com>
Date: Wed Aug 18 03:45:03 2021
Ensure changing arguments causes recompose
Now that NavBackStackEntries are immutable and we don't just change
arguements, we change entire entries, we should make sure NavigatorState
properly handles launchSingleTop.
The only thing we need to do is to update both the navController and
navigator state back stacks with the proper entry.
RelNote: "Navigation Compose now properly recomposes when changing back
stack arguments and using launchSingleTop=true."
Test: all tests pass, and tested in samples from bug
Bug: 186392337
Fixes: 196390311
Change-Id: Iebd698c9e310ad84ce65238c8a5a33db86a9f1f7
M navigation/navigation-common/api/current.txt
M navigation/navigation-common/api/public_plus_experimental_current.txt
M navigation/navigation-common/api/restricted_current.txt
M navigation/navigation-common/src/main/java/androidx/navigation/Navigator.kt
M navigation/navigation-common/src/main/java/androidx/navigation/NavigatorState.kt
M navigation/navigation-runtime/src/androidTest/java/androidx/navigation/NavControllerTest.kt
M navigation/navigation-runtime/src/main/java/androidx/navigation/NavController.kt
jb...@google.com <jb...@google.com> #14
We were able to get a fix for this in Navigation 2.4.0-alpha08
.
You can try this out by following the #7677699
.
ma...@gmail.com <ma...@gmail.com> #15
jb...@google.com <jb...@google.com> #16
Please file a new bug with a minimal sample project that reproduces the issue.
so...@gmail.com <so...@gmail.com> #17
The same issue still exists.
il...@google.com <il...@google.com> #18
Re
Description
Component used: Navigation-Compose Version used: 1.0.0-alpha10, Compose 1.0.0-beta05
A bit short on time, so just posting a simple repro here. When trying to navigate to a destination that is the current destination but with different arguments using
NavOptions.launchSingleTop
, the NavController will replace the current NavBackStackEntry's arguments. Consider the following example:In
NavController#currentBackStackEntryAsState
, theState
's value won't be changed because the reference stays the same and the NavBackStackEntry held by the state has already been mutated, so theNavHost
won't recompose after that change. Maybe theNeverEqualPolicy
could be used as a quick fix.Let me know if you need more info, cheers!