Created attachment 458061 [details] Code reproduction Focusing a scroll container before performing a smooth scroll operation causes smooth scrolling to not work. Non-smooth scrolling works as expected. Steps to reproduce: 1. Open attached code reproduction on an iOS device that supports smooth scrolling. 2. Tap the "Smooth scroll to end" button. Observe that the container does not scroll to the end. 3. Tap the "Non Smooth scroll to end" button. Observe that the container scrolls to the end. Expected Behavior: I would expect that the container scrolls regardless of smooth scroll status. Actual Behavior: The scroll container does not scroll if smooth scrolling is enabled. Other Information: - This works as expected on Chrome and Firefox. - Disabling CSSOM View Smooth Scrolling in Settings > Safari > Experimental Features resolves the issue. - Wrapping the scroll operation in a requestAnimationFrame fixes the issue.
rdar://92105675
Also reproduces on macOS.
The focus call is triggering a call to stopAsyncAnimatedScroll: WebPageProxy 6 activityStateDidChange - mayHaveChanged active window WebPageProxy 6 dispatchActivityStateChange - potentiallyChangedActivityStateFlags active window WebPageProxy 6 dispatchActivityStateChange: state changed from active window, focused, visible, visible or occluded, in-window to focused, visible, visible or occluded, in-window WebPage 7 setActivityState to focused, visible, visible or occluded, in-window RenderLayer 0x59b04d540 584x250 stopAsyncAnimatedScroll
That might be a red herring, or only happen the first time. On every subsequent button click, there's no activity state change, but the animated scroll is getting cancelled because FrameView::scrollToFocusedElementInternal() runs on a timer.
Created attachment 458112 [details] Patch
Created attachment 458113 [details] Patch
Created attachment 458155 [details] Patch
Committed r293260 (249904@main): <https://commits.webkit.org/249904@main> All reviewed patches have been landed. Closing bug and clearing flags on attachment 458155 [details].
Thank you for the fix!