accompanist
accompanist copied to clipboard
[Pager] Web content becomes infinite sometimes when Pager is vertical
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
- Have a vertical pager setup with web pages
- Have each web page set up with a long series of text, such as news columns.
- 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.
This seems similar to #1063
@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
Ben, seems like it is something to fix in webview wrapper, can you please take a look?
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.
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?
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.
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
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:
- Browse
- Download "Foxaholic"
- Scroll to newly installed extension, click the card to open up catalog
- Select any resulting cards to open up info
- Click "Resume"
- At this point, Scroll down until you reach the end of a chapter, then pull to the next chapter
- 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.
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.
Bump, Still an issue
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)
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_PARENTas it will not work properly in a scrollable list (ColumnorLazyColumn)
bump, as the solution I found is changing the second to wrap.
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.
0554af0b622fea152353fcbd80ce8dc6ae7d2c00 seems to solve this