JetBrains / compose-multiplatform

Compose Multiplatform, a modern UI framework for Kotlin that makes building performant and beautiful user interfaces easy and enjoyable.
https://jetbrains.com/lp/compose-multiplatform
Apache License 2.0
16.08k stars 1.17k forks source link

NavigationRail error in some devices #3399

Closed helmysaeed closed 3 weeks ago

helmysaeed commented 1 year ago

Exception in thread "AWT-EventQueue-0" kotlinx.coroutines.CompletionHandlerException: Exception in resume onCancellation handler for CancellableContinuation(DispatchedContinuation[FlushCoroutineDispatcher@232812c8, Continuation at androidx.compose.foundation.gestures.PressGestureScopeImpl.reset(TapGestureDetector.kt:365)@191ad5f]){Completed}@6fc20858 at kotlinx.coroutines.CancellableContinuationImpl.callOnCancellation(CancellableContinuationImpl.kt:264) at kotlinx.coroutines.CompletedContinuation.invokeHandlers(CancellableContinuationImpl.kt:659) at kotlinx.coroutines.CancellableContinuationImpl.cancelCompletedResult$kotlinx_coroutines_core(CancellableContinuationImpl.kt:180) at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:100) at androidx.compose.ui.platform.FlushCoroutineDispatcher$dispatch$2$1.invoke(FlushCoroutineDispatcher.skiko.kt:62) at androidx.compose.ui.platform.FlushCoroutineDispatcher$dispatch$2$1.invoke(FlushCoroutineDispatcher.skiko.kt:57) at androidx.compose.ui.platform.FlushCoroutineDispatcher.performRun(FlushCoroutineDispatcher.skiko.kt:91) at androidx.compose.ui.platform.FlushCoroutineDispatcher.access$performRun(FlushCoroutineDispatcher.skiko.kt:37) at androidx.compose.ui.platform.FlushCoroutineDispatcher$dispatch$2.invokeSuspend(FlushCoroutineDispatcher.skiko.kt:57) at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33) at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106) at java.desktop/java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:318) at java.desktop/java.awt.EventQueue.dispatchEventImpl(EventQueue.java:773) at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:720) at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:714) at java.base/java.security.AccessController.doPrivileged(AccessController.java:399) at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:86) at java.desktop/java.awt.EventQueue.dispatchEvent(EventQueue.java:742) at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:203) at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:124) at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:113) at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:109) at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101) at java.desktop/java.awt.EventDispatchThread.run(EventDispatchThread.java:90) Suppressed: kotlinx.coroutines.internal.DiagnosticCoroutineContextException: [androidx.compose.ui.awt.ComposeBridge$coroutineExceptionHandler$1@356afe9b, androidx.compose.runtime.BroadcastFrameClock@8c00ccc, StandaloneCoroutine{Cancelling}@27a2cd0, FlushCoroutineDispatcher@232812c8] Caused by: java.lang.IllegalStateException: This mutex is not locked at kotlinx.coroutines.sync.MutexImpl.unlock(Mutex.kt:207) at kotlinx.coroutines.sync.MutexImpl$CancellableContinuationWithOwner$tryResume$token$1.invoke(Mutex.kt:255) at kotlinx.coroutines.sync.MutexImpl$CancellableContinuationWithOwner$tryResume$token$1.invoke(Mutex.kt:252) at kotlinx.coroutines.CancellableContinuationImpl.callOnCancellation(CancellableContinuationImpl.kt:259) ... 23 more

Versions

pjBooms commented 1 year ago

Can you provide a reproducible sample for this?

helmysaeed commented 1 year ago

Can you provide a reproducible sample for this?

@Composable fun navSide( department: (String) -> Unit, selectedIndexClick: (String) -> Unit, selectedIndex: String, // selectedTab: (String)->Unit ) {

   val item=  mutableListOf(Nav( localization.sales,docType.sales,icon = Icons.Outlined.PointOfSale)
       ,Nav( localization.salesReturn,docType.salesReturn,Icons.Outlined.SwapVert)
       , Nav( localization.purchases,docType.purches ,icon = Icons.Outlined.ShoppingBasket),
       Nav( localization.purchasesReturn,docType.purchesReturn,Icons.Outlined.SwapHoriz),
               Nav( localization.items,docType.items,icon = Icons.Outlined.Inventory) ,Nav( localization.inventory,docType.inventory,icon = Icons.Outlined.Inventory2 ),
    Nav(localization.partner,docType.partner,Icons.Outlined.Groups),Nav( localization.finance,docType.finincial,Icons.Outlined.Analytics),
               Nav( localization.security,docType.security ,icon = Icons.Outlined.Security))
Column(modifier = Modifier ) {

    NavigationRail(

        containerColor = Color.Transparent,

        content = {

            item.forEachIndexed {index,it->
                NavigationRailItem(

                    onClick = {
                 //   selectedTab("0")

                    selectedIndexClick(index.toString())

                    department(it.number)

                } ,
                    enabled = true

                     ,
                    selected =  index.toString()==selectedIndex,

                    icon = { it.icon?.let { it1 -> Icon(imageVector = it1,contentDescription = "") } },

                    label = {Text(it.key)  },

                )
            }
        }
    )

      //  Divider()

 /*   ModalNavigationDrawer(
        drawerState = drawerState,
        drawerContent = {
            Text("meedd")
       *//*     NavigationDrawerItem(label = { Text(text = "me")}, selected = true , onClick = {
                scope.launch {
                    drawerState.close()

                }
            })*//*
        }) {

    }*/

}

}

okushnikov commented 3 months ago

Please check the following ticket on YouTrack for follow-ups to this issue. GitHub issues will be closed in the coming weeks.