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
ap...@google.com <ap...@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.
sa...@gmail.com <sa...@gmail.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()
}
}
Description
Version used: 2.1.0-alpha02 (Navigation), 1.1.0-alpha04 (AppCompat)
Devices/Android versions reproduced on: Pixel 3 XL (API Q)
Using the new AppCompatActivity constructor that accepts a @LayoutRes contentLayoutId and then calling findNavController in onCreate throws the following IllegalArgumentException:
2019-04-04 21:42:06.096 23637-23637/com.example.debug E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.debug, PID: 23637
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.debug/com.example.MainActivity}: java.lang.IllegalStateException: Activity com.example.MainActivity@a6fc922 does not have a NavController set on 2131362030
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3113)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3249)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:81)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1940)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:209)
at android.app.ActivityThread.main(ActivityThread.java:7046)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:486)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:862)
Caused by: java.lang.IllegalStateException: Activity com.example.MainActivity@a6fc922 does not have a NavController set on 2131362030
at androidx.navigation.Navigation.findNavController(Navigation.java:61)
at androidx.navigation.ActivityKt.findNavController(Activity.kt:30)
at com.example.MainActivity.setupBottomNavigation(MainActivity.kt:49)
at com.example.MainActivity.onCreate(MainActivity.kt:44)
at android.app.Activity.performCreate(Activity.java:7658)
at android.app.Activity.performCreate(Activity.java:7647)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1295)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3088)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3249)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:81)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1940)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:209)
at android.app.ActivityThread.main(ActivityThread.java:7046)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:486)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:862)
Using the traditional call to setContentView in onCreate before calling findNavController does not experience this crash.