skiptools / skip-ui

SwiftUI for Android
https://skip.tools
GNU Lesser General Public License v3.0
128 stars 14 forks source link

NavigationStack breaks onTapGesture #14

Closed pnewell closed 1 year ago

pnewell commented 1 year ago

Not sure exactly what is causing the crash, but here is what I have figured out so far. It seems to be the interplay of NavigationStack/Form/onTapGesture, removing NavigationStack or Form and I can't reproduce. The first click/tap works fine and the second row is shown, but on tapping again the emulator crashes.

public struct ContentView: View {
    @State var isShowing: Bool = false

    public init() {
    }

    public var body: some View {
        NavigationStack {
            Form {
                Section {
                    HStack {
                        Text("Click Me")
                            .onTapGesture {
                                isShowing = !isShowing
                            }
                    }
                    if(isShowing) {
                        HStack {
                            Text("Hi!")
                        }
                    }
                }
            }
        }
    }
}
pnewell commented 1 year ago

Still can't completely consistently recreate this but was able to grab a stacktrace:

E  FATAL EXCEPTION: main
   Process: com.example.app, PID: 2007
   java.lang.IndexOutOfBoundsException: Index 3, size 3
       at androidx.compose.foundation.lazy.layout.MutableIntervalList.checkIndexBounds(IntervalList.kt:183)
       at androidx.compose.foundation.lazy.layout.MutableIntervalList.get(IntervalList.kt:166)
       at androidx.compose.foundation.lazy.layout.LazyLayoutIntervalContent.getKey(LazyLayoutIntervalContent.kt:86)
       at androidx.compose.foundation.lazy.LazyListItemProviderImpl.getKey(LazyListItemProvider.kt:85)
       at androidx.compose.foundation.lazy.LazyListMeasuredItemProvider.getAndMeasure(LazyListMeasuredItemProvider.kt:46)
       at androidx.compose.foundation.lazy.LazyListMeasureKt.createItemsAfterList(LazyListMeasure.kt:418)
       at androidx.compose.foundation.lazy.LazyListMeasureKt.measureLazyList-50ZNEM8(LazyListMeasure.kt:278)
       at androidx.compose.foundation.lazy.LazyListKt$rememberLazyListMeasurePolicy$1$1.invoke-0kLqBqw(LazyList.kt:328)
       at androidx.compose.foundation.lazy.LazyListKt$rememberLazyListMeasurePolicy$1$1.invoke(LazyList.kt:193)
       at androidx.compose.foundation.lazy.layout.LazyLayoutKt$LazyLayout$3$2$1.invoke-0kLqBqw(LazyLayout.kt:107)
       at androidx.compose.foundation.lazy.layout.LazyLayoutKt$LazyLayout$3$2$1.invoke(LazyLayout.kt:100)
       at androidx.compose.ui.layout.LayoutNodeSubcompositionsState$createMeasurePolicy$1.measure-3p2s80s(SubcomposeLayout.kt:708)
       at androidx.compose.ui.node.InnerNodeCoordinator$LookaheadDelegateImpl.measure-BRTryo0(InnerNodeCoordinator.kt:81)
       at androidx.compose.foundation.AndroidOverscrollKt$StretchOverscrollNonClippingLayer$2.invoke-3p2s80s(AndroidOverscroll.kt:584)
       at androidx.compose.foundation.AndroidOverscrollKt$StretchOverscrollNonClippingLayer$2.invoke(AndroidOverscroll.kt:583)
       at androidx.compose.ui.layout.LayoutModifierImpl.measure-3p2s80s(LayoutModifier.kt:291)
       at androidx.compose.ui.node.LayoutModifierNodeCoordinator$LookaheadDelegateForLayoutModifierNode.measure-BRTryo0(LayoutModifierNodeCoordinator.kt:64)
       at androidx.compose.foundation.AndroidOverscrollKt$StretchOverscrollNonClippingLayer$1.invoke-3p2s80s(AndroidOverscroll.kt:568)
       at androidx.compose.foundation.AndroidOverscrollKt$StretchOverscrollNonClippingLayer$1.invoke(AndroidOverscroll.kt:567)
       at androidx.compose.ui.layout.LayoutModifierImpl.measure-3p2s80s(LayoutModifier.kt:291)
       at androidx.compose.ui.node.LayoutModifierNodeCoordinator$LookaheadDelegateForLayoutModifierNode.measure-BRTryo0(LayoutModifierNodeCoordinator.kt:64)
       at androidx.compose.ui.graphics.SimpleGraphicsLayerModifier.measure-3p2s80s(GraphicsLayerModifier.kt:646)
       at androidx.compose.ui.node.LayoutModifierNodeCoordinator$LookaheadDelegateForLayoutModifierNode.measure-BRTryo0(LayoutModifierNodeCoordinator.kt:64)
       at androidx.compose.foundation.layout.FillNode.measure-3p2s80s(Size.kt:699)
       at androidx.compose.ui.node.LayoutModifierNodeCoordinator$LookaheadDelegateForLayoutModifierNode.measure-BRTryo0(LayoutModifierNodeCoordinator.kt:64)
       at androidx.compose.foundation.layout.PaddingNode.measure-3p2s80s(Padding.kt:397)
       at androidx.compose.ui.node.LayoutModifierNodeCoordinator$LookaheadDelegateForLayoutModifierNode.measure-BRTryo0(LayoutModifierNodeCoordinator.kt:64)
       at androidx.compose.ui.node.LayoutNodeLayoutDelegate$performLookaheadMeasure$1.invoke(LayoutNodeLayoutDelegate.kt:1622)
       at androidx.compose.ui.node.LayoutNodeLayoutDelegate$performLookaheadMeasure$1.invoke(LayoutNodeLayoutDelegate.kt:1621)
       at androidx.compose.runtime.snapshots.Snapshot$Companion.observe(Snapshot.kt:2303)
       at androidx.compose.runtime.snapshots.SnapshotStateObserver$ObservedScopeMap.observe(SnapshotStateObserver.kt:496)
       at androidx.compose.runtime.snapshots.SnapshotStateObserver.observeReads(SnapshotStateObserver.kt:256)
       at androidx.compose.ui.node.OwnerSnapshotObserver.observeReads$ui_release(OwnerSnapshotObserver.kt:133)
       at androidx.compose.ui.node.OwnerSnapshotObserver.observeMeasureSnapshotReads$ui_release(OwnerSnapshotObserver.kt:111)
