results-collection icon indicating copy to clipboard operation
results-collection copied to clipboard

Safari Tech Preview test results are different on local machine

Open beaufortfrancois opened this issue 7 years ago • 25 comments

I'm seeing some timeouts on Picture-in-Picture idl harness tests that I'm not seeing locally with Safari Tech Preview Release 67 (on macOS 10.13.6).

Note that it is the same with Safari stable locally.

Local machine image

web-platform-tests dashboard image

beaufortfrancois avatar Oct 17 '18 13:10 beaufortfrancois

@jugglinmike do you have logs available for these runs, to see if they provide any clues?

foolip avatar Oct 17 '18 13:10 foolip

Note that I actually get timeouts when running from command line (see below) Same for Safari Stable and Tech Preview.

./wpt run safari picture-in-picture/idlharness.window.html

Running 1 tests in web-platform-tests



  ▶ TIMEOUT [expected OK] /picture-in-picture/idlharness.window.html



  ▶ Unexpected subtest result in /picture-in-picture/idlharness.window.html:

  │ TIMEOUT [expected PASS] idl_test setup

  └   → Test timed out

beaufortfrancois avatar Oct 17 '18 14:10 beaufortfrancois

It turns out that if I attach <video> to document.body, test doesn't time out anymore. Note that test times out because loadedmetadata event is NOT fired when <video> is not attached to document.body. It seems to be specific to running from command line (using Automation mode).

 function loadVideo(activeDocument, sourceUrl) {
   return new Promise((resolve, reject) => {
     const document = activeDocument || window.document;
     const video = document.createElement('video');
+    document.body.appendChild('video'); // Needed only for Safari Automation mode.
     video.src = sourceUrl || getVideoURI('/media/movie_5');
     video.onloadedmetadata = () => { resolve(video); };
     video.onerror = error => { reject(error); };
   });
 }

https://github.com/web-platform-tests/wpt/blob/2ac8a23714d941c1a544f2b897a3c77f65425ae9/picture-in-picture/resources/picture-in-picture-helpers.js

beaufortfrancois avatar Oct 17 '18 16:10 beaufortfrancois

@burg any idea what's up here with Safari behaving differently under automation?

gsnedders avatar Oct 17 '18 16:10 gsnedders

I'm not quite sure what "Automation mode" means. Does this run via WebDriver, or not?

burg avatar Oct 18 '18 16:10 burg

Yes @burg

beaufortfrancois avatar Oct 18 '18 19:10 beaufortfrancois

What do I run to test this locally from the wpt repository with a custom driver path?

burg avatar Oct 18 '18 21:10 burg

Two avenues come to mind:

  • Is the window visible on the screen? If not, this might cause trouble. A video recording from a failing run would help triage this aspect.
  • There may be a misconfiguration of the Automation window. safaridriver may need to set WKWebViewConfiguration._mediaDataLoadsAutomatically = YES to behave the same as Safari, but I can't check this easily.

burg avatar Oct 18 '18 21:10 burg

@burg

./wpt run safari --webdriver-binary /Applications/Safari\ Technology\ Preview.app/Contents/MacOS/safaridriver picture-in-picture/idlharness.window.html

gsnedders avatar Oct 18 '18 22:10 gsnedders

--channel=preview should also work after https://github.com/web-platform-tests/wpt/pull/13460 too.

foolip avatar Oct 18 '18 22:10 foolip

Great, I'm tracking this internally as rdar://problem/45384220. I'll update this issue when I figure it out.

burg avatar Oct 19 '18 00:10 burg

@burg, here's a 28s screen recording: https://photos.app.goo.gl/qsxSgHijiWEfVW649

beaufortfrancois avatar Oct 19 '18 06:10 beaufortfrancois

That's cool :)

Note that if you ever want to run a single test and don't want the window to stay open you can use --no-pause.

foolip avatar Oct 19 '18 17:10 foolip

FWIW @jernoble and I noticed that HTMLMediaElement logs were not present in the Console.app to help debugging this.

