Bug 183611 - [GTK] Layout test media/context-menu-actions.html is failing
Summary: [GTK] Layout test media/context-menu-actions.html is failing
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Media (show other bugs)
Version: Other
Hardware: PC Linux
: P2 Normal
Assignee: Enrique Ocaña
URL:
Keywords: InRadar
: 121742 (view as bug list)
Depends on:
Blocks:
 
Reported: 2018-03-13 13:34 PDT by Michael Catanzaro
Modified: 2020-07-02 06:45 PDT (History)
13 users (show)

See Also:


Attachments
Patch (2.16 KB, patch)
2020-06-16 07:54 PDT, Enrique Ocaña
no flags Details | Formatted Diff | Diff
Patch (3.89 KB, patch)
2020-06-16 09:35 PDT, Enrique Ocaña
no flags Details | Formatted Diff | Diff
Patch (6.70 KB, patch)
2020-06-18 09:40 PDT, Enrique Ocaña
no flags Details | Formatted Diff | Diff
Patch (6.71 KB, patch)
2020-07-01 08:36 PDT, Enrique Ocaña
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Michael Catanzaro 2018-03-13 13:34:31 PDT
Layout test media/context-menu-actions.html is failing since r229466 "webkitfullscreenchange event not fired at the same time as :-webkit-full-screen pseudo selector changes; causes glitchiness". I'll add a Failure expectation.

--- /home/slave/webkitgtk/gtk-linux-64-release-tests/build/layout-test-results/media/context-menu-actions-expected.txt
+++ /home/slave/webkitgtk/gtk-linux-64-release-tests/build/layout-test-results/media/context-menu-actions-actual.txt
@@ -1,3 +1,4 @@
+CONSOLE MESSAGE: line 122: TypeError: undefined is not an object (evaluating 'this.captionMenu.style')
 Test the various actions available in the HTML5 media element context-menu.
 
 
@@ -21,7 +22,7 @@
 
 EXPECTED (video.webkitDisplayingFullscreen == 'false') OK
 Toggling fullscreen state
-EXPECTED (video.webkitDisplayingFullscreen == 'true') OK
+EXPECTED (video.webkitDisplayingFullscreen == 'true'), OBSERVED 'false' FAIL
 
 END OF TEST
Comment 1 Jer Noble 2018-03-13 15:16:42 PDT
This test assumes that the webkitRequestFullscreen() implementation is entirely synchronous, which is most definitely isn't.  Each of these tests (or at least, each that has an associated event) should be waiting on that event, and not assuming that the results will change within the current run-loop.
Comment 2 Michael Catanzaro 2018-03-13 17:20:11 PDT
I'll remove the REGRESSION tag then. It doesn't seem helpful here, as the behavior change was intended.
Comment 3 Enrique Ocaña 2020-06-16 04:26:41 PDT
*** Bug 121742 has been marked as a duplicate of this bug. ***
Comment 4 Enrique Ocaña 2020-06-16 07:54:34 PDT
Created attachment 402005 [details]
Patch
Comment 5 Enrique Ocaña 2020-06-16 09:35:12 PDT
Created attachment 402012 [details]
Patch
Comment 6 Michael Catanzaro 2020-06-16 10:07:21 PDT
Comment on attachment 402012 [details]
Patch

Problem is that 50ms delays are (a) racy, and (b) going to add up when running 60,000 layout tests all at once. If there's no way to check whether the window has been fullscreened, then this is the best we can do. But I bet there is a way to check? :)
Comment 7 Xabier Rodríguez Calvar 2020-06-16 23:57:54 PDT
Comment on attachment 402012 [details]
Patch

I must agree with Michael here
Comment 8 Enrique Ocaña 2020-06-17 03:20:41 PDT
(In reply to Michael Catanzaro from comment #6)

> Problem is that 50ms delays are (a) racy, and (b) going to add up when
> running 60,000 layout tests all at once. If there's no way to check whether
> the window has been fullscreened, then this is the best we can do. But I bet
> there is a way to check? :)

I understand, but the ChangeLog explains why the "proper" way to check if the window has been fullscreened (onwebkitfullscreenchange) isn't working:

Simply setting an event handler on video.onwebkitfullscreenchange wouldn't have been enough, since the event is triggered before the fullscreen operation has been completed and checking for video.webkitDisplayingFullscreen == true would still fail by then.

The extra 50ms delay was the only solution I found. I tried to set it to the lowest possible value that doesn't trigger errors on my local system (25ms was too low, 100ms seemed a waste).
Comment 9 Michael Catanzaro 2020-06-17 06:29:41 PDT
OK, in that case, maybe a hardcoded delay is unavoidable.

