Bug 246971

Summary: accessibility tests hit assertion on macOS with UI side compositing enabled
Product: WebKit Reporter: Cameron McCormack (:heycam) <heycam>
Component: WebKit Process ModelAssignee: Nobody <webkit-unassigned>
Status: RESOLVED DUPLICATE    
Severity: Normal CC: webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
Bug Depends on: 247045    
Bug Blocks:    

Description Cameron McCormack (:heycam) 2022-10-24 16:15:22 PDT
Some tests under LayoutTests/accessibility/ hit this assertion when run on macOS with UI side compositing enabled:

ASSERTION FAILED: m_isWaitingForDidUpdateGeometry
/Volumes/z/safari/d/OpenSource/Source/WebKit/UIProcess/RemoteLayerTree/RemoteLayerTreeDrawingAreaProxy.mm(99) : virtual void WebKit::RemoteLayerTreeDrawingAreaProxy::didUpdateGeometry()

This is because:

1. The tests call testRunner.setViewSize().

2. This calls WKBundlePagePostSynchronousMessageForTesting(..., "SetViewSize", ...) in the Web content process, so that the test is blocked until the view size update is processed.

3. WKBundlePagePostSynchronousMessageForTesting calls WebPage::postSynchronousMessageForTesting, which sends a HandleSynchronousMessage("SetViewSize", ...) with the UseFullySynchronousModeForTesting flag.

4. On the UI process side, Connection::dispatchMessage for the HandleSynchronusMessage increments m_inDispatchMessageMarkedToUseFullySynchronousModeForTesting because of the UseFullySynchronousModeForTesting flag that was set on the message it just received. The effect of this is to cause all async messages sent on the connection back to the Web content process to be wrapped in WrappedAsyncMessageForTesting and sent synchronously too.

5. The HandleSynchronusMessage("SetViewSize", ...) message is processed in TestInvocation::didReceiveSynchronousMessageFromInjectedBundle by calling resizeTo() on the WKView.

6. Under resizeTo(), we end up in RemoteLayerTreeDrawingAreaProxy::sizeDidChange(), which calls RemoteLayerTreeDrawingAreaProxy::sendUpdateGeometry(). This sends DrawingArea::UpdateGeometry, which is normally an async message, but because the connection is in this m_inDispatchMessageMarkedToUseFullySynchronousModeForTesting mode, we send it synchronously.

7. The Web content process receives the UpdateGeometry message, does some more synchronous messaging back and forth with the UI process, and finally sends back a synchronous DidUpdateGeometry message.

8. Because RemoteLayerTreeDrawingAreaProxy::sendUpdateGeometry sets m_isWaitingForDidUpdateGeometry = true after the send() call, when we re-entrantly get into RemoteLayerTreeDrawingAreaProxy::didUpdateGeometry() to handle the DidUpdateGeometry message, we assert.

First thought was to move the m_isWaitingForDidUpdateGeometry = true assignment just above the send() call, but that's making the test time out. (Though possible it's timing out for other reasons.)
Comment 1 Radar WebKit Bug Importer 2022-10-24 16:15:44 PDT
<rdar://problem/101520235>
Comment 2 Cameron McCormack (:heycam) 2022-10-25 15:21:51 PDT
The test timeout is a different issue.  When the SetViewSize is message is sent, the window does get resized, but if the new size is wider than the old size, the document contents doesn't get reflowed to the new size.
Comment 3 Cameron McCormack (:heycam) 2022-10-25 21:33:35 PDT
Simon already has a bug for this: bug 242884.

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