mirror of
https://github.com/tuskyapp/Tusky
synced 2024-12-22 23:08:04 +01:00
b2547c5eef
Fragments don't necessarily have the same lifecycle as their views, so their is a rare race condition when collecting a Flow from the `lifecycleScope` of the Fragment where the view is already disposed but the collect lambda is still executed. Accessing the view from such a lambda can therefore led to a crash. Collecting from the `viewLifecycleOwner.lifecycleScope` fixes the problem. ``` Exception java.lang.IllegalStateException: at androidx.fragment.app.Fragment.requireView (Fragment.java:2062) at com.keylesspalace.tusky.util.ViewLifecycleLazy.getValue (ViewBindingExtensions.kt:32) at com.keylesspalace.tusky.components.viewthread.ViewThreadFragment.getBinding (ViewThreadFragment.kt:79) at com.keylesspalace.tusky.components.viewthread.ViewThreadFragment.access$getBinding (ViewThreadFragment.kt:67) at com.keylesspalace.tusky.components.viewthread.ViewThreadFragment$onViewCreated$3$1.emit (ViewThreadFragment.java:250) at com.keylesspalace.tusky.components.viewthread.ViewThreadFragment$onViewCreated$3$1.emit (ViewThreadFragment.java:248) at kotlinx.coroutines.flow.SharedFlowImpl.collect$suspendImpl (SharedFlow.kt:392) at kotlinx.coroutines.flow.SharedFlowImpl$collect$1.invokeSuspend (SharedFlow.kt:13) at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith (ContinuationImpl.kt:33) at kotlinx.coroutines.DispatchedTaskKt.resume (DispatchedTask.kt:231) at kotlinx.coroutines.DispatchedTaskKt.resumeUnconfined (DispatchedTask.kt:187) at kotlinx.coroutines.DispatchedTaskKt.dispatch (DispatchedTask.kt:159) at kotlinx.coroutines.CancellableContinuationImpl.dispatchResume (CancellableContinuationImpl.kt:470) at kotlinx.coroutines.CancellableContinuationImpl.resumeImpl (CancellableContinuationImpl.kt:504) at kotlinx.coroutines.CancellableContinuationImpl.resumeImpl$default (CancellableContinuationImpl.kt:493) at kotlinx.coroutines.CancellableContinuationImpl.resumeWith (CancellableContinuationImpl.kt:364) at kotlinx.coroutines.flow.SharedFlowImpl.tryEmit (SharedFlow.kt:409) at kotlinx.coroutines.flow.SharedFlowImpl.emit$suspendImpl (SharedFlow.kt:414) at kotlinx.coroutines.flow.SharedFlowImpl.emit (SharedFlow.kt:1) at com.keylesspalace.tusky.components.viewthread.ViewThreadViewModel$loadThread$1.invokeSuspend (ViewThreadViewModel.kt:172) at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith (ContinuationImpl.kt:33) at kotlinx.coroutines.DispatchedTask.run (DispatchedTask.kt:104) at android.os.Handler.handleCallback (Handler.java:938) at android.os.Handler.dispatchMessage (Handler.java:99) at android.os.Looper.loopOnce (Looper.java:210) at android.os.Looper.loop (Looper.java:299) at android.app.ActivityThread.main (ActivityThread.java:8319) at java.lang.reflect.Method.invoke at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:556) at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1038) ``` |
||
---|---|---|
.. | ||
schemas/com.keylesspalace.tusky.db.AppDatabase | ||
src | ||
build.gradle | ||
getGitSha.gradle | ||
lint-baseline.xml | ||
lint.xml | ||
proguard-rules.pro |