Bug 185965 - [iOS] TestWebKitAPI.PasteImage tests are flaky failures
Summary: [iOS] TestWebKitAPI.PasteImage tests are flaky failures
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: New Bugs (show other bugs)
Version: Other
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Wenson Hsieh
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2018-05-24 16:31 PDT by Ryan Haddad
Modified: 2018-08-30 15:50 PDT (History)
9 users (show)

See Also:


Attachments
Patch (2.94 KB, patch)
2018-08-29 20:47 PDT, Wenson Hsieh
no flags Details | Formatted Diff | Diff
Patch (4.33 KB, patch)
2018-08-30 14:08 PDT, Wenson Hsieh
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Ryan Haddad 2018-05-24 16:31:04 PDT
The following API test is a flaky failure on iOS Simulator bots:

    TestWebKitAPI.PasteImage.PastePNGImage
        
        /Volumes/Data/slave/ios-simulator-11-release/build/Tools/TestWebKitAPI/Tests/WebKitCocoa/PasteImage.mm:115
        Value of: [webView stringByEvaluatingJavaScript:@"imageElement.width"]
          Actual: "0"
        Expected: "200"

https://build.webkit.org/builders/Apple%20iOS%2011%20Simulator%20Release%20WK2%20(Tests)/builds/5205/steps/run-api-tests/logs/stdio
Comment 1 Ryan Haddad 2018-05-24 17:30:27 PDT
I see a similar failure with TestWebKitAPI.PasteImage.PasteGIFImage @ r231863
        
        /Volumes/Data/slave/ios-simulator-11-release/build/Tools/TestWebKitAPI/Tests/WebKitCocoa/PasteImage.mm:71
        Value of: [webView stringByEvaluatingJavaScript:@"imageElement.width"]
          Actual: "0"
        Expected: "400"

https://build.webkit.org/builders/Apple%20iOS%2011%20Simulator%20Release%20WK2%20%28Tests%29/builds/5029
Comment 3 Ryan Haddad 2018-07-02 10:08:35 PDT
I can easily reproduce these failures by running the tests in a loop:
while true; do run-api-tests --ios-simulator PasteImage; done
Comment 4 Radar WebKit Bug Importer 2018-07-02 10:08:47 PDT
<rdar://problem/41727126>
Comment 5 Radar WebKit Bug Importer 2018-07-02 10:09:02 PDT
<rdar://problem/41727134>
Comment 6 Wenson Hsieh 2018-07-02 10:10:29 PDT
I suspect we just need to wait for the image elements to become their expected sizes.
Comment 7 Ryan Haddad 2018-08-29 11:47:24 PDT
(In reply to Wenson Hsieh from comment #6)
> I suspect we just need to wait for the image elements to become their
> expected sizes.
Is this a quick fix? These failures are frequently making the bots red.
Comment 8 Wenson Hsieh 2018-08-29 12:44:32 PDT
(In reply to Ryan Haddad from comment #7)
> (In reply to Wenson Hsieh from comment #6)
> > I suspect we just need to wait for the image elements to become their
> > expected sizes.
> Is this a quick fix? These failures are frequently making the bots red.

If my speculation is correct, the fix should be trivial. I'll take a look at this by the end of the week and see (we may just need to sprinkle `[webView waitForMessage:@"loaded"];` in some places).
Comment 9 Wenson Hsieh 2018-08-29 20:47:58 PDT
Created attachment 348478 [details]
Patch
Comment 10 WebKit Commit Bot 2018-08-30 07:35:35 PDT
Comment on attachment 348478 [details]
Patch

Clearing flags on attachment: 348478

Committed r235504: <https://trac.webkit.org/changeset/235504>
Comment 11 WebKit Commit Bot 2018-08-30 07:35:37 PDT
All reviewed patches have been landed.  Closing bug.
Comment 12 Ryan Haddad 2018-08-30 13:14:59 PDT
It looks like these tests time out on macOS now :(

TestWebKitAPI.PasteImage.PastePNGImage
https://build.webkit.org/builders/Apple%20Sierra%20Debug%20WK2%20(Tests)/builds/7823/steps/run-api-tests/logs/stdio

TestWebKitAPI.PasteImage.PasteGIFImage
https://build.webkit.org/builders/Apple%20Sierra%20Debug%20WK1%20%28Tests%29/builds/9324/steps/run-api-tests/logs/stdio
Comment 13 Truitt Savell 2018-08-30 13:20:22 PDT
(In reply to Ryan Haddad from comment #12)
> It looks like these tests time out on macOS now :(
> 
> TestWebKitAPI.PasteImage.PastePNGImage
> https://build.webkit.org/builders/Apple%20Sierra%20Debug%20WK2%20(Tests)/
> builds/7823/steps/run-api-tests/logs/stdio
> 
> TestWebKitAPI.PasteImage.PasteGIFImage
> https://build.webkit.org/builders/Apple%20Sierra%20Debug%20WK1%20%28Tests%29/
> builds/9324/steps/run-api-tests/logs/stdio

Also 

TestWebKitAPI.PasteImage.PasteJPEGImage
https://build.webkit.org/builders/Apple%20Sierra%20Debug%20WK1%20%28Tests%29/builds/9326/steps/run-api-tests/logs/stdio
Comment 14 Wenson Hsieh 2018-08-30 13:22:41 PDT
(In reply to Ryan Haddad from comment #12)
> It looks like these tests time out on macOS now :(
> 
> TestWebKitAPI.PasteImage.PastePNGImage
> https://build.webkit.org/builders/Apple%20Sierra%20Debug%20WK2%20(Tests)/
> builds/7823/steps/run-api-tests/logs/stdio
> 
> TestWebKitAPI.PasteImage.PasteGIFImage
> https://build.webkit.org/builders/Apple%20Sierra%20Debug%20WK1%20%28Tests%29/
> builds/9324/steps/run-api-tests/logs/stdio

Weird!

I'll look into this later today. I suppose it's possible that images can load /too/ quickly on macOS, and we dispatch the "load" event before the UI process even gets a chance to register a message handler.

I can test this by registering prior to calling insertFileAsImage.
Comment 15 Wenson Hsieh 2018-08-30 14:08:51 PDT
Reopening to attach new patch.
Comment 16 Wenson Hsieh 2018-08-30 14:08:51 PDT
Created attachment 348545 [details]
Patch
Comment 17 Wenson Hsieh 2018-08-30 14:11:21 PDT
(In reply to Wenson Hsieh from comment #16)
> Created attachment 348545 [details]
> Patch

Luckily, I'm able to reproduce the timeouts on macOS this time. This should fix the timeouts that started after my previous attempt...
Comment 18 WebKit Commit Bot 2018-08-30 15:50:43 PDT
Comment on attachment 348545 [details]
Patch

Clearing flags on attachment: 348545

Committed r235528: <https://trac.webkit.org/changeset/235528>
Comment 19 WebKit Commit Bot 2018-08-30 15:50:45 PDT
All reviewed patches have been landed.  Closing bug.