jerboa icon indicating copy to clipboard operation
jerboa copied to clipboard

Stuttering scrolling on profile

Open nilsonsales opened this issue 3 years ago • 3 comments

Jerboa Version 0.0.38

Android version + phone Android 13, Galaxy S23

Describe the bug Suddenly changing the scrolling direction on profile makes the screen stutters for a bit before behaving correctly. It's more noticeable if you're scrolling fast.

To Reproduce Steps to reproduce the behavior:

  1. Go to any Profile
  2. Go to Comments
  3. Pull the screen to scroll down
  4. While the view is scrolling, scroll up

https://github.com/dessalines/jerboa/assets/3781478/51beab75-0476-412d-9258-1d283f8a4d9d

nilsonsales avatar Jul 11 '23 00:07 nilsonsales

This has something to do with the HorizontalPager in a Scafford with a collapsing TopAppBar. I'm able to reproduce it using basic components like

val scrollBehavior = TopAppBarDefaults.enterAlwaysScrollBehavior(rememberTopAppBarState())
Scaffold(
	modifier = Modifier.nestedScroll(scrollBehavior.nestedScrollConnection),
	topBar = {
		TopAppBar(
			scrollBehavior = scrollBehavior,
			title = {
				Text("Hello")
			},
		)
	},
	content = {
		Column(
			modifier = Modifier.padding(it),
		) {
			val pagerState = rememberPagerState { 3 }
			HorizontalPager(
				state = pagerState,
				modifier = Modifier.fillMaxSize(),
			) {
				val listState = rememberLazyListState()

				LazyColumn(
					state = listState,
					modifier = Modifier
						.fillMaxSize()
				) {
					items(200) {
						Text("Hello${it}")
					}
				}
			}
		}
	},
)

Screen_recording_20230719_190807.webm

If you take away either the HorizontalPager or remove the collapsible behavior of the TopAppBar it works fine with no freeze/stutter.

yate avatar Jul 19 '23 23:07 yate

@yate your hint about the collapsible TopAppBar was helpful. Pinning the TopAppBar seems to help avoid a large number of recompositions on other activities as well.

camporter avatar Aug 13 '23 02:08 camporter

Seems like a jetpack compose issue. If someone wants to work on this, I can re-open.

dessalines avatar Feb 10 '24 23:02 dessalines