2023-11-20 20:43:42.173  2007-2007  AndroidRuntime          com.example.app             E      at androidx.compose.ui.node.OwnerSnapshotObserver.observeMeasureSnapshotReads$ui_release$default(OwnerSnapshotObserver.kt:105)
       at androidx.compose.ui.node.LayoutNodeLayoutDelegate.performLookaheadMeasure-BRTryo0(LayoutNodeLayoutDelegate.kt:1621)
       at androidx.compose.ui.node.LayoutNodeLayoutDelegate.access$performLookaheadMeasure-BRTryo0(LayoutNodeLayoutDelegate.kt:36)
       at androidx.compose.ui.node.LayoutNodeLayoutDelegate$LookaheadPassDelegate.remeasure-BRTryo0(LayoutNodeLayoutDelegate.kt:1289)
       at androidx.compose.ui.node.LayoutNode.lookaheadRemeasure-_Sx5XlM$ui_release(LayoutNode.kt:1126)
       at androidx.compose.ui.node.LayoutNode.lookaheadRemeasure-_Sx5XlM$ui_release$default(LayoutNode.kt:1120)
       at androidx.compose.ui.node.MeasureAndLayoutDelegate.doLookaheadRemeasure-sdFAvZA(MeasureAndLayoutDelegate.kt:313)
       at androidx.compose.ui.node.MeasureAndLayoutDelegate.remeasureAndRelayoutIfNeeded(MeasureAndLayoutDelegate.kt:478)
       at androidx.compose.ui.node.MeasureAndLayoutDelegate.remeasureAndRelayoutIfNeeded$default(MeasureAndLayoutDelegate.kt:461)
       at androidx.compose.ui.node.MeasureAndLayoutDelegate.measureAndLayout(MeasureAndLayoutDelegate.kt:354)
       at androidx.compose.ui.platform.AndroidComposeView.measureAndLayout(AndroidComposeView.android.kt:969)
       at androidx.compose.ui.node.Owner.measureAndLayout$default(Owner.kt:230)
       at androidx.compose.ui.platform.AndroidComposeView.dispatchDraw(AndroidComposeView.android.kt:1222)
       at android.view.View.draw(View.java:23892)
       at android.view.View.updateDisplayListIfDirty(View.java:22756)
       at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:4540)
       at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:4513)
       at android.view.View.updateDisplayListIfDirty(View.java:22712)
       at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:4540)
       at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:4513)
       at android.view.View.updateDisplayListIfDirty(View.java:22712)
       at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:4540)
       at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:4513)
       at android.view.View.updateDisplayListIfDirty(View.java:22712)
       at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:4540)
       at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:4513)
       at android.view.View.updateDisplayListIfDirty(View.java:22712)
       at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:4540)
       at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:4513)
       at android.view.View.updateDisplayListIfDirty(View.java:22712)
       at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:4540)
       at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:4513)
       at android.view.View.updateDisplayListIfDirty(View.java:22712)
       at android.view.ThreadedRenderer.updateViewTreeDisplayList(ThreadedRenderer.java:694)
       at android.view.ThreadedRenderer.updateRootDisplayList(ThreadedRenderer.java:700)
       at android.view.ThreadedRenderer.draw(ThreadedRenderer.java:798)
       at android.view.ViewRootImpl.draw(ViewRootImpl.java:4939)
       at android.view.ViewRootImpl.performDraw(ViewRootImpl.java:4643)
       at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:3822)
       at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:2465)
       at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:9305)
       at android.view.Choreographer$CallbackRecord.run(Choreographer.java:1339)
       at android.view.Choreographer$CallbackRecord.run(Choreographer.java:1348)
       at android.view.Choreographer.doCallbacks(Choreographer.java:952)
       at android.view.Choreographer.doFrame(Choreographer.java:882)
       at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:1322)
       at android.os.Handler.handleCallback(Handler.java:958)
       at android.os.Handler.dispatchMessage(Handler.java:99)
       at android.os.Looper.loopOnce(Looper.java:205)
       at android.os.Looper.loop(Looper.java:294)
       at android.app.ActivityThread.main(ActivityThread.java:8177)
