Bug 184694

Summary: document.body.scrollHeight is different after resizing the window down and up
Product: WebKit Reporter: Tobi Reif <tobi>
Component: Layout and RenderingAssignee: Nobody <webkit-unassigned>
Status: RESOLVED CONFIGURATION CHANGED    
Severity: Major CC: bfulgham, cdumez, jond, simon.fraser, webkit-bug-importer, zalan
Priority: P2 Keywords: InRadar
Version: Safari 11   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
the page
none
Test reduction
none
Test reduction none

Description Tobi Reif 2018-04-17 08:19:02 PDT
In a full-size window load https://tobireif.com/demos/ .
Note that the page is short.
Resize the window to be narrow, and back.
Note that the same page at the same full width as before now is much longer than before.
The issue does not occur in Chrome, Firefox, and Opera.

The related code probably is "function setCanvasSize()" -> "document.body.scrollHeight".

I hope you can ensure that it will work as in Chrome & Firefox & Opera where the reported height is the same after downsize-upsize.
Comment 1 Tobi Reif 2018-04-17 08:21:01 PDT
(Please set the correct Component, it might be Layout instead of DOM.)
Comment 2 Tobi Reif 2018-04-17 08:41:03 PDT
Created attachment 338118 [details]
the page
Comment 3 Radar WebKit Bug Importer 2018-04-20 23:34:04 PDT
<rdar://problem/39618561>
Comment 4 Tobi Reif 2018-05-03 01:33:54 PDT
I hope you can update this ticket as soon as <rdar://problem/39618561> got set to fixed, so that I can check the fix in the latest Safari (in addition to your tests).
Comment 5 zalan 2018-05-04 16:28:04 PDT
Created attachment 339609 [details]
Test reduction
Comment 6 zalan 2018-05-04 16:29:52 PDT
Interestingly both FF and Chrome behave the same as Safari in quirks mode.
Comment 7 zalan 2018-05-04 16:31:47 PDT
Test reduction -> 
1. resize the page until all boxes wrap
2. resize it back until all boxes are on the same line
-> check for scrolling.
Comment 8 zalan 2018-05-04 16:33:20 PDT
Created attachment 339610 [details]
Test reduction
Comment 9 Simon Fraser (smfr) 2018-05-07 14:11:42 PDT
So this bug is about the value of scrollHeight during the resize handler?
Comment 10 Tobi Reif 2018-05-08 00:45:22 PDT
> So this bug is about the value of scrollHeight during the resize handler?

Yep - when you insert "console.log(document.body.scrollHeight);" into "function setCanvasSize()", then open the page in eg Chrome, you always get ~ the same value after you downsize upsize the window. In Safari you'll get very different much larger values after downsize upsize.
Comment 11 Simon Fraser (smfr) 2018-05-18 21:19:07 PDT
document.body.scrollHeight seems incompatible between Safari and Chrome/Firefox. In Safari, it's max(view height, contents height), but in other browsers it's just contents height.

This is odd, since scrollHeight is max(box height, contents height) for an overflow scroll div.
Comment 12 Simon Fraser (smfr) 2018-05-18 21:27:27 PDT
scrollHeight on the body comes from the ScrollView contentsSize, and that is computed via RenderView::unscaledDocumentRect() which uses layoutOverflowRect(). If not overflowing, we use height and width of the RenderView (which is not the body!).
Comment 14 Tobi Reif 2018-05-19 05:47:32 PDT
Thanks for investigating!
Comment 15 Tobi Reif 2018-06-19 04:00:40 PDT
I hope this can get fixed
Comment 16 Tobi Reif 2018-11-09 01:06:14 PST
The issue still exists in Safari 12.0.1 (14606.2.104.1.1) and in Safari Technology Preview Release 69 (Safari 12.1, WebKit 14607.1.12) :

After sizing the window to be narrow and back, the page is longer than before == longer than it should be.
Comment 17 Tobi Reif 2019-06-25 09:27:07 PDT
It would be great if this could get fixed :)
Comment 18 Tobi Reif 2019-09-25 01:27:44 PDT
It would be great if this could get fixed :)
Comment 19 Tobi Reif 2021-07-01 02:52:58 PDT
It would be great if this could get fixed.
Comment 20 Tobi Reif 2021-07-01 03:00:11 PDT
Actually, I can't reproduce this anymore (neither with the linked page nor with the supplied attachment). If you agree that the issue got resolved you can close this ticket.
Comment 21 Simon Fraser (smfr) 2021-07-01 11:10:07 PDT
Confirmed, can no longer reproduce.
Comment 22 Tobi Reif 2021-07-02 00:50:17 PDT
Thanks!