scala-js-macrotask-executor icon indicating copy to clipboard operation
scala-js-macrotask-executor copied to clipboard

Setup Safari ci

Open armanbilge opened this issue 4 years ago • 6 comments

Towards #18.

armanbilge avatar Sep 07 '21 12:09 armanbilge

This turned out to be a bigger yak than I hoped. tl;dr scala-js-selenium-env likes to spin-up many instances of browsers, which works fine for Firefox/Chrome but makes Safari very angry. So this needs some way to close() / quit the Safari instance and/or not create so many of them.

armanbilge avatar Sep 12 '21 15:09 armanbilge

You can turn off parallel testing with

Test / parallelExecution := false

which will in turn create only one browser window.

sjrd avatar Sep 12 '21 15:09 sjrd

Thanks, I'll try that.

armanbilge avatar Sep 12 '21 15:09 armanbilge

Still getting

org.openqa.selenium.SessionNotCreatedException: Could not create a session: The Safari instance is already paired with another WebDriver session.

armanbilge avatar Sep 12 '21 16:09 armanbilge

@sjrd the problem is it still seems to be creating two sessions back-to-back ... any ideas about this? Thanks. https://github.com/scala-js/scala-js-macrotask-executor/pull/19/checks?check_run_id=3580303613#step:8:39

armanbilge avatar Sep 12 '21 16:09 armanbilge

@sjrd sorry to bug you about this one again. I think I have a guess what might be happening.

To recap, the problem is that sometimes, non-deterministically there are two Safari sessions being created (which Safari does not allow). Note that I've disabled parallel execution, limited global concurrency, and am only running core/test in CI (not test on the root aggregate and not for any other projects).

2022-04-28 20:00:50.564Z  info [DefaultDriverProvider] Creating a new session for Capabilities {browserName: safari, javascriptEnabled: true, safari.options: {technologyPreview: false}} 
2022-04-28 20:00:54.462Z  info [ProtocolHandshake] Detected dialect: W3C 
2022-04-28 20:00:54.859Z  info [DefaultDriverProvider] Creating a new session for Capabilities {browserName: safari, javascriptEnabled: true, safari.options: {technologyPreview: false}} 
...
 [error] Caused by: org.openqa.selenium.SessionNotCreatedException: Could not create a session: The Safari instance is already paired with another WebDriver session.

Trying to chase this down, my best guess is that the issue lies here: https://github.com/scala-js/scala-js/blob/0708917912938714d52be1426364f78a3d1fd269/test-adapter/src/main/scala/org/scalajs/testing/adapter/TestAdapter.scala#L120

IIUC, if the getRunnerForThread() method gets invoked multiple times from different threads, you can end up with more than one session. This would explain why this failure is non-deterministic.

Any thoughts/ideas? Thanks :)

armanbilge avatar Apr 28 '22 20:04 armanbilge