Title: [277101] trunk/Tools
Revision
277101
Author
[email protected]
Date
2021-05-06 10:20:55 -0700 (Thu, 06 May 2021)

Log Message

REGRESSION (r272414?): [macOS] TestWebKitAPI.GPUProcess.CrashWhilePlayingVideo is a flaky failure
https://bugs.webkit.org/show_bug.cgi?id=221742
<rdar://problem/74220428>

Reviewed by Youenn Fablet.

Check that video.currentTime is changing to determine if the video is playing, instead of
relying on [webView _isPlayingAudio]. Also use a test page with a single video element instead
of multiple. I am hoping this will make the test more reliable or at least shade some light on
why this is flaky.

* TestWebKitAPI/Tests/WebKitCocoa/GPUProcess.mm:
(TEST):

Modified Paths

Diff

Modified: trunk/Tools/ChangeLog (277100 => 277101)


--- trunk/Tools/ChangeLog	2021-05-06 17:13:47 UTC (rev 277100)
+++ trunk/Tools/ChangeLog	2021-05-06 17:20:55 UTC (rev 277101)
@@ -1,3 +1,19 @@
+2021-05-06  Chris Dumez  <[email protected]>
+
+        REGRESSION (r272414?): [macOS] TestWebKitAPI.GPUProcess.CrashWhilePlayingVideo is a flaky failure
+        https://bugs.webkit.org/show_bug.cgi?id=221742
+        <rdar://problem/74220428>
+
+        Reviewed by Youenn Fablet.
+
+        Check that video.currentTime is changing to determine if the video is playing, instead of
+        relying on [webView _isPlayingAudio]. Also use a test page with a single video element instead
+        of multiple. I am hoping this will make the test more reliable or at least shade some light on
+        why this is flaky.
+
+        * TestWebKitAPI/Tests/WebKitCocoa/GPUProcess.mm:
+        (TEST):
+
 2021-05-06  Sam Sneddon  <[email protected]>
 
         mark all SCM tests using SVN as slow, a couple as xfail; enable SCM

Modified: trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/GPUProcess.mm (277100 => 277101)


--- trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/GPUProcess.mm	2021-05-06 17:13:47 UTC (rev 277100)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/GPUProcess.mm	2021-05-06 17:20:55 UTC (rev 277101)
@@ -314,22 +314,11 @@
     WKPreferencesSetBoolValueForKeyForTesting((__bridge WKPreferencesRef)[configuration preferences], true, WKStringCreateWithUTF8CString("UseGPUProcessForMediaEnabled"));
 
     auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:CGRectMake(0, 0, 400, 400) configuration:configuration.get()]);
-    [webView synchronouslyLoadTestPageNamed:@"large-videos-with-audio"];
+    [webView synchronouslyLoadTestPageNamed:@"large-video-with-audio"];
 
-    __block bool done = false;
-    [webView evaluateJavaScript:@"document.getElementsByTagName('video')[0].loop = true;" completionHandler:^(id result, NSError *error) {
-        EXPECT_TRUE(!error);
-        done = true;
-    }];
-    TestWebKitAPI::Util::run(&done);
+    [webView objectByEvaluatingJavaScript:@"document.getElementsByTagName('video')[0].loop = true;"];
+    [webView objectByEvaluatingJavaScriptWithUserGesture:@"play()"];
 
-    done = false;
-    [webView evaluateJavaScript:@"document.getElementsByTagName('video')[0].play() && true" completionHandler:^(id result, NSError *error) {
-        EXPECT_TRUE(!error);
-        done = true;
-    }];
-    TestWebKitAPI::Util::run(&done);
-
     auto webViewPID = [webView _webProcessIdentifier];
 
     // The GPU process should get launched.
@@ -343,11 +332,20 @@
         return;
     auto gpuProcessPID = [processPool _gpuProcessIdentifier];
 
-    // Audio should be playing.
-    timeout = 0;
-    while (![webView _isPlayingAudio] && timeout++ < 100)
-        TestWebKitAPI::Util::sleep(0.1);
-    EXPECT_TRUE([webView _isPlayingAudio]);
+    // Video should be playing.
+    auto ensureIsPlaying = [&] {
+        double initialTime = [[webView objectByEvaluatingJavaScript:@"document.getElementsByTagName('video')[0].currentTime"] doubleValue];
+        timeout = 0;
+        double currentTime = initialTime;
+        do {
+            TestWebKitAPI::Util::sleep(0.1);
+            currentTime = [[webView objectByEvaluatingJavaScript:@"document.getElementsByTagName('video')[0].currentTime"] doubleValue];
+            if (fabs(currentTime - initialTime) > 0.01)
+                break;
+        } while (timeout++ < 100);
+        return fabs(currentTime - initialTime) > 0.01;
+    };
+    EXPECT_TRUE(ensureIsPlaying());
 
     // Kill the GPU Process.
     kill(gpuProcessPID, 9);
@@ -364,10 +362,7 @@
     EXPECT_EQ(webViewPID, [webView _webProcessIdentifier]);
 
     // Audio should resume playing.
-    timeout = 0;
-    while (![webView _isPlayingAudio] && timeout++ < 100)
-        TestWebKitAPI::Util::sleep(0.1);
-    EXPECT_TRUE([webView _isPlayingAudio]);
+    EXPECT_TRUE(ensureIsPlaying());
 
     EXPECT_EQ(gpuProcessPID, [processPool _gpuProcessIdentifier]);
     EXPECT_EQ(webViewPID, [webView _webProcessIdentifier]);
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to