<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.webkit.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4.1"
          urlbase="https://bugs.webkit.org/"
          
          maintainer="admin@webkit.org"
>

    <bug>
          <bug_id>281786</bug_id>
          
          <creation_ts>2024-10-18 15:32:14 -0700</creation_ts>
          <short_desc>Auto-scrolling on popular Guitar Tab site doesn&apos;t work when page is zoomed</short_desc>
          <delta_ts>2025-01-29 20:58:51 -0800</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>New Bugs</component>
          <version>Safari Technology Preview</version>
          <rep_platform>Unspecified</rep_platform>
          <op_sys>Unspecified</op_sys>
          <bug_status>NEW</bug_status>
          <resolution></resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords>BrowserCompat, InRadar</keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Daniel Jalkut">jalkut</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>karlcow</cc>
    
    <cc>simon.fraser</cc>
    
    <cc>webkit-bug-importer</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>2069269</commentid>
    <comment_count>0</comment_count>
    <who name="Daniel Jalkut">jalkut</who>
    <bug_when>2024-10-18 15:32:14 -0700</bug_when>
    <thetext>The Ultimate Guitar tab site features an autoscroll button which is intended to scroll the content of the page automatically so you can play along.

The scroll works fine in Safari UNLESS you&apos;ve zoomed the page to any non-100% zoom level.

To reproduce:

1. Navigate to any Ultimate Guitar song page, for example: https://tabs.ultimate-guitar.com/tab/the-beths/expert-in-a-dying-field-chords-4271140
2. Ensure the page is zoomed to actual size by pressing Cmd-0
3. Click the &quot;Autoscroll&quot; button at the bottom of the page
4. While the page content is scrolling, press Cmd-+ to increase the zoom factor for the page.

Expected: the scrolling should continue

Actual: the scrolling stops

Notice that if you switch back to 100% (Cmd-0) the scrolling immediately begins again. Then zooming to a non-100% factor immediately stops it.

I don&apos;t know if this is ultimately (hah!) a bug in their autoscrolling code, or something wrong in WebKit. I confirmed though that the same feature works at all zoom sizes in Chrome.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2069277</commentid>
    <comment_count>1</comment_count>
    <who name="Sam Sneddon [:gsnedders]">gsnedders</who>
    <bug_when>2024-10-18 15:49:34 -0700</bug_when>
    <thetext>Daniel also pointed at https://www.ultimate-guitar.com/forum/showthread.php?t=2215942 in Slack, where it suggests the developer is aware of this.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2069279</commentid>
    <comment_count>2</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2024-10-18 15:49:44 -0700</bug_when>
    <thetext>&lt;rdar://problem/138214931&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2072702</commentid>
    <comment_count>3</comment_count>
    <who name="Karl Dubost">karlcow</who>
    <bug_when>2024-11-04 18:01:41 -0800</bug_when>
    <thetext>The autoscroll is managed by 

```
const G = () =&gt; {
        const [t, e] = (0, y.useState)(document.body.getBoundingClientRect()),
            [o, i] = (0, y.useState)(0),
            [n, s] = (0, y.useState)(t.top),
            [a, r] = (0, y.useState)(t.left),
            [l, c] = (0, y.useState)(null),
            d = () =&gt; {
                e(document.body.getBoundingClientRect()),
                c(o &gt; -t.top ? &quot;down&quot; : &quot;up&quot;)
            };
        return (0, y.useEffect)((() =&gt; {
            s(t.top ? -t.top : 0),
            r(t.left),
            i(t.top ? -t.top : 0)
        }), [t]), (0, y.useEffect)((() =&gt; (window.addEventListener(&quot;scroll&quot;, d), () =&gt; {
            window.removeEventListener(&quot;scroll&quot;, d)
        }))), {
            scrollY: n,
            scrollX: a,
            scrollDirection: l
        }
    },
```
in https://tabs.ultimate-guitar.com/static/public/build/ug_react_es6/202411/7496.96e2ce90724815b836fc437c3c770313.js


To note that the zoom also stops the scrolling on Firefox. So only chrome keeps scrolling. 

