Skip to content

Commit

Permalink
Potential fix for “art::ConditionVariable::WaitHoldingLocks” #209
Browse files Browse the repository at this point in the history
  • Loading branch information
Dima-Android committed Jan 8, 2025
1 parent 6717205 commit 9c9fcf8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,13 @@ internal fun PdfReaderScreen(
val viewState by viewModel.viewStates.observeAsState(PdfReaderViewState())
val viewEffect by viewModel.viewEffects.observeAsState()
val activity = LocalContext.current as? AppCompatActivity ?: return
val currentView = LocalView.current
ObserveLifecycleEvent { event ->
when (event) {
Lifecycle.Event.ON_STOP -> { viewModel.onStop(activity.isChangingConfigurations) }
Lifecycle.Event.ON_STOP -> {
currentView.keepScreenOn = false
viewModel.onStop(activity.isChangingConfigurations)
}
else -> {}
}
}
Expand All @@ -66,7 +70,6 @@ internal fun PdfReaderScreen(
val thumbnailsLazyListState = rememberLazyListState()
val layoutType = CustomLayoutSize.calculateLayoutType()
val focusManager = LocalFocusManager.current
val currentView = LocalView.current
LaunchedEffect(key1 = viewEffect) {
when (val consumedEffect = viewEffect?.consume()) {
is PdfReaderViewEffect.NavigateBack -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2403,6 +2403,7 @@ class PdfReaderViewModel @Inject constructor(
}

fun onStop(isChangingConfigurations: Boolean) {
disableForceScreenOnTimer?.cancel()
if (!this::pdfFragment.isInitialized || this.pdfFragment.document == null) {
//If pdfFragment is not yet initialized and onStop is called the most likely cause is that user has returned to the app after a while hence ViewModel was deinitialized and then user either very quickly:
//1. Navigated to some other screen from PdfReaderScreen screen
Expand Down

0 comments on commit 9c9fcf8

Please sign in to comment.