Fixed
Status Update
Comments
ti...@gmail.com <ti...@gmail.com> #2
Yigit, do you have time to fix it?
reemission of the same liveData is racy
reemission of the same liveData is racy
pa...@gmail.com <pa...@gmail.com> #3
yea i'll take it.
be...@google.com <be...@google.com> #4
Thanks for the detailed analysis. This may not be an issue anymore since we've started using Main.immediate there but I' not sure; I'll try to create a test case.
ap...@google.com <ap...@google.com> #5
just emitting same live data reproduces the issue.
@Test
fun raceTest() {
val subLiveData = MutableLiveData(1)
val subject = liveData(testScope.coroutineContext) {
emitSource(subLiveData)
emitSource(subLiveData) //crashes
}
subject.addObserver().apply {
testScope.advanceUntilIdle()
}
}
@Test
fun raceTest() {
val subLiveData = MutableLiveData(1)
val subject = liveData(testScope.coroutineContext) {
emitSource(subLiveData)
emitSource(subLiveData) //crashes
}
subject.addObserver().apply {
testScope.advanceUntilIdle()
}
}
ap...@google.com <ap...@google.com> #6
With 2.2.0-alpha04 (that use Main.immediate), the issue seems to be still there (I tested it by calling emitSource() twice, like your test case)
ap...@google.com <ap...@google.com> #7
yea sorry immediate does not fix it.
I actually have a WIP fix for it:
https://android-review.googlesource.com/c/platform/frameworks/support/+/1112186
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} )
}
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} )
}
ap...@google.com <ap...@google.com> #8
Project: platform/frameworks/support
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
https://android-review.googlesource.com/1112186
https://goto.google.com/android-sha1/af12e75e6b4110f48e44ca121466943909de8f06
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
ap...@google.com <ap...@google.com> #9
Project: platform/frameworks/support
Branch: androidx-master-dev
commit 7c1e1040023893a1f24d1e044de30732dbe1737e
Author: Ben Weiss <benweiss@google.com>
Date: Fri Sep 13 13:05:23 2019
Introduce navigation-dynamic-features-fragment
Enable navigating to fragments in com.android.dynamic-feature modules.
Also introduces DefaultProgressFragment and AbstractProgressFragment.
These classes provide progress destinations and enable customization of
progress display.
Bug: 132170186
Bug: 140712620
Bug: 142894369
Test: ./gradlew navigation:navigation-dynamic-features-fragment:check
Change-Id: If2eb6905048e35b67bfe6600d9fc85bbe79416c4
M buildSrc/src/main/kotlin/androidx/build/PublishDocsRules.kt
A navigation/navigation-dynamic-features-fragment/api/2.3.0-alpha01.txt
A navigation/navigation-dynamic-features-fragment/api/current.txt
A navigation/navigation-dynamic-features-fragment/api/public_plus_experimental_2.3.0-alpha01.txt
A navigation/navigation-dynamic-features-fragment/api/public_plus_experimental_current.txt
A navigation/navigation-dynamic-features-fragment/api/res-2.3.0-alpha01.txt
A navigation/navigation-dynamic-features-fragment/api/restricted_2.3.0-alpha01.txt
A navigation/navigation-dynamic-features-fragment/api/restricted_current.txt
A navigation/navigation-dynamic-features-fragment/build.gradle
A navigation/navigation-dynamic-features-fragment/src/androidTest/AndroidManifest.xml
A navigation/navigation-dynamic-features-fragment/src/androidTest/java/androidx/navigation/dynamicfeatures/fragment/DynamicNavHostFragmentTest.kt
A navigation/navigation-dynamic-features-fragment/src/androidTest/res/layout/dynamic_activity_layout.xml
A navigation/navigation-dynamic-features-fragment/src/androidTest/res/navigation/default_progress_navigation.xml
A navigation/navigation-dynamic-features-fragment/src/main/AndroidManifest.xml
A navigation/navigation-dynamic-features-fragment/src/main/java/androidx/navigation/dynamicfeatures/fragment/DynamicFragmentNavigator.java
A navigation/navigation-dynamic-features-fragment/src/main/java/androidx/navigation/dynamicfeatures/fragment/DynamicNavHostFragment.java
A navigation/navigation-dynamic-features-fragment/src/main/java/androidx/navigation/dynamicfeatures/fragment/ui/AbstractProgressFragment.java
A navigation/navigation-dynamic-features-fragment/src/main/java/androidx/navigation/dynamicfeatures/fragment/ui/DefaultProgressFragment.java
A navigation/navigation-dynamic-features-fragment/src/main/java/androidx/navigation/dynamicfeatures/fragment/ui/InstallViewModel.java
A navigation/navigation-dynamic-features-fragment/src/main/res/layout/dynamic_feature_install_fragment.xml
A navigation/navigation-dynamic-features-fragment/src/main/res/values/attrs.xml
A navigation/navigation-dynamic-features-fragment/src/main/res/values/ids.xml
A navigation/navigation-dynamic-features-fragment/src/main/res/values/strings.xml
M settings.gradle
https://android-review.googlesource.com/1120991
https://goto.google.com/android-sha1/7c1e1040023893a1f24d1e044de30732dbe1737e
Branch: androidx-master-dev
commit 7c1e1040023893a1f24d1e044de30732dbe1737e
Author: Ben Weiss <benweiss@google.com>
Date: Fri Sep 13 13:05:23 2019
Introduce navigation-dynamic-features-fragment
Enable navigating to fragments in com.android.dynamic-feature modules.
Also introduces DefaultProgressFragment and AbstractProgressFragment.
These classes provide progress destinations and enable customization of
progress display.
Bug: 132170186
Bug: 140712620
Bug: 142894369
Test: ./gradlew navigation:navigation-dynamic-features-fragment:check
Change-Id: If2eb6905048e35b67bfe6600d9fc85bbe79416c4
M buildSrc/src/main/kotlin/androidx/build/PublishDocsRules.kt
A navigation/navigation-dynamic-features-fragment/api/2.3.0-alpha01.txt
A navigation/navigation-dynamic-features-fragment/api/current.txt
A navigation/navigation-dynamic-features-fragment/api/public_plus_experimental_2.3.0-alpha01.txt
A navigation/navigation-dynamic-features-fragment/api/public_plus_experimental_current.txt
A navigation/navigation-dynamic-features-fragment/api/res-2.3.0-alpha01.txt
A navigation/navigation-dynamic-features-fragment/api/restricted_2.3.0-alpha01.txt
A navigation/navigation-dynamic-features-fragment/api/restricted_current.txt
A navigation/navigation-dynamic-features-fragment/build.gradle
A navigation/navigation-dynamic-features-fragment/src/androidTest/AndroidManifest.xml
A navigation/navigation-dynamic-features-fragment/src/androidTest/java/androidx/navigation/dynamicfeatures/fragment/DynamicNavHostFragmentTest.kt
A navigation/navigation-dynamic-features-fragment/src/androidTest/res/layout/dynamic_activity_layout.xml
A navigation/navigation-dynamic-features-fragment/src/androidTest/res/navigation/default_progress_navigation.xml
A navigation/navigation-dynamic-features-fragment/src/main/AndroidManifest.xml
A navigation/navigation-dynamic-features-fragment/src/main/java/androidx/navigation/dynamicfeatures/fragment/DynamicFragmentNavigator.java
A navigation/navigation-dynamic-features-fragment/src/main/java/androidx/navigation/dynamicfeatures/fragment/DynamicNavHostFragment.java
A navigation/navigation-dynamic-features-fragment/src/main/java/androidx/navigation/dynamicfeatures/fragment/ui/AbstractProgressFragment.java
A navigation/navigation-dynamic-features-fragment/src/main/java/androidx/navigation/dynamicfeatures/fragment/ui/DefaultProgressFragment.java
A navigation/navigation-dynamic-features-fragment/src/main/java/androidx/navigation/dynamicfeatures/fragment/ui/InstallViewModel.java
A navigation/navigation-dynamic-features-fragment/src/main/res/layout/dynamic_feature_install_fragment.xml
A navigation/navigation-dynamic-features-fragment/src/main/res/values/attrs.xml
A navigation/navigation-dynamic-features-fragment/src/main/res/values/ids.xml
A navigation/navigation-dynamic-features-fragment/src/main/res/values/strings.xml
M settings.gradle
be...@google.com <be...@google.com>
ag...@gmail.com <ag...@gmail.com> #10
I wonder how they fixed this? how they handle inter-module navigation with safe-args
related:https://issuetracker.google.com/issues/140354946
related:
be...@google.com <be...@google.com> #11
We did not just yet.
jo...@gmail.com <jo...@gmail.com> #12
Any updated on this?
be...@google.com <be...@google.com> #14
Yes, you can use it with non-dynamic modules as well.
Currently there is no way to use SafeArgs with dynamic feature modules. +1
ag...@gmail.com <ag...@gmail.com> #15
Having docs would be nice for the usage with non dynamic modules.
Can you please give me a code example of how to use this with non dynamic modules?
Can you please give me a code example of how to use this with non dynamic modules?
be...@google.com <be...@google.com> #16
All navigation-dynamic-*
components extend from their non-dynamic counterparts.
You should be able to use them the same way as using the navigation library.
If you encounter bugs on that path please let us know by
Limitations of navigation-dynamic-*
are
Description
Navigation currently requires your entire graph to be available when the app starts. Navigation should also support a method where parts of your graph can be provided by on demand installed dynamic feature module. It should also take care of managing the installation process when destinations from a not installed module are triggered.