Bug 75501

Summary: Webkit has a "flash of unscrolled content" when you click Back to a page that wasn't in the page cache
Product: WebKit Reporter: Cngevpxhaqrefpber <Cngevpxhaqrefpber>
Component: New BugsAssignee: Nobody <webkit-unassigned>
Status: RESOLVED DUPLICATE    
Severity: Normal CC: ap, beidson
Priority: P2 Keywords: InRadar
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: Unspecified   

Description Cngevpxhaqrefpber 2012-01-03 15:51:49 PST
If you do the following in Safari/Chrome:

1. Visit a website (such as reddit.com).
2. Scroll down a bit, and then click a link.
3. Click the Back button after the page loads.

You're taken to the very top of the page until it finishes loading again, and only then does the scrollbar return to its previous position. This means you have to wait at least a second if not longer to be automatically taken back to your previous position. Either that or you manually find your old position again (which is just as annoying).

This compared to Firefox, IE, and Opera, all of which instantly "move" the scrollbar to its previous position (you can't even see it happen). To me the delay in Safari/Chrome is very annoying / counter-intuitive and it'd be awesome if it could be avoided!
Comment 1 Brady Eidson 2012-01-04 16:00:18 PST
There should be zero delay when the page is in the page cache.

For the non page-cache case, this is actually a very difficult problem.

I'd love to see *one* specific URL where you see behavior you like in Firefox but in WebKit we wait till it's finished loading.  It's very likely that Firefox "works" by avoiding the amount of polish we usually demand.  But it's also possible they've put a lot of effort into solving this very difficult problem.
Comment 2 Cngevpxhaqrefpber 2012-01-04 18:39:30 PST
(In reply to comment #1)
> There should be zero delay when the page is in the page cache.
> 
> For the non page-cache case, this is actually a very difficult problem.
> 
> I'd love to see *one* specific URL where you see behavior you like in Firefox but in WebKit we wait till it's finished loading.  It's very likely that Firefox "works" by avoiding the amount of polish we usually demand.  But it's also possible they've put a lot of effort into solving this very difficult problem.

Hi Brady, I actually notice it all the time on reddit.com (and other sites), since on that site I'm usually clicking links and then going back to the main page often. I just scroll down a bit, click a link, click back after a bit, and then almost always the scrollbar position is back at the top of the page, and there's quite a noticeable delay before the scrollbar goes back to the old position. I don't remember ever experiencing this in Firefox or Opera, and I use and have used both extensively. I rarely use IE but I just tried it in IE9 prior to submitting the bug report and it didn't happen for me then either.

Curious to see if you can reproduce -- I don't think I've changed any settings in Chrome (and definitely not Safari) that would be causing this. I tried disabling all extensions to see if that'd change anything and it didn't.
Comment 3 Brady Eidson 2012-01-05 09:29:22 PST
(In reply to comment #2)
> (In reply to comment #1)
> > There should be zero delay when the page is in the page cache.
> > 
> > For the non page-cache case, this is actually a very difficult problem.
> > 
> > I'd love to see *one* specific URL where you see behavior you like in Firefox but in WebKit we wait till it's finished loading.  It's very likely that Firefox "works" by avoiding the amount of polish we usually demand.  But it's also possible they've put a lot of effort into solving this very difficult problem.
> 
> Hi Brady, I actually notice it all the time on reddit.com (and other sites), since on that site I'm usually clicking links and then going back to the main page often. I just scroll down a bit, click a link, click back after a bit, and then almost always the scrollbar position is back at the top of the page, and there's quite a noticeable delay before the scrollbar goes back to the old position. I don't remember ever experiencing this in Firefox or Opera, and I use and have used both extensively. I rarely use IE but I just tried it in IE9 prior to submitting the bug report and it didn't happen for me then either.
> 
> Curious to see if you can reproduce -- I don't think I've changed any settings in Chrome (and definitely not Safari) that would be causing this. I tried disabling all extensions to see if that'd change anything and it didn't.

So in Safari, the page cache actually works at reddit.com.  I just tried this: Went to the main page, scrolled all the way down, clicked an imgur link, hit back, and it was literally instant.  Chrome doesn't use the WebKit page cache so I can't speak to its performance on this one page.
Comment 4 Brady Eidson 2012-01-05 09:31:58 PST
I just disabled the page cache via a pref and tried reddit again.

The main HTML resource was in the disk cache, fortunately, so going back was still very very fast.  I did see a flash of unscrolled content before the scroll position was restored.

When originally reading this report, I thought you were reporting that slow loading pages somehow scroll better in FFX/Opera than WebKit browsers, and that had me a bit dubious.  But if what you're actually reporting is that fast loading pages whose resources are already cached have a "flash of unscrolled content" before the scroll position is restored... I agree!
Comment 5 Cngevpxhaqrefpber 2012-01-05 09:46:41 PST
> So in Safari, the page cache actually works at reddit.com.  I just tried this: Went to the main page, scrolled all the way down, clicked an imgur link, hit back, and it was literally instant.  Chrome doesn't use the WebKit page cache so I can't speak to its performance on this one page.

Not for me. However, what's interesting is when I turn off extensions completely in Safari (I only have one extension installed and enabled: Magic Scroll by Slice Factory: http://www.slicefactory.com/browser-extensions/magic-scroll-safari/274 -- I was using 0.1 but it looks like the version at the link above "works" too) it appears that the delay before the scrollbar is restored to its previous position goes away. Completely I think, and I also was able to reproduce this every time -- or maybe it's just a coincidence? I'd be interested to see if you can reproduce it too.
Comment 6 Cngevpxhaqrefpber 2012-01-05 09:49:13 PST
(In reply to comment #4)
> But if what you're actually reporting is that fast loading pages whose resources are already cached have a "flash of unscrolled content" before the scroll position is restored... I agree!

Yes, that is what I'm reporting... go to a site, let it load, scroll down, click a link, let it load, go back ... scroll bar goes back to the top of the page for a brief period, until it's then restored.

In your opinion should I report this over at the Chromium issues page as well?
Comment 7 Brady Eidson 2012-01-05 11:30:27 PST
(In reply to comment #6)
> (In reply to comment #4)
> > But if what you're actually reporting is that fast loading pages whose resources are already cached have a "flash of unscrolled content" before the scroll position is restored... I agree!
> 
> Yes, that is what I'm reporting... go to a site, let it load, scroll down, click a link, let it load, go back ... scroll bar goes back to the top of the page for a brief period, until it's then restored.
> 
> In your opinion should I report this over at the Chromium issues page as well?

As covered in https://bugs.webkit.org/show_bug.cgi?id=75597 the fact that Chromium doesn't use the WebKit page cache is up to them to resolve.

As far as this bug goes - the "flash of unscrolled content" - it's a very real, cross platform WebKit bug that we can resolve in WebCore.  They probably don't need a separate bug report for it.
Comment 8 Brady Eidson 2012-01-12 12:30:30 PST
In radar as <rdar://problem/10671919>
Comment 9 Brady Eidson 2012-01-12 12:32:04 PST
And this was noticed a long time ago.  By me.

https://bugs.webkit.org/show_bug.cgi?id=13629

*** This bug has been marked as a duplicate of bug 13629 ***