Fixed
Status Update
Comments
il...@google.com <il...@google.com> #2
Yigit, do you have time to fix it?
reemission of the same liveData is racy
reemission of the same liveData is racy
ca...@gmail.com <ca...@gmail.com> #3
yea i'll take it.
il...@google.com <il...@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()
}
}
jb...@google.com <jb...@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: snap-temp-L69500000699869549
commit 658ded1d1c845cc764fb47e07c8f560ffae406ff
Author: Jeremy Woods <jbwoods@google.com>
Date: Wed Sep 23 14:44:52 2020
Keep long arg names from wrapping
When using safe-args with a long argument name, kotlin does an
automatic line wrap at 100 characters which makes it place the argument
return and variable on different lines, which fails.
We should add `·` to emit a space that never wraps.
Test: Added KotlinNavWriterTest
Bug: 168584987
Change-Id: Ibc31f91fd6b1c4a94f0b7c05b9b9679ffa09b625
(cherry picked from commit 766a3ad47da73e1179ce6419693a825c4d665cfd)
M navigation/navigation-safe-args-generator/src/main/kotlin/androidx/navigation/safe/args/generator/kotlin/KotlinNavWriter.kt
M navigation/navigation-safe-args-generator/src/test/kotlin/androidx/navigation/safe/args/generator/KotlinNavWriterTest.kt
A navigation/navigation-safe-args-generator/src/test/test-data/expected/kotlin_nav_writer_test/ReallyReallyReallyReallyReallyReallyReallyReallyReallyReallyReallyReallyReallyReallyLongNameMainFragmentArgs.kt
https://android-review.googlesource.com/1436914
Branch: snap-temp-L69500000699869549
commit 658ded1d1c845cc764fb47e07c8f560ffae406ff
Author: Jeremy Woods <jbwoods@google.com>
Date: Wed Sep 23 14:44:52 2020
Keep long arg names from wrapping
When using safe-args with a long argument name, kotlin does an
automatic line wrap at 100 characters which makes it place the argument
return and variable on different lines, which fails.
We should add `·` to emit a space that never wraps.
Test: Added KotlinNavWriterTest
Bug: 168584987
Change-Id: Ibc31f91fd6b1c4a94f0b7c05b9b9679ffa09b625
(cherry picked from commit 766a3ad47da73e1179ce6419693a825c4d665cfd)
M navigation/navigation-safe-args-generator/src/main/kotlin/androidx/navigation/safe/args/generator/kotlin/KotlinNavWriter.kt
M navigation/navigation-safe-args-generator/src/test/kotlin/androidx/navigation/safe/args/generator/KotlinNavWriterTest.kt
A navigation/navigation-safe-args-generator/src/test/test-data/expected/kotlin_nav_writer_test/ReallyReallyReallyReallyReallyReallyReallyReallyReallyReallyReallyReallyReallyReallyLongNameMainFragmentArgs.kt
ap...@google.com <ap...@google.com> #10
Project: platform/frameworks/support
Branch: snap-temp-L31300000699869852
commit 998afa5a45306f1096a053e0f9eb275481fe79ab
Author: Jeremy Woods <jbwoods@google.com>
Date: Wed Sep 23 14:44:52 2020
Keep long arg names from wrapping
When using safe-args with a long argument name, kotlin does an
automatic line wrap at 100 characters which makes it place the argument
return and variable on different lines, which fails.
We should add `·` to emit a space that never wraps.
Test: Added KotlinNavWriterTest
Bug: 168584987
Change-Id: Ibc31f91fd6b1c4a94f0b7c05b9b9679ffa09b625
(cherry picked from commit 766a3ad47da73e1179ce6419693a825c4d665cfd)
M navigation/navigation-safe-args-generator/src/main/kotlin/androidx/navigation/safe/args/generator/kotlin/KotlinNavWriter.kt
M navigation/navigation-safe-args-generator/src/test/kotlin/androidx/navigation/safe/args/generator/KotlinNavWriterTest.kt
A navigation/navigation-safe-args-generator/src/test/test-data/expected/kotlin_nav_writer_test/ReallyReallyReallyReallyReallyReallyReallyReallyReallyReallyReallyReallyReallyReallyLongNameMainFragmentArgs.kt
https://android-review.googlesource.com/1436918
Branch: snap-temp-L31300000699869852
commit 998afa5a45306f1096a053e0f9eb275481fe79ab
Author: Jeremy Woods <jbwoods@google.com>
Date: Wed Sep 23 14:44:52 2020
Keep long arg names from wrapping
When using safe-args with a long argument name, kotlin does an
automatic line wrap at 100 characters which makes it place the argument
return and variable on different lines, which fails.
We should add `·` to emit a space that never wraps.
Test: Added KotlinNavWriterTest
Bug: 168584987
Change-Id: Ibc31f91fd6b1c4a94f0b7c05b9b9679ffa09b625
(cherry picked from commit 766a3ad47da73e1179ce6419693a825c4d665cfd)
M navigation/navigation-safe-args-generator/src/main/kotlin/androidx/navigation/safe/args/generator/kotlin/KotlinNavWriter.kt
M navigation/navigation-safe-args-generator/src/test/kotlin/androidx/navigation/safe/args/generator/KotlinNavWriterTest.kt
A navigation/navigation-safe-args-generator/src/test/test-data/expected/kotlin_nav_writer_test/ReallyReallyReallyReallyReallyReallyReallyReallyReallyReallyReallyReallyReallyReallyLongNameMainFragmentArgs.kt
ap...@google.com <ap...@google.com> #11
Project: platform/frameworks/support
Branch: snap-temp-L53700000699921463
commit 0e594474451b1e1a2f6927179c703f1547dbfe7c
Author: Jeremy Woods <jbwoods@google.com>
Date: Wed Sep 23 14:44:52 2020
Keep long arg names from wrapping
When using safe-args with a long argument name, kotlin does an
automatic line wrap at 100 characters which makes it place the argument
return and variable on different lines, which fails.
We should add `·` to emit a space that never wraps.
Test: Added KotlinNavWriterTest
Bug: 168584987
Change-Id: Ibc31f91fd6b1c4a94f0b7c05b9b9679ffa09b625
(cherry picked from commit 766a3ad47da73e1179ce6419693a825c4d665cfd)
M navigation/navigation-safe-args-generator/src/main/kotlin/androidx/navigation/safe/args/generator/kotlin/KotlinNavWriter.kt
M navigation/navigation-safe-args-generator/src/test/kotlin/androidx/navigation/safe/args/generator/KotlinNavWriterTest.kt
A navigation/navigation-safe-args-generator/src/test/test-data/expected/kotlin_nav_writer_test/ReallyReallyReallyReallyReallyReallyReallyReallyReallyReallyReallyReallyReallyReallyLongNameMainFragmentArgs.kt
https://android-review.googlesource.com/1436921
Branch: snap-temp-L53700000699921463
commit 0e594474451b1e1a2f6927179c703f1547dbfe7c
Author: Jeremy Woods <jbwoods@google.com>
Date: Wed Sep 23 14:44:52 2020
Keep long arg names from wrapping
When using safe-args with a long argument name, kotlin does an
automatic line wrap at 100 characters which makes it place the argument
return and variable on different lines, which fails.
We should add `·` to emit a space that never wraps.
Test: Added KotlinNavWriterTest
Bug: 168584987
Change-Id: Ibc31f91fd6b1c4a94f0b7c05b9b9679ffa09b625
(cherry picked from commit 766a3ad47da73e1179ce6419693a825c4d665cfd)
M navigation/navigation-safe-args-generator/src/main/kotlin/androidx/navigation/safe/args/generator/kotlin/KotlinNavWriter.kt
M navigation/navigation-safe-args-generator/src/test/kotlin/androidx/navigation/safe/args/generator/KotlinNavWriterTest.kt
A navigation/navigation-safe-args-generator/src/test/test-data/expected/kotlin_nav_writer_test/ReallyReallyReallyReallyReallyReallyReallyReallyReallyReallyReallyReallyReallyReallyLongNameMainFragmentArgs.kt
ap...@google.com <ap...@google.com> #12
Project: platform/frameworks/support
Branch: snap-temp-L25200000699921867
commit c9e5aa95317da82d339c362a3dae64a9f331e214
Author: Jeremy Woods <jbwoods@google.com>
Date: Wed Sep 23 14:44:52 2020
Keep long arg names from wrapping
When using safe-args with a long argument name, kotlin does an
automatic line wrap at 100 characters which makes it place the argument
return and variable on different lines, which fails.
We should add `·` to emit a space that never wraps.
Test: Added KotlinNavWriterTest
Bug: 168584987
Change-Id: Ibc31f91fd6b1c4a94f0b7c05b9b9679ffa09b625
(cherry picked from commit 766a3ad47da73e1179ce6419693a825c4d665cfd)
M navigation/navigation-safe-args-generator/src/main/kotlin/androidx/navigation/safe/args/generator/kotlin/KotlinNavWriter.kt
M navigation/navigation-safe-args-generator/src/test/kotlin/androidx/navigation/safe/args/generator/KotlinNavWriterTest.kt
A navigation/navigation-safe-args-generator/src/test/test-data/expected/kotlin_nav_writer_test/ReallyReallyReallyReallyReallyReallyReallyReallyReallyReallyReallyReallyReallyReallyLongNameMainFragmentArgs.kt
https://android-review.googlesource.com/1436925
Branch: snap-temp-L25200000699921867
commit c9e5aa95317da82d339c362a3dae64a9f331e214
Author: Jeremy Woods <jbwoods@google.com>
Date: Wed Sep 23 14:44:52 2020
Keep long arg names from wrapping
When using safe-args with a long argument name, kotlin does an
automatic line wrap at 100 characters which makes it place the argument
return and variable on different lines, which fails.
We should add `·` to emit a space that never wraps.
Test: Added KotlinNavWriterTest
Bug: 168584987
Change-Id: Ibc31f91fd6b1c4a94f0b7c05b9b9679ffa09b625
(cherry picked from commit 766a3ad47da73e1179ce6419693a825c4d665cfd)
M navigation/navigation-safe-args-generator/src/main/kotlin/androidx/navigation/safe/args/generator/kotlin/KotlinNavWriter.kt
M navigation/navigation-safe-args-generator/src/test/kotlin/androidx/navigation/safe/args/generator/KotlinNavWriterTest.kt
A navigation/navigation-safe-args-generator/src/test/test-data/expected/kotlin_nav_writer_test/ReallyReallyReallyReallyReallyReallyReallyReallyReallyReallyReallyReallyReallyReallyLongNameMainFragmentArgs.kt
ap...@google.com <ap...@google.com> #13
Project: platform/frameworks/support
Branch: snap-temp-L07700000699933785
commit f3069dc913eb8d41e6cc3859df5d6ef204fdf18c
Author: Jeremy Woods <jbwoods@google.com>
Date: Wed Sep 23 14:44:52 2020
Keep long arg names from wrapping
When using safe-args with a long argument name, kotlin does an
automatic line wrap at 100 characters which makes it place the argument
return and variable on different lines, which fails.
We should add `·` to emit a space that never wraps.
Test: Added KotlinNavWriterTest
Bug: 168584987
Change-Id: Ibc31f91fd6b1c4a94f0b7c05b9b9679ffa09b625
(cherry picked from commit 766a3ad47da73e1179ce6419693a825c4d665cfd)
M navigation/navigation-safe-args-generator/src/main/kotlin/androidx/navigation/safe/args/generator/kotlin/KotlinNavWriter.kt
M navigation/navigation-safe-args-generator/src/test/kotlin/androidx/navigation/safe/args/generator/KotlinNavWriterTest.kt
A navigation/navigation-safe-args-generator/src/test/test-data/expected/kotlin_nav_writer_test/ReallyReallyReallyReallyReallyReallyReallyReallyReallyReallyReallyReallyReallyReallyLongNameMainFragmentArgs.kt
https://android-review.googlesource.com/1436930
Branch: snap-temp-L07700000699933785
commit f3069dc913eb8d41e6cc3859df5d6ef204fdf18c
Author: Jeremy Woods <jbwoods@google.com>
Date: Wed Sep 23 14:44:52 2020
Keep long arg names from wrapping
When using safe-args with a long argument name, kotlin does an
automatic line wrap at 100 characters which makes it place the argument
return and variable on different lines, which fails.
We should add `·` to emit a space that never wraps.
Test: Added KotlinNavWriterTest
Bug: 168584987
Change-Id: Ibc31f91fd6b1c4a94f0b7c05b9b9679ffa09b625
(cherry picked from commit 766a3ad47da73e1179ce6419693a825c4d665cfd)
M navigation/navigation-safe-args-generator/src/main/kotlin/androidx/navigation/safe/args/generator/kotlin/KotlinNavWriter.kt
M navigation/navigation-safe-args-generator/src/test/kotlin/androidx/navigation/safe/args/generator/KotlinNavWriterTest.kt
A navigation/navigation-safe-args-generator/src/test/test-data/expected/kotlin_nav_writer_test/ReallyReallyReallyReallyReallyReallyReallyReallyReallyReallyReallyReallyReallyReallyLongNameMainFragmentArgs.kt
ma...@syslogic.io <ma...@syslogic.io> #14
Just gotten into a similar situation (the title matches): When calling method getArguments()
in the constructor, it returns null
.
While in public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
it returns the Bundle
Alike this I can obtain the arguments of a DialogFragment
inside a library, which doesn't know about the Navigation at all.
Description
STEPS:
DialogFragment
class calledMyDialog
MyNewDialog
that inherits fromMyDialog
instead ofDialogFragment
(for example, to inherit styles or UI)Now in a XML graph, try to add it and put it some
argument
s:Then, when trying to build the application, it won't compile and the navigation generated code will throw:
However, no problem with
actions
(Why it doesn't throw same error with typeMyNewDialogDirections
??)No problem if we use
MyDialog
(that inherits directly fromDialogFragment
) instead ofMyNewDialog
(that inherits fromMyDialog
and this last, fromDialogFragment