accompanist icon indicating copy to clipboard operation
accompanist copied to clipboard

[Pager] Web content becomes infinite sometimes when Pager is vertical

Open Doomsdayrs opened this issue 3 years ago • 12 comments
trafficstars

Description My application uses both the Pager & Web components. The Web component is utilized to display the content to the user. The Pager component is used to navigate between the contents. The Pager can be configured by the user to be either Horizontal or Vertical. When the Pager is set to Vertical, and the Web content is a long page with lots of text, the Web content becomes infinite sometimes.

Steps to reproduce

  1. Have a vertical pager setup with web pages
  2. Have each web page set up with a long series of text, such as news columns.
  3. Scroll through the content, Notice that eventually web content goes into an infinite scroll sometimes.

Expected behavior Web content does not become infinite

Additional context When the Pager is horizontal, the Web content does not become infinite.

Doomsdayrs avatar Apr 13 '22 18:04 Doomsdayrs

This seems similar to #1063

Doomsdayrs avatar Apr 14 '22 04:04 Doomsdayrs

@andkulikov It seems this issue is routed with the following code at line 88 of WebView.kt

                layoutParams = ViewGroup.LayoutParams(
                    ViewGroup.LayoutParams.MATCH_PARENT,
                    ViewGroup.LayoutParams.MATCH_PARENT
                )

Setting it to wrap content for height solves the issue

Doomsdayrs avatar Apr 19 '22 21:04 Doomsdayrs

Ben, seems like it is something to fix in webview wrapper, can you please take a look?

andkulikov avatar Apr 21 '22 15:04 andkulikov

furthermore, this also seems to occur on horizontal as well

It seems to derive from a delay in rendering causing the constraints to be out of wack.

Doomsdayrs avatar Apr 21 '22 15:04 Doomsdayrs

I added a sample to try and repro the problem. I am curious though, what is your expected behaviour when the webview content is larger than the pager? You would have two vertically scrolling elements together?

bentrengrove avatar Apr 21 '22 23:04 bentrengrove

The expected behavior is that when the Web content is used to render a passage of text. This can be news, novel, etc, from the internet.

If the webview content is larger then the pager, I expect that the webview is scrolled until there is no more content, afterwards starting a scroll of the pager.

The above behavior is present as it is, but will eventually lead to an "infinite" scroll, in which the webview becomes exponentially large compared to the content.

I had to modify the layoutParams to constrain the webview to the content.

Doomsdayrs avatar Apr 22 '22 18:04 Doomsdayrs

Would it be possible to provide some sample code? I have implemented with the instructions above and I am unable to reproduce. For me when I do that the webviews never scroll, the scroll is just intercepted by the pager.

What version of Android are you testing on? Perhaps there are differences in the underlying webview

bentrengrove avatar Apr 26 '22 11:04 bentrengrove

Would it be possible to provide some sample code? I have implemented with the instructions above and I am unable to reproduce. For me when I do that the webviews never scroll, the scroll is just intercepted by the pager.

I would say my app would be the perfect example of the code. Simply remove these three lines and run in studio with android 11 for emulation.

Then follow this navigation:

  1. Browse
  2. Download "Foxaholic"
  3. Scroll to newly installed extension, click the card to open up catalog
  4. Select any resulting cards to open up info
  5. Click "Resume"
  6. At this point, Scroll down until you reach the end of a chapter, then pull to the next chapter
  7. If the issue decides to happen, Notice that the second chapter becomes "infinite", with lots of empty space

What version of Android are you testing on? Perhaps there are differences in the underlying webview

I doubt it is android version.

Doomsdayrs avatar May 20 '22 03:05 Doomsdayrs

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 Jun 20 '22 03:06 github-actions[bot]

Bump, Still an issue

Doomsdayrs avatar Jul 22 '22 21:07 Doomsdayrs

This seems to be the root cause, any plan to fix it? https://github.com/google/accompanist/issues/1127#issuecomment-1103185274. i.e. the layout params should not be hardcoded as MATCH_PARENT as it will not work properly in a scrollable list (Column or LazyColumn)

SilverEnd avatar Oct 19 '22 03:10 SilverEnd

This seems to be the root cause, any plan to fix it? #1127 (comment). i.e. the layout params should not be hardcoded as MATCH_PARENT as it will not work properly in a scrollable list (Column or LazyColumn)

bump, as the solution I found is changing the second to wrap.

Doomsdayrs avatar Nov 04 '22 05:11 Doomsdayrs

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 Dec 05 '22 03:12 github-actions[bot]

0554af0b622fea152353fcbd80ce8dc6ae7d2c00 seems to solve this

Doomsdayrs avatar Dec 07 '22 16:12 Doomsdayrs