Moreover, on @padenot's machine, test was actually flaky, not always a timeout.

Update: I was able to get flakyness as well.

beaufortfrancois avatar Oct 26 '18 14:10 beaufortfrancois

@burg Let me know if I can help.

beaufortfrancois avatar Oct 29 '18 06:10 beaufortfrancois

@beaufortfrancois once https://github.com/web-platform-tests/wpt/pull/13769 has landed, you should be able to submit a PR that tweaks .azure-pipelines.yml a bit to run the test using Safari Technology Preview, for a second data point. If it also is different from a local machine, then at least it's easy (ish) to iterate on the Azure Pipelines setup to work out why it's different.

foolip avatar Oct 31 '18 10:10 foolip

@burg Any progress on this issue?

beaufortfrancois avatar Nov 21 '18 07:11 beaufortfrancois

I executed ./wpt run --channel=preview safari picture-in-picture/idlharness.window.html again this morning and I'm still seeing the timeout issue. As I said in https://github.com/web-platform-tests/results-collection/issues/619#issuecomment-430696562, attaching the video to the body fixes the timeout.

@burg Were you able to figure this one out? @jernoble may help as well to diagnose. @foolip Is there anything else I can do as well to help?

$ ./wpt run --channel=preview safari picture-in-picture/idlharness.window.html 
Running 1 tests in web-platform-tests

  ▶ TIMEOUT [expected OK] /picture-in-picture/idlharness.window.html

  ▶ Unexpected subtest result in /picture-in-picture/idlharness.window.html:
  │ TIMEOUT [expected PASS] idl_test setup
  └   → Test timed out

$ ./wpt run safari picture-in-picture/idlharness.window.html 
safaridriver: unrecognized option `--version'
Running 1 tests in web-platform-tests

  ▶ TIMEOUT [expected OK] /picture-in-picture/idlharness.window.html

  ▶ Unexpected subtest result in /picture-in-picture/idlharness.window.html:
  │ TIMEOUT [expected PASS] idl_test setup
  └   → Test timed out

https://wpt.fyi/results/picture-in-picture/idlharness.window.html?label=master&label=experimental&product=chrome&product=safari

beaufortfrancois avatar Jan 22 '19 07:01 beaufortfrancois

@beaufortfrancois if you're getting unrecognized option --version'then you're probably not using the most recent Safari Technology Preview. Does/Applications/Safari Technology Preview.app/Contents/MacOS/safaridriver --version` also give you that error? If so can you update it?

The problem, however, seems to be related to picture-in-picture-helpers.js. Can you just attach the video to the document if that fixes the problem? You could file a WebKit bug and link to it in a comment.

foolip avatar Jan 22 '19 09:01 foolip

Sorry, there were two ./wpt run invocations in your code block, and only the second one shows the warning. That's as expected until the next Safari stable release.

foolip avatar Jan 22 '19 09:01 foolip

My goal with these tests is to make sure a video doesn't have to be attached to the DOM to be able to enter Picture-in-Picture, so it should fail (because it is not supported yet) but not time out.

To be clear, this issue happens only in SafariDriver, not Safari browser.

beaufortfrancois avatar Jan 22 '19 10:01 beaufortfrancois

@beaufortfrancois is there anything in https://github.com/WebKit/webkit/blob/master/Source/WebCore/html/HTMLMediaElement.cpp that provides hints? Without reading code, my guess would be that the window isn't considered focused or visible when run under automation, and that there's some code that waits for it to be focused/visible.

foolip avatar Jan 22 '19 11:01 foolip

It may be mediaDataLoadsAutomatically as suggested earlier by @burg but I'm not sure.

beaufortfrancois avatar Jan 22 '19 11:01 beaufortfrancois

I haven't had time to look into this, but it's still being tracked.

burg avatar Jan 22 '19 18:01 burg

@burg Is there any chance you can prioritize this or we can help?

beaufortfrancois avatar Jan 23 '19 07:01 beaufortfrancois