Bug 212019 - Scroll position of page keeps changing as I try to read it
Summary: Scroll position of page keeps changing as I try to read it
Status: NEW
Alias: None
Product: WebKit
Classification: Unclassified
Component: Layout and Rendering (show other bugs)
Version: Safari 12
Hardware: iPhone / iPad iOS 13
: P2 Normal
Assignee: Nobody
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2020-05-18 04:54 PDT by Nicholas Shanks
Modified: 2020-05-19 11:18 PDT (History)
4 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Nicholas Shanks 2020-05-18 04:54:34 PDT
Note: I don't know what version of Safari is running on my phone, as it's not shown under Settings.app > General, nor Settings.app > Safari, nor in the Mobile Safari app AFAICT. The phone has iOS 13.3.1 installed.


Abstract:
I clicked a link in the Twitter iOS app to https://wholemars.net/2020/05/17/frederic-response/ and had a terrible user experience, fighting with the site and/or WebView, which kept changing my scroll position. In the end I gave up with iOS and switched to my laptop to read the article. i propose a solution which will improve the user experience.


Long version with most expletives removed:
The link opened in the app's WebKit view, and I began reading. Judging by the length of the article, it would take about 30 minutes to read it all in good conditions. About 20 seconds in, the view switche(d/s) to Reader Mode, which was a little annoying but not enough to make me file a bug, though it would be nice if it started rendering in Reader Mode straight off the bat. (I assume by the time of first paint, you already have enough consecutive P tags to realise this is a text-dominant web page.)

During reading of the article, the scroll position jumps around so often and to such a degree that it makes it near impossible to read to the end. The effect seemed greater the further down the document you are, both in the frequency and magnitude of the scroll position changes. At about 80% of the way down the document, it was often taking me longer to re-find where I had gotten to, than the scroll position change interval, thus I was unable to continue reading the page.

I tried turning off Reader Mode, this didn't help. I tried reloading the page within the WebView (returning to the linking tweet and re-clicking), this didn't help. I tried opening the URL in iOS Safari. This also did not resolve the jumping around.
In the end I switched to my Mac and loaded the page with Javascript disabled. This resolved the poor experience and I was able to complete reading the page. Trying it now (+24h later) on desktop with JS on, I don't see the jumping around. Thus I don't know whether to blame the website or iOS WebKit, but in either case, the issue can be solved with some smarter generic behaviour from WebKit.

I don't know if the document length changes were due to images loading very late, javascript on the page doing weird shit, or something else, but it would be much better if, when any document DOM changes in height and the scroll position ≠ zero, the deepest DOM element in normal flow in the viewport remains the same number of pixels from the top of the viewport as it was before the height changed. During an iOS scroll, use the element under the user's finger. That element should track the user's finger and any changes earlier in the DOM during the scroll (e.g. images which load and cause re-layout) should push the top of the page further away, or bring it closer to the viewport (for height increases, decreases respectively), just as DOM additions after the current viewport push the bottom of the document further away from the viewport.
In short, do whatever you can to keep what's on the screen still on the screen despite adversarial DOM changes.
Comment 1 Radar WebKit Bug Importer 2020-05-18 11:05:41 PDT
<rdar://problem/63350035>
Comment 2 Simon Fraser (smfr) 2020-05-18 11:06:10 PDT
To clarify, you saw scroll position jumping both in reader mode, and when viewing the normal page?
Comment 3 Nicholas Shanks 2020-05-19 05:10:42 PDT
@smfr Correct, in all eight combinations of: in WebView with reader mode on & off, in Safari with reader mode on & off, and during/not during scroll event with finger touching screen.
Comment 4 Nicholas Shanks 2020-05-19 05:18:44 PDT
Oh one further addition, I recall noticing more than once that I was further back after the jump, i.e. that either the start of the page had gotten longer and pushed content I'd read into the viewport, or the scroll offset from the top of the page had decreased (IIRC y-axis is flipped from AppKit default). I don't recall it jumping further down the page than I had already read, and thus me having to scroll up to get to where I was. AFAICR, I was always initially scrolling down (though obviously sometimes overshot into text I was not familiar with).
Comment 5 Simon Fraser (smfr) 2020-05-19 11:18:14 PDT
Does it reproduce in MobileSafari with the same URL?