accompanist icon indicating copy to clipboard operation
accompanist copied to clipboard

[Pager] Avoid Recomposing Page When the Page is invisible

Open OXeu opened this issue 3 years ago • 3 comments

Description If there is 3 screens totally, when we scroll to the 3rd(index:2) page, the 1st(index:0) page will be destroyed ,and when we ready to scroll to the 2nd(index:1) page, the 1st page would recompose which makes the UI thread blocked a few frames, especially when the page is complex such as the page with a LazyColumn with much complex items. And I could not find any method to avoid the page that far away from the current page recomposing.

Expected behavior Is there any posibility to cache all the pages instead of the behavior that recycling the item and recomposing the item as the LazyRow or LazyColumn. Recompose the page is expensive!

OXeu avatar Aug 14 '22 02:08 OXeu

What you are observing is the intendent behaviour. Pager is built on top of the LazyRow/LazyColumn. LazyRow/LazyColumn do not support this feature yet. I think the offscreenPageLimit is what you are looking for, but unfortunately it's not ready so far. You can track the progress in this issue: https://github.com/google/accompanist/issues/899

dmitrytavpeko avatar Aug 14 '22 12:08 dmitrytavpeko

What you are observing is the intendent behaviour. Pager is built on top of the LazyRow/LazyColumn. LazyRow/LazyColumn do not support this feature yet. I think the offscreenPageLimit is what you are looking for, but unfortunately it's not ready so far. You can track the progress in this issue: #899

That's what I'm expected. Is there possible to build the pager with Column/Row instead of LazyColumn/LazyRow? Because it seems that there isn't any progress about this feature in the Compose official issue tracker.

OXeu avatar Aug 14 '22 13:08 OXeu

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.

github-actions[bot] avatar Sep 14 '22 04:09 github-actions[bot]