Maybe "loop" the timeout say, 20 times, by reattaching the timeout if it's not fullscreen yet? That way we can reduce the race window and only fail the test if it's still not fullscreen after one second, without slowing down the test by more than 50ms more than required. I'm sure 50ms is enough for a typical laptop or desktop, but imagine the test is running in a container on a VM with limited resources on a host system that's doing 200 other things at the same time... or imagine the test passes when the system is doing 100 other things at the same time rather than 200... won't be fun to debug that.
Comment 10 Enrique Ocaña 2020-06-17 08:25:05 PDT
(In reply to Michael Catanzaro from comment #9)

> Maybe "loop" the timeout say, 20 times, by reattaching the timeout if it's
> not fullscreen yet? That way we can reduce the race window and only fail the
> test if it's still not fullscreen after one second

That's a good suggestion, thanks!
Comment 11 Xabier Rodríguez Calvar 2020-06-17 08:33:04 PDT
Comment on attachment 402012 [details]
Patch

There seems to be a beginfullscreen event. I think we should use this instead of just a timeout
Comment 12 Enrique Ocaña 2020-06-18 08:21:01 PDT
(In reply to Xabier Rodríguez Calvar from comment #11)

> There seems to be a beginfullscreen event. I think we should use this
> instead of just a timeout

Neither that webkitbeginfullscreen event[1] nor its couterpart webkitendfullscreenevent is ever triggered when using FULLSCREEN_API[2], so I don't think they're an option unless we change (and potentially break) the HTMLMediaElement code.

I suspect that some sort of wait is needed after all, since that's how other tests deal with fullscreen changes. For instance, helper functions in media-fullscreen.js call testExpectedEventually()[3][4][5], which is implemented as a sleep-and-retry loop[6].

[1] https://github.com/WebKit/webkit/blob/master/Source/WebCore/html/HTMLMediaElement.cpp#L5974
[2] https://github.com/WebKit/webkit/blob/master/Source/WebCore/html/HTMLMediaElement.cpp#L5953
[3] https://github.com/WebKit/webkit/blob/master/LayoutTests/media/media-fullscreen.js#L138
[4] https://github.com/WebKit/webkit/blob/master/LayoutTests/media/media-fullscreen.js#L36
[5] https://github.com/WebKit/webkit/blob/master/LayoutTests/media/media-fullscreen.js#L43
[6] https://github.com/WebKit/webkit/blob/master/LayoutTests/media/video-test.js#L119
Comment 13 Xabier Rodríguez Calvar 2020-06-18 08:47:26 PDT
(In reply to Enrique Ocaña from comment #12)
> Neither that webkitbeginfullscreen event[1] nor its couterpart
> webkitendfullscreenevent is ever triggered when using FULLSCREEN_API[2], so
> I don't think they're an option unless we change (and potentially break) the
> HTMLMediaElement code.

Sigh. Go for the loop Michael suggested then.
Comment 14 Enrique Ocaña 2020-06-18 09:40:47 PDT
Created attachment 402211 [details]
Patch
Comment 15 Xabier Rodríguez Calvar 2020-06-19 08:49:03 PDT
Comment on attachment 402211 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=402211&action=review

r+ but you need to fix the changelog.

Then I have a couple of questions. First is if this patch breaks any other tests and need a a rebase line. The seconds would be why is the test still marked as crash.

> LayoutTests/ChangeLog:19
> +        would be lost) in case we wait forever for the comparison to evaluato to the expected value.

evaluate
Comment 16 Enrique Ocaña 2020-07-01 03:54:34 PDT
(In reply to Xabier Rodríguez Calvar from comment #15)

> Then I have a couple of questions. First is if this patch breaks any other tests and need a a rebase line.

Indeed, some tests appear to be broken. I'll need to have a look.

> The seconds would be why is the test still marked as crash.

The crash issue belongs to bug 198830 and seems to be a GLX related problem out of the scope of bug 183611. I wanted to focus on one thing at a time instead of tackling two unrelated problems.
Comment 17 Enrique Ocaña 2020-07-01 08:36:29 PDT
Created attachment 403297 [details]
Patch
Comment 18 EWS 2020-07-02 01:14:20 PDT
Committed r263835: <https://trac.webkit.org/changeset/263835>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 403297 [details].
Comment 19 Radar WebKit Bug Importer 2020-07-02 01:15:20 PDT
<rdar://problem/65023862>
Comment 20 Philippe Normand 2020-07-02 02:18:10 PDT
Comment on attachment 403297 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=403297&action=review

> LayoutTests/platform/gtk/TestExpectations:3964
> -webkit.org/b/183611 webkit.org/b/198830 media/context-menu-actions.html [ Failure Crash ]
> +webkit.org/b/198830 media/context-menu-actions.html [ Crash ]

So now this test is no longer flaky on GTK? Was this an intended change? Is this expected to always crash now?
Comment 21 Enrique Ocaña 2020-07-02 02:39:00 PDT
Comment on attachment 403297 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=403297&action=review

>> LayoutTests/platform/gtk/TestExpectations:3964
>> +webkit.org/b/198830 media/context-menu-actions.html [ Crash ]
> 
> So now this test is no longer flaky on GTK? Was this an intended change? Is this expected to always crash now?

I fixed the flakiness (the test no longer fails), but the crash still can happen sometimes (not always, we could call it a flaky crash) and is tracked on bug 198830, out of the scope of this bug.
Comment 22 Philippe Normand 2020-07-02 02:41:31 PDT
Comment on attachment 403297 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=403297&action=review

>>> LayoutTests/platform/gtk/TestExpectations:3964
>>> +webkit.org/b/198830 media/context-menu-actions.html [ Crash ]
>> 
>> So now this test is no longer flaky on GTK? Was this an intended change? Is this expected to always crash now?
> 
> I fixed the flakiness (the test no longer fails), but the crash still can happen sometimes (not always, we could call it a flaky crash) and is tracked on bug 198830, out of the scope of this bug.

OK so the new expectation should be [ Pass Crash ] I think...
Comment 23 Michael Catanzaro 2020-07-02 06:30:41 PDT
(In reply to Philippe Normand from comment #22)
> OK so the new expectation should be [ Pass Crash ] I think...

Yup.
Comment 24 Enrique Ocaña 2020-07-02 06:45:16 PDT
For reference, I've corrected the TestExpectations line in bug 213877.