Status Update
Comments
ma...@gmail.com <ma...@gmail.com> #2
Project: platform/frameworks/support
Branch: androidx-main
Author: Louis Pullen-Freilich <
Link:
Adds OverscrollEffect#withoutDrawing and OverscrollEffect#withoutEventHandling
Expand for full commit details
Adds OverscrollEffect#withoutDrawing and OverscrollEffect#withoutEventHandling
These APIs allow overscroll to have events dispatched to it by one component, and rendered in a separate component.
Fixes: b/266550551
Fixes: b/204650733
Fixes: b/255554340
Fixes: b/229537244
Test: OverscrollTest
Relnote: "Adds OverscrollEffect#withoutDrawing and OverscrollEffect#withoutEventHandling APIs - these APIs create a wrapped instance of the provided overscroll effect that doesn't draw / handle events respectively, which allows for rendering overscroll in a separate component from the component that is dispatching events. For example, disabling drawing the overscroll inside a lazy list, and then drawing the overscroll separately on top / elsewhere."
Change-Id: Idbb3d91546b49c1987a041f959bce4b2b09a9f61
Files:
- M
compose/foundation/foundation/api/current.txt
- M
compose/foundation/foundation/api/restricted_current.txt
- M
compose/foundation/foundation/integration-tests/foundation-demos/src/main/java/androidx/compose/foundation/demos/OverscrollDemo.kt
- M
compose/foundation/foundation/samples/src/main/java/androidx/compose/foundation/samples/OverscrollSample.kt
- M
compose/foundation/foundation/src/androidInstrumentedTest/kotlin/androidx/compose/foundation/OverscrollTest.kt
- M
compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/Overscroll.kt
Hash: f64e25b7a473c757d080521e7dd97b3f6670f60d
Date: Fri Nov 01 18:43:56 2024
jo...@google.com <jo...@google.com> #3
The following release(s) address this bug.It is possible this bug has only been partially addressed:
androidx.compose.foundation:foundation:1.8.0-alpha06
androidx.compose.foundation:foundation-android:1.8.0-alpha06
androidx.compose.foundation:foundation-jvmstubs:1.8.0-alpha06
androidx.compose.foundation:foundation-linuxx64stubs:1.8.0-alpha06
se...@google.com <se...@google.com>
ap...@google.com <ap...@google.com> #4
Branch: androidx-main
commit 4600d819db8a295aa6168f523aac5be4ec4f26ba
Author: Jossi Wolf <jossiwolf@google.com>
Date: Thu Aug 17 14:06:25 2023
[M3] Optimize BottomSheetScaffold layout
Moves placement-related reads into placement. This also fixes
potential issues with BottomSheetScaffold in a LookaheadLayout
where we would attempt to access the AnchoredDraggableState's
offset in the lookahead measure pass before it was initialized.
Test: Manual testing, existing tests pass.
Relnote: "Fixed an issue where some components using Subcomposition
(e.g. BottomSheetScaffold) inside a Scaffold inside a LookaheadScope
were attempting to read their size too early."
Fixes: 295536718
Change-Id: I297b401ce6fd3b01ac5a2fba5fd617f66bc34550
M compose/material3/material3/src/commonMain/kotlin/androidx/compose/material3/BottomSheetScaffold.kt
ap...@google.com <ap...@google.com> #5
Branch: androidx-main
commit 9b481ae2c6b79eead3c86093fcd9abe102a04878
Author: Jossi Wolf <jossiwolf@google.com>
Date: Wed Aug 16 18:45:22 2023
[M3] Move Scaffold subcomposition to measure
We were previously subcomposing and measuring in placement. When performing a lookahead place pass, we would then perform lookahead measure + lookahead place on the children before the main place pass. This meant that e.g. onSizeChanged would only report the node's size after lookahead place, in which a user or component might rely on the data.
While we have to revisit the overall pattern in the Lookahead world, this addresses the issue for Material Scaffold users.
Test: scaffold_onSizeChanged_calledBeforeLookaheadPlace, manually tested Material Catalog app
Relnote: Fixed an issue where some components using Subcomposition (e.g. BottomSheetScaffold) inside a Scaffold inside a LookaheadScope were attempting to read their size too early.
Fixes: 295536718
Change-Id: I871f1f655d0bf504490a040ec793b1b07ce195e4
M compose/material3/material3/src/androidAndroidTest/kotlin/androidx/compose/material3/ScaffoldTest.kt
M compose/material3/material3/src/commonMain/kotlin/androidx/compose/material3/Scaffold.kt
se...@google.com <se...@google.com> #6
Thank you for landing this fix, Jossi!
ro...@veeva.com <ro...@veeva.com> #7
This is marked as fixed but doesn't seem to be part of
jo...@google.com <jo...@google.com> #8
We mark issues as fixed as soon as the fix is merged, not when the fix is included in a release. We will provide updates on this issue once the fix gets released.
While Compose releases are scheduled for roughly every two weeks, we don't commit to certain release times. Appreciate the patience!
pr...@google.com <pr...@google.com> #9
The following release(s) address this bug.It is possible this bug has only been partially addressed:
androidx.compose.material3:material3:1.2.0-alpha07
androidx.compose.material3:material3-android:1.2.0-alpha07
64...@gmail.com <64...@gmail.com> #10
the sheet doesn't crash in the alpha07
but it directly starts in a half-expanded state (?!). i didn't have the chance to test if it's something particular to my code, but this was not happening on alpha04
and previous versions.
jo...@google.com <jo...@google.com> #11
#10, please file a new issue with an isolated repro so we can take a look.
64...@gmail.com <64...@gmail.com> #12
#11, sure, here's a sample code to reproduce it:
class MainActivity : ComponentActivity() {
@OptIn(ExperimentalMaterial3Api::class)
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContent {
val scaffoldState = rememberBottomSheetScaffoldState(
bottomSheetState = rememberStandardBottomSheetState(
initialValue = SheetValue.Hidden,
skipHiddenState = false
)
)
val scope = rememberCoroutineScope()
BottomSheetTheme {
BottomSheetScaffold(
scaffoldState = scaffoldState,
sheetContent = {
Text("This is the sheet")
}
) {
Button(onClick = {scope.launch {
if (scaffoldState.bottomSheetState.isVisible) {
scaffoldState.bottomSheetState.hide()
} else {
scaffoldState.bottomSheetState.expand()
}
}}) {
Text("Expand/Collapse")
}
}
}
}
}
}
while at it, it would be great to be able to switch the current StandardBottomSheet
for the ModalBottomSheet
(i created a separate issue for it:
jo...@google.com <jo...@google.com>
je...@gmail.com <je...@gmail.com> #13
I hope this fix is not included on androidx.compose.material3:material3:1.2.0-alpha08 also ?
I am facing the similar crash when i configure skipPartiallyExpanded as true. If i set the flag value to false, everything looks good. But, I want the bottom sheet to be hidden for my usecase and i don't want the partial expanded option too .
val scaffoldState = rememberBottomSheetScaffoldState(
bottomSheetState = SheetState(
skipPartiallyExpanded = true,
density = LocalDensity.current,
)
)
BottomSheetScaffold(
modifier = Modifier.fillMaxWidth(),
scaffoldState = scaffoldState,
sheetShape = RoundedCornerShape(topStart = 10.dp, topEnd = 10.dp),
sheetContent = {
Spacer(modifier = Modifier.height(1.dp))
// Sheet content
}
}
) {
Scaffold { // Page conent. }
}
Thanks in advance for looking out this one .
Stack trace:
java.lang.IllegalStateException: The offset was read before being initialized. Did you access the offset in a phase before layout, like effects or composition?
at androidx.compose.material3.AnchoredDraggableState.requireOffset(AnchoredDraggable.kt:345)
at androidx.compose.material3.SheetState.requireOffset(SheetDefaults.kt:166)
at androidx.compose.material3.BottomSheetScaffoldKt$BottomSheetScaffold$3$1.invoke(BottomSheetScaffold.kt:128)
at androidx.compose.material3.BottomSheetScaffoldKt$BottomSheetScaffold$3$1.invoke(BottomSheetScaffold.kt:128)
at androidx.compose.material3.BottomSheetScaffoldKt$BottomSheetScaffoldLayout$2$1$1.invoke(BottomSheetScaffold.kt:363)
at androidx.compose.material3.BottomSheetScaffoldKt$BottomSheetScaffoldLayout$2$1$1.invoke(BottomSheetScaffold.kt:362)
at androidx.compose.ui.layout.MeasureScope$layout$1.placeChildren(MeasureScope.kt:70)
at androidx.compose.ui.layout.LayoutNodeSubcompositionsState$createMeasurePolicy$1$measure-3p2s80s$$inlined$createMeasureResult$2.placeChildren(SubcomposeLayout.kt:951)
at androidx.compose.ui.node.LayoutNodeLayoutDelegate$LookaheadPassDelegate$layoutChildren$1.invoke(LayoutNodeLayoutDelegate.kt:1093)
at androidx.compose.ui.node.LayoutNodeLayoutDelegate$LookaheadPassDelegate$layoutChildren$1.invoke(LayoutNodeLayoutDelegate.kt:1088)
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.observeLayoutSnapshotReads$ui_release(OwnerSnapshotObserver.kt:81)
at androidx.compose.ui.node.OwnerSnapshotObserver.observeLayoutSnapshotReads$ui_release$default(OwnerSnapshotObserver.kt:75)
at androidx.compose.ui.node.LayoutNodeLayoutDelegate$LookaheadPassDelegate.layoutChildren(LayoutNodeLayoutDelegate.kt:1088)
at androidx.compose.ui.node.LayoutNodeLayoutDelegate$LookaheadPassDelegate.onNodePlaced$ui_release(LayoutNodeLayoutDelegate.kt:1470)
at androidx.compose.ui.node.InnerNodeCoordinator$LookaheadDelegateImpl.placeChildren(InnerNodeCoordinator.kt:97)
at androidx.compose.ui.node.LookaheadDelegate.placeAt-f8xVGno(LookaheadDelegate.kt:156)
at androidx.compose.ui.layout.Placeable.access$placeAt-f8xVGno(Placeable.kt:34)
at androidx.compose.ui.layout.Placeable$PlacementScope.place-70tqf50(Placeable.kt:463)
at androidx.compose.ui.layout.Placeable$PlacementScope.place-70tqf50$default(Placeable.kt:231)
at androidx.compose.ui.node.LayoutNodeLayoutDelegate$LookaheadPassDelegate$placeAt$1.invoke(LayoutNodeLayoutDelegate.kt:1317)
at androidx.compose.ui.node.LayoutNodeLayoutDelegate$LookaheadPassDelegate$placeAt$1.invoke(LayoutNodeLayoutDelegate.kt:1315)
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.observeLayoutModifierSnapshotReads$ui_release(OwnerSnapshotObserver.kt:96)
at androidx.compose.ui.node.OwnerSnapshotObserver.observeLayoutModifierSnapshotReads$ui_release$default(OwnerSnapshotObserver.kt:90)
at androidx.compose.ui.node.LayoutNodeLayoutDelegate$LookaheadPassDelegate.placeAt-f8xVGno(LayoutNodeLayoutDelegate.kt:1315)
at androidx.compose.ui.layout.Placeable.access$placeAt-f8xVGno(Placeable.kt:34)
at androidx.compose.ui.layout.Placeable$PlacementScope.place(Placeable.kt:460)
sh...@gmail.com <sh...@gmail.com> #14
It still happens in androidx.compose.material3:material3:1.2.0-beta01
val scaffoldState = rememberBottomSheetScaffoldState(
bottomSheetState = rememberStandardBottomSheetState(
initialValue = SheetValue.Hidden,
skipHiddenState = true,
),
)
BottomSheetScaffold(
scaffoldState = scaffoldState,
sheetContent = {
Text(
modifier = Modifier
.fillMaxWidth()
.padding(8.dp),
text = "This is Flexible Bottom Sheet",
textAlign = TextAlign.Center,
color = Color.White,
style = MaterialTheme.typography.bodySmall
)
},
sheetPeekHeight = 0.dp,
contentColor = BottomSheetBackgroundColor,
modifier = Modifier.fillMaxSize(),
) {
Text("Hello")
}
LaunchedEffect(scaffoldState.bottomSheetState) {
if (!scaffoldState.bottomSheetState.isVisible) {
onDismiss()
}
}
se...@google.com <se...@google.com>
se...@google.com <se...@google.com> #15
The crash you are seeing appears to be intended. If you set skipHiddenState to true, the initial value must instead be partially expanded or expanded.
an...@gmail.com <an...@gmail.com> #16
I still get crash when initializing state like this:
val scaffoldState = rememberBottomSheetScaffoldState(
bottomSheetState = SheetState(
skipPartiallyExpanded = true,
density = LocalDensity.current,
)
)
Using
androidx.compose.material3:material3-android:1.2.0
al...@gmail.com <al...@gmail.com> #17
at androidx.compose.material3.AnchoredDraggableState.requireOffset(AnchoredDraggable.kt:344)
at androidx.compose.material3.SheetState.requireOffset(SheetDefaults.kt:164)
at androidx.compose.material3.BottomSheetScaffoldKt$BottomSheetScaffold$3$1.invoke(BottomSheetScaffold.kt:131)
ph...@gmail.com <ph...@gmail.com> #18
at androidx.compose.material.SwipeableV2State.requireOffset(SwipeableV2.kt:208)
at androidx.compose.material.BottomSheetState.requireOffset(BottomSheetScaffold.kt:159)
at androidx.compose.material.BottomSheetScaffoldKt$BottomSheetScaffold$child$1$3$1.invoke(BottomSheetScaffold.kt:369)
at androidx.compose.material.BottomSheetScaffoldKt$BottomSheetScaffold$child$1$3$1.invoke(BottomSheetScaffold.kt:369)
at androidx.compose.material.BottomSheetScaffoldKt$BottomSheetScaffoldLayout$1$1.invoke-0kLqBqw(BottomSheetScaffold.kt:495)
at androidx.compose.material.BottomSheetScaffoldKt$BottomSheetScaffoldLayout$1$1.invoke(BottomSheetScaffold.kt:488)
at androidx.compose.ui.layout.LayoutNodeSubcompositionsState$createMeasurePolicy$1.measure-3p2s80s(SubcomposeLayout.kt:598)
at androidx.compose.ui.node.InnerNodeCoordinator.measure-BRTryo0(InnerNodeCoordinator.kt:103)
at androidx.compose.ui.node.LayoutNodeLayoutDelegate$performMeasure$2.invoke(LayoutNodeLayoutDelegate.kt:1090)
at androidx.compose.ui.node.LayoutNodeLayoutDelegate$performMeasure$2.invoke(LayoutNodeLayoutDelegate.kt:1086)
at androidx.compose.runtime.snapshots.Snapshot$Companion.observe(Snapshot.kt:2200)
Compose Version: 1.2.1
androidx-compose-material3 = { group = "androidx.compose.material3", name = "material3", version.ref = "androidxComposeMaterial3" }
I still get this error. Please help me
Description
Jetpack Compose version: 1.6.0-alpha03
Jetpack Compose component used: material3
Android Studio Build: Android Studio Hedgehog | 2023.1.1 Canary 15
Kotlin version: 1.9.0
After upgrading from androidx.compose.material3:material3-android:1.2.0-alpha04 to -alpha05 a BottomSheetScaffold crashes when contained in a NavHost in SwipeableV2State code
Steps to Reproduce or Code Sample to Reproduce:
1. Create a project with this content or used the attached sample
and these dependencies
Everything works as expected
2.
Change
"androidx.compose.material3:material3-android:1.2.0-alpha04"
to"androidx.compose.material3:material3-android:1.2.0-alpha05"
3.
Observe the app immediately crash
Stack trace (if applicable):