Bug 256864 - REGRESSION (2023-05-13): [ macOS ] TestWebKitAPI.WKAttachmentTests.MovePastedImageByDragging is a consistent failure
Summary: REGRESSION (2023-05-13): [ macOS ] TestWebKitAPI.WKAttachmentTests.MovePasted...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Tools / Tests (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Wenson Hsieh
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2023-05-16 15:52 PDT by Karl Rackler
Modified: 2023-05-16 22:36 PDT (History)
8 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Karl Rackler 2023-05-16 15:52:53 PDT
Description:
TestWebKitAPI.WKAttachmentTests.MovePastedImageByDragging

The first failure I saw on the dashboard was on 5/13/2023 at 264047@main.

History:
https://results.webkit.org/?suite=api-tests&test=TestWebKitAPI.WKAttachmentTests.MovePastedImageByDragging

Diff:
Failed
    TestWebKitAPI.WKAttachmentTests.MovePastedImageByDragging
        2023-05-16 13:52:01.742 TestWebKitAPI[40420:316648632] Expected to find ordered tags: (
            STRONG,
            IMG
        ) in: (
            IMG,
            DIV,
            STRONG,
            DIV,
            STRONG,
            BR
        )
        
        /Volumes/Data/worker/Apple-Ventura-Release-Build/build/Tools/TestWebKitAPI/cocoa/TestWKWebView.mm:202
        Expected equality of these values:
          [remainingTags count]
            Which is: 1
          0U
            Which is: 0
Comment 1 Radar WebKit Bug Importer 2023-05-16 15:53:18 PDT
<rdar://problem/109428176>
Comment 2 Karl Rackler 2023-05-16 16:08:08 PDT
Looking at the flakiness dashboard, this seems to have started in the range https://commits.webkit.org/compare/264056@main...264046@main
Comment 3 Alexey Proskuryakov 2023-05-16 18:43:18 PDT
This started failing on different revisions on different bots through Sunday. This fits neither code change nor environment change.

I've rebooted bot135 just to see if this happens to change anything. Maybe drag and drop breaks after 45 days of uptime.
Comment 4 Wenson Hsieh 2023-05-16 20:30:57 PDT
Robert Jenner let me borrow one of the test runners that's currently reproducing the test failure (bot211), and I was able to figure out where it's falling over. This API test is basically split into 2 parts:

1. It first copies and pastes an attachment-backed image in an editable webview.
2. It then starts an edit drag over (50, 50) (where the image is supposed to be), moving it within the view.

The issue is that it's possible for the image to take long enough to load, that the test attempts to begin a drag over the image before it's even done loading/painting; this causes the drag (and API test) to fail.

I confirmed that this adjustment fixes the race on bot211 (which is consistently hitting this failure otherwise):

```
diff --git a/Tools/TestWebKitAPI/Tests/WebKitCocoa/WKAttachmentTests.mm b/Tools/TestWebKitAPI/Tests/WebKitCocoa/WKAttachmentTests.mm
index 2197d4ff1983..a75522ce34ee 100644
--- a/Tools/TestWebKitAPI/Tests/WebKitCocoa/WKAttachmentTests.mm
+++ b/Tools/TestWebKitAPI/Tests/WebKitCocoa/WKAttachmentTests.mm
@@ -1152,6 +1152,8 @@ TEST(WKAttachmentTests, MovePastedImageByDragging)

     platformCopyPNG();
     [webView _synchronouslyExecuteEditCommand:@"Paste" argument:nil];
+    [webView waitForImageElementSizeToBecome:CGSizeMake(215, 174)];
+
     [webView _executeEditCommand:@"InsertParagraph" argument:nil completion:nil];
     [webView _executeEditCommand:@"InsertHTML" argument:@"<strong>text</strong>" completion:nil];
     [webView _synchronouslyExecuteEditCommand:@"InsertParagraph" argument:nil];
```

It's still somewhat of a mystery why this passed so consistently prior to 5/13, but it's also evident that the test is inherently racy, and may have flaked before then (just less frequently).
Comment 5 Wenson Hsieh 2023-05-16 20:35:32 PDT
Pull request: https://github.com/WebKit/WebKit/pull/13948
Comment 6 Alexey Proskuryakov 2023-05-16 22:26:39 PDT
And rebooting didn't help on bot135. This is quite a mystery.
Comment 7 Alexey Proskuryakov 2023-05-16 22:33:41 PDT
Temperature in the lab hasn't changed, I checked.
Comment 8 EWS 2023-05-16 22:36:55 PDT
Committed 264137@main (255d31d4f608): <https://commits.webkit.org/264137@main>

Reviewed commits have been landed. Closing PR #13948 and removing active labels.