Also when coming back to &quot;zoom: 100%&quot;, then the scroll restarts.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2072703</commentid>
    <comment_count>4</comment_count>
    <who name="Karl Dubost">karlcow</who>
    <bug_when>2024-11-04 18:02:20 -0800</bug_when>
    <thetext>I wonder how document.body.getBoundingClientRect() changes when zooming on different browsers.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2072704</commentid>
    <comment_count>5</comment_count>
    <who name="Karl Dubost">karlcow</who>
    <bug_when>2024-11-04 18:08:43 -0800</bug_when>
    <thetext>document.body.getBoundingClientRect() changes in similar ways in different browsers.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2072708</commentid>
    <comment_count>6</comment_count>
    <who name="Karl Dubost">karlcow</who>
    <bug_when>2024-11-04 18:12:29 -0800</bug_when>
    <thetext>Another data point, 
If I zoom BEFORE activating the autoscroll, and activate it, then the autoscroll is not working. 
In that same sequence, if I set back to 100%, the autoscroll starts.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2090618</commentid>
    <comment_count>7</comment_count>
    <who name="Simon Fraser (smfr)">simon.fraser</who>
    <bug_when>2025-01-29 19:18:56 -0800</bug_when>
    <thetext>The autoscroll code is actually this:

```
                    v = (0, n.useCallback)((t =&gt; {
                        const {current: e} = r;
                        if (!d.current || !a.current || !e)
                            return;
                        const i = 0 &lt; window.innerHeight - l - a.current.getBoundingClientRect().bottom,
                            n = e instanceof Window ? e.scrollX : e.scrollLeft;
                        if (i) {
                            if (!t)
                                return void f();
                            e.scrollTo(n, 0)
                        }
                        if (!i) {
                            const t = e instanceof Window ? e.scrollY : e.scrollTop;
                            e.scrollTo(n, t + u.current)
                        }
                        const o = 1e3 / p.current * (g.nR / (40 - (40 / 15 - 1)));
                        c.current = window.setTimeout(v, o)
                    }), [e, l]);
```

Maybe this is related to bug 174362.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2090619</commentid>
    <comment_count>8</comment_count>
    <who name="Simon Fraser (smfr)">simon.fraser</who>
    <bug_when>2025-01-29 19:21:46 -0800</bug_when>
    <thetext>Bug 174362 is about pinch zoom, not Command-+ zoom</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2090633</commentid>
    <comment_count>9</comment_count>
    <who name="Daniel Jalkut">jalkut</who>
    <bug_when>2025-01-29 20:55:12 -0800</bug_when>
    <thetext>Thanks for isolating the autoscroll code. I wonder if there&apos;s something about the different zoom levels that causes the math to be off such that the `e.scrollTo` line continuously scrolls to the same offset. I don&apos;t know enough about how the zoomed window might change the semantic meaning of a &quot;scrollY&quot; value, for example. But I can observe that while the bug is happening it constantly tries to scroll by &quot;1&quot; (u.current), but by the time the callback is reached again e.scrollY is still at the same location. So maybe scrolling by 1 isn&apos;t enough?

In fact, as a quick check, I broke at the line where the scrollTo occurs, and changed the value of `u.current` to 2 instead of 1. Making this changes causes the scroll animation to resume.

In fact, I can confirm that at the breakpoint, if e.scrollY for example is 1302, manually invoking `e.scrollTo(0, 1303)` has no impact on e.scrollY. But something like `e.scrollTo(0, 1305` does.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2090634</commentid>
    <comment_count>10</comment_count>
    <who name="Daniel Jalkut">jalkut</who>
    <bug_when>2025-01-29 20:58:51 -0800</bug_when>
    <thetext>Perhaps the distinction between browsers here is if Chrome&apos;s implementation of `scrollTo` rounds &quot;out&quot; (rounding up for positive and down for negative changes), but Safari rounds &quot;in.&quot; I think the bug somehow has to do with the developer&apos;s assumption that consistently asking for the scroll to be &quot;1&quot; greater will always result in a change, but that on Safari it is not guaranteed.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>