Bug 179927

Summary: Text cursor blinks outside of input box after scrolling
Product: WebKit Reporter: Danyao Wang <danyao>
Component: Layout and RenderingAssignee: Nobody <webkit-unassigned>
Status: RESOLVED DUPLICATE    
Severity: Normal CC: ajuma, bfulgham, fred.wang, simon.fraser, zalan
Priority: P2    
Version: Safari 11   
Hardware: iPhone / iPad   
OS: iOS 11   
See Also: https://bugs.webkit.org/show_bug.cgi?id=138201
Attachments:
Description Flags
Screenshot showing cursor blinking outside of input box none

Description Danyao Wang 2017-11-21 13:26:42 PST
Created attachment 327427 [details]
Screenshot showing cursor blinking outside of input box

This bug was originally reported by folks from http://n26.com. See http://crbug.com/781297 for original repro steps.

I created a minimal example that reproduces the problem: http://output.jsbin.com/cabejez

Steps to reproduce:
1. On an iOS device, visit http://output.jsbin.com/cabejez in Safari
2. Tab on input box
3. Scroll the page up

Expected result:
Cursor blinks inside the input box

Actual result:
Cursor blinks below and outside the input box. See screenshot attached.

The key ingredient for exposing the bug seems to be the <div> that contains the input box having position:fixed. Normally this <div> is not scrollable. But when the <input> is focused, it seems that the view is scrolled in UIProcess, but the WebProcess didn't get the update.
Comment 1 Frédéric Wang (:fredw) 2017-11-24 08:52:44 PST
I can confirm the bug on trunk.

@Danyao: I've actually been studying stack traces to re-position the fixed node for other bugs and it is:

WebCore::ScrollingStateFixedNode::reconcileLayerPositionForViewportRect
WebCore::AsyncScrollingCoordinator::reconcileViewportConstrainedLayerPositions
WebCore::AsyncScrollingCoordinator::reconcileScrollingState
WebKit::WebPage::updateVisibleContentRects

Also IIRC AsyncScrollingCoordinator::reconcileScrollingState is called 
from WebCore::AsyncScrollingCoordinator::updateScrollPositionAfterAsyncScroll if you perform a programmatic scroll of the main frame (instead of user interaction).

WebCore::AsyncScrollingCoordinator::updateScrollPositionAfterAsyncScroll is also called when doing user interaction in "overflow: auto; webkit-overflow-scrolling: touch" nodes and interestingly in that case we tell WebEditorClient that the overflow scroll position has changed.

Maybe you can try to compare your testcase using scrollingElement.scrollTop = ... or "overflow: auto; webkit-overflow-scrolling: touch" nodes and see whether you get the same issue?
Comment 2 Frédéric Wang (:fredw) 2018-02-15 08:33:20 PST
@Danyao: It seems that this bug is fixed in WebKit trunk (I tried the testcase with the simulator), can you please try again?
Comment 3 Simon Fraser (smfr) 2018-02-15 10:24:49 PST

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