ui: Fix recompose loop during scroll (2fps vertical)
Focus requesters were stored in snapshot-state maps and written during composition of every list item: each write invalidated the reading scope, which recomposed the (whole page of) items, wrote again, ... This feedback loop is why vertical scrolling ran at ~2fps on the TV while the same build scrolled fine in the emulator's short bursts. Plain HashMaps kill the loop - focus handling needs no recomposition.
This commit is contained in:
parent
f7273121ae
commit
5ea1ca5124
2 changed files with 2 additions and 2 deletions
|
|
@ -237,7 +237,7 @@ private fun ChannelCardRow(
|
|||
onLeftAtStart: () -> Unit,
|
||||
) {
|
||||
val rowState = androidx.compose.foundation.lazy.rememberLazyListState()
|
||||
val focusRequesters = remember { mutableMapOf<Int, FocusRequester>() }
|
||||
val focusRequesters = remember { HashMap<Int, FocusRequester>() }
|
||||
var focusedIndex by remember { mutableIntStateOf(-1) }
|
||||
var clickedIndex by remember { mutableIntStateOf(-1) }
|
||||
|
||||
|
|
|
|||
|
|
@ -260,7 +260,7 @@ fun FocusScrollRow(
|
|||
afterItem: @Composable (index: Int, video: VideoDto) -> Unit = { _, _ -> },
|
||||
) {
|
||||
val rowState = rememberLazyListState()
|
||||
val focusRequesters = remember { androidx.compose.runtime.mutableStateMapOf<Int, FocusRequester>() }
|
||||
val focusRequesters = remember { HashMap<Int, FocusRequester>() }
|
||||
var focusedIndex by remember { androidx.compose.runtime.mutableStateOf(-1) }
|
||||
// BACK from playback: scroll to + focus the card that was opened (user request).
|
||||
LaunchedEffect(restoreToken) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue