Bug P4
Status Update
Comments
ch...@google.com <ch...@google.com>
jo...@google.com <jo...@google.com>
le...@google.com <le...@google.com>
ki...@gmail.com <ki...@gmail.com> #2
Automatic regression verification started for measurement:
ChromiumPerf/android-pixel6-perf/system_health.memory_mobile/memory:chrome:all_processes:reported_by_chrome:malloc:max_committed_size_avg/browse_news
Verification workflow id: projects/62121018386/locations/us-central1/workflows/sandwich-verification-workflow-prod/executions/f430dab5-4642-48dd-a3d6-a50904c1d68e
ChromiumPerf/android-pixel6-perf/system_health.memory_mobile/memory:chrome:all_processes:reported_by_chrome:malloc:max_committed_size_avg/browse_news
Verification workflow id: projects/62121018386/locations/us-central1/workflows/sandwich-verification-workflow-prod/executions/f430dab5-4642-48dd-a3d6-a50904c1d68e
ji...@gmail.com <ji...@gmail.com> #3
🥪 Regression verification projects/62121018386/locations/us-central1/workflows/sandwich-verification-workflow-prod/executions/f430dab5-4642-48dd-a3d6-a50904c1d68e job 169445e4610000 for test: ChromiumPerf/android-pixel6-perf/system_health.memory_mobile/memory:chrome:all_processes:reported_by_chrome:malloc:max_committed_size_avg/browse_news
did NOT reproduce the regression with statistic: {'control_median': 135405568, 'lower': -2.0340368398504394, 'p_value': 0.42795460671186447, 'treatment_median': 135325696, 'upper': 1.0165479548803757}.
Issue closed.
did NOT reproduce the regression with statistic: {'control_median': 135405568, 'lower': -2.0340368398504394, 'p_value': 0.42795460671186447, 'treatment_median': 135325696, 'upper': 1.0165479548803757}.
Issue closed.
Description
Jetpack Compose component(s) used: HorizontalPager
Android Studio Build:
Android Studio Jellyfish | 2023.3.1 RC 2
Build #AI-233.14808.21.2331.11678080, built on April 5, 2024
Kotlin version: 2.0.0
Steps to Reproduce or Code Sample to Reproduce:
The issue, TL;DR, the Pager snaps to spacing and depending on placement also treats it as an item. Creates incorrect placements, updates and sometimes jankyness.
Trying to build a Horizontal Pager width pages being a desired width (200.dp), fixed spacing between (56.dp), snap on center and then also have the first and last item ALSO center; i.e use horizontal content padding to place it in the center (screenwidth/2 - page/2 + pageSpacing).
(It would be great if the SnapPosition.Center could take an argument to allow that, but that's beside the point really)
Issues:
* The last item is regarded as the content spacing
* The first items does not show correctly at all and first page is never shown fully
* Sometimes the pager snaps center on the pageSpacing and not the pages
* Because the last item is the space, the callbackFlow reports the shown page to be one less; and perhaps more after we've gone past a few page spacings.
* Have experienced issues with both/only pageSpacing and contentPadding
The code below is a bit jumpy to indicate that I've tried approaches both where itemSpacing is used and eliminated (handled manually "on the page").
```
var horizontalPadding: Dp by remember { mutableStateOf(0.dp) }
/// ...
// Parent Container modifier
.onPlaced {
if (it.size.width == 0) return@onPlaced
val screenWidth = with(density) { it.size.width.toDp() }
horizontalPadding = (screenWidth / 2) - 100.dp + 56.dp
}
// ...
val pagerState = rememberPagerState(initialPage = state.dayWheels.lastIndex) { state.dayWheels.count() }
// ...
var dateText: String by remember { mutableStateOf("") }
LaunchedEffect(Unit) {
snapshotFlow { pagerState.currentPage }.collect { page ->
val day = state.dayWheels[page].date
dateText = "($page)" + DateFormatter.formatTrainingDay(day) + " - ${state.dayWheels[page].score}"
actions.showSessionsForDay(day) // Updates column/items below wheel
}
}
Text(text = dateText)
if (horizontalPadding.value > 0F)
HorizontalPager(
modifier = Modifier
.fillMaxWidth()
.background(Color.DarkGray),
key = { state.dayWheels[it].date.toString() },
state = pagerState,
// 1. pageSize = PageSize.Fixed((200 + 28 * 2).dp),
// 2. pageSize = PageSize.Fixed(200.dp),
pageSpacing = 56.dp,
snapPosition = SnapPosition.Center,
contentPadding = PaddingValues(horizontal = horizontalPadding)
) { page ->
val actualPage = page.coerceIn(0, state.dayWheels.lastIndex)
val wheelDay = remember { state.dayWheels[actualPage] }
Timber.d("Pager: ($page->$actualPage) ${wheelDay.let { "Wheel(${it.date}, ${it.score}, ${
ScoreWheel(
modifier = Modifier
.height(200.dp)
.border(1.dp, Color.Black)
(based on approach) // .padding(horizontal = 28.dp)
.border(1.dp, Color.Yellow),
stuff = wheelDay.stuff
)
}
```
At the time of reporting I am unable to reproduce intermittent states where the page spacing gets centered, but that has also happened. But as visible in screenshots and the video the content padding on the end is regarded as an item. And in the image of two unfilled wheels - they are empty because the items/pages are not properly regarded as "pages shown". (`actions.showSessionsForDay(day)` in the callbackFlow also updates the state so that the model passed in to the wheel is set to start an animation; which also )