2023-11-20 20:43:42.173  2007-2007  AndroidRuntime          com.example.app             E      at java.lang.reflect.Method.invoke(Native Method)
       at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:552)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:971)
2023-11-20 20:43:42.212  1027-1826  OneSearchS...stProvider com...le.android.apps.nexuslauncher  E  Failed to fetch suggestions from AppSearch, fallback to AGA
   java.util.concurrent.CompletionException: java.util.NoSuchElementException: No value present
       at java.util.concurrent.CompletableFuture.encodeThrowable(CompletableFuture.java:308)
       at java.util.concurrent.CompletableFuture.completeThrowable(CompletableFuture.java:323)
       at java.util.concurrent.CompletableFuture$UniAccept.tryFire(CompletableFuture.java:684)
       at java.util.concurrent.CompletableFuture.postComplete(CompletableFuture.java:486)
       at java.util.concurrent.CompletableFuture.completeExceptionally(CompletableFuture.java:2138)
       at com.google.android.apps.nexuslauncher.allapps.H0.onResult(Unknown Source:59)
       at android.app.appsearch.SearchSessionUtil$1.lambda$onResult$0(SearchSessionUtil.java:129)
       at android.app.appsearch.SearchSessionUtil$1.$r8$lambda$_nlk9WiPjSfaAsqKYmp0aPvSRC0(SearchSessionUtil.java:1)
       at android.app.appsearch.SearchSessionUtil$1$$ExternalSyntheticLambda0.run(R8$$SyntheticClass:13)
       at android.os.Handler.handleCallback(Handler.java:958)
       at android.os.Handler.dispatchMessage(Handler.java:99)
       at android.os.Looper.loopOnce(Looper.java:205)
       at android.os.Looper.loop(Looper.java:294)
       at android.os.HandlerThread.run(HandlerThread.java:67)
   Caused by: java.util.NoSuchElementException: No value present
       at java.util.Optional.get(Optional.java:144)
       at com.google.android.apps.nexuslauncher.allapps.H0.onResult(Unknown Source:16)
       at android.app.appsearch.SearchSessionUtil$1.lambda$onResult$0(SearchSessionUtil.java:129)
       at android.app.appsearch.SearchSessionUtil$1.$r8$lambda$_nlk9WiPjSfaAsqKYmp0aPvSRC0(SearchSessionUtil.java:1)
       at android.app.appsearch.SearchSessionUtil$1$$ExternalSyntheticLambda0.run(R8$$SyntheticClass:13)
       at android.os.Handler.handleCallback(Handler.java:958)
       at android.os.Handler.dispatchMessage(Handler.java:99)
       at android.os.Looper.loopOnce(Looper.java:205)
       at android.os.Looper.loop(Looper.java:294)
       at android.os.HandlerThread.run(HandlerThread.java:67)
pnewell commented 1 year ago

Scratch this, is a bug in the alpha of material3 I was using