Status Update
Comments
ma...@gmail.com <ma...@gmail.com> #2
Branch: androidx-main
commit a330c0d3bcdd41326f37968a60e6084ad4a2e32c
Author: Chet Haase <chet@google.com>
Date: Wed Jul 05 07:26:46 2023
Convert APIs using PointF to use Float instead
PointF is a convenient mechanism for passing around x.y values
representing 2D points. But there are downsides, including:
- Converting to PointF: You may not have the data in PointF form
to begin with, so using an API which takes PointF requires converting
the data to that form (including allocating a PointF object every time)
- Mutability: Point structures can be mutated internally, causing
unpredictability in what that mutation means. Should the library
react to those changes? Ignore them? Do defensive copies (requiring
even more allocations)? Using primitive types like Float make the
behavior more obvious (by making the data inherently immutable).
- Allocations: Whenever we use object types, there are necessarily
allocations on the Java heap for them. This puts pressure on the GC
at both allocation and collection time. Given the amount of points
being passed around (especially at morph creation time, when curves
are being split and created), this causes a lot of PointF objects to
be allocated (even temporarily). Using Float avoids that problem.
Also fixed bug with unclosed paths causing discontinuity at the
start/end point.
Bug: 276466399
Bug: 290254314
Test: integration and unit tests pass
Relnote: PointF parameters changed to Float pairs
Change-Id: Id4705d27c7be31b26ade8186b99fffe2e2f8450e
M graphics/graphics-shapes/api/current.txt
M graphics/graphics-shapes/api/restricted_current.txt
M graphics/graphics-shapes/src/androidTest/java/androidx/graphics/shapes/CubicShapeTest.kt
M graphics/graphics-shapes/src/androidTest/java/androidx/graphics/shapes/CubicTest.kt
M graphics/graphics-shapes/src/androidTest/java/androidx/graphics/shapes/PolygonMeasureTest.kt
M graphics/graphics-shapes/src/androidTest/java/androidx/graphics/shapes/PolygonTest.kt
M graphics/graphics-shapes/src/androidTest/java/androidx/graphics/shapes/RoundedPolygonTest.kt
M graphics/graphics-shapes/src/androidTest/java/androidx/graphics/shapes/ShapesTest.kt
M graphics/graphics-shapes/src/androidTest/java/androidx/graphics/shapes/TestUtils.kt
M graphics/graphics-shapes/src/main/java/androidx/graphics/shapes/Cubic.kt
M graphics/graphics-shapes/src/main/java/androidx/graphics/shapes/CubicShape.kt
M graphics/graphics-shapes/src/main/java/androidx/graphics/shapes/FeatureMapping.kt
M graphics/graphics-shapes/src/main/java/androidx/graphics/shapes/FloatMapping.kt
M graphics/graphics-shapes/src/main/java/androidx/graphics/shapes/Morph.kt
M graphics/graphics-shapes/src/main/java/androidx/graphics/shapes/PolygonMeasure.kt
M graphics/graphics-shapes/src/main/java/androidx/graphics/shapes/RoundedPolygon.kt
M graphics/graphics-shapes/src/main/java/androidx/graphics/shapes/Shapes.kt
M graphics/graphics-shapes/src/main/java/androidx/graphics/shapes/Utils.kt
M graphics/integration-tests/testapp-compose/src/main/java/androidx/graphics/shapes/testcompose/DebugDraw.kt
M graphics/integration-tests/testapp-compose/src/main/java/androidx/graphics/shapes/testcompose/ShapeEditor.kt
M graphics/integration-tests/testapp/src/main/java/androidx/graphics/shapes/test/MaterialShapes.kt
jo...@google.com <jo...@google.com> #3
se...@google.com <se...@google.com>
ap...@google.com <ap...@google.com> #4
The following release(s) address this bug.It is possible this bug has only been partially addressed:
androidx.graphics:graphics-shapes:1.0.0-alpha04
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):