accompanist icon indicating copy to clipboard operation
accompanist copied to clipboard

[Pager]HorizontalPager cannot save the AndroidView state.

Open wilinz opened this issue 3 years ago • 4 comments

HorizontalPager cannot save the AndroidView state. When switching pages, the AndroidView factory will be triggered, resulting in view recreate. If WebView is used in HorizontalPager, the webpage will be reloaded when switching pages.

wilinz avatar Jul 09 '22 07:07 wilinz

I'm facing the same issue with ExoPlayer. The video does not start preparing for display until it's on screen, which results in a delay before playing it and a performance impact.

Nek-12 avatar Jul 13 '22 13:07 Nek-12

I have the same issue with WebView. It keeps reloading every time I switch my tabs. Very annoying.

agent10 avatar Jul 14 '22 02:07 agent10

Starting with Version 0.19 there was a switch from the previous HorizontalPager to a LazyRow implementation. By definition a LazyRow only shows views inside the viewport thus the WebView keeps reloading every time.

both HorizontalPager and VerticalPager were re-written to be based on LazyRow and LazyColumn respectively https://google.github.io/accompanist/pager/#changes-in-v0190

This is also related to https://github.com/google/accompanist/issues/899 where the support for offscreenPageLimit is discussed.

I noticed myself that in a setup with a Horizontal Pager with only 3 Tabs the tabs on the right hand side are kept and are recycled while tabs on the left are disposed immediately when they leave the viewport.

David-Development avatar Jul 15 '22 13:07 David-Development

Seems like Pager don't save the state of the pages and recreate everything in the page when switching pages. Is there any solution for this?

tengyeekong avatar Jul 31 '22 11:07 tengyeekong

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 Aug 31 '22 04:08 github-actions[bot]

I think its rather obvious that there should be an option to keep the pages in memory. Why google keep making my life complicated? Do they like it?

lectricas avatar Apr 30 '23 12:04 lectricas

Using foundation pager you can specify offscreen page limit. No need to vent here.

Nek-12 avatar Apr 30 '23 18:04 Nek-12