{"action":"opened","issue":{"url":"https://api.github.com/repos/SeleniumHQ/selenium/issues/2226","repository_url":"https://api.github.com/repos/SeleniumHQ/selenium","labels_url":"https://api.github.com/repos/SeleniumHQ/selenium/issues/2226/labels{/name}","comments_url":"https://api.github.com/repos/SeleniumHQ/selenium/issues/2226/comments","events_url":"https://api.github.com/repos/SeleniumHQ/selenium/issues/2226/events","html_url":"https://github.com/SeleniumHQ/selenium/issues/2226","id":158890916,"number":2226,"title":"Issue with running FirefoxDriver in threaded environment (Java)","user":{"login":"dmand","id":668589,"avatar_url":"https://avatars.githubusercontent.com/u/668589?v=3","gravatar_id":"","url":"https://api.github.com/users/dmand","html_url":"https://github.com/dmand","followers_url":"https://api.github.com/users/dmand/followers","following_url":"https://api.github.com/users/dmand/following{/other_user}","gists_url":"https://api.github.com/users/dmand/gists{/gist_id}","starred_url":"https://api.github.com/users/dmand/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dmand/subscriptions","organizations_url":"https://api.github.com/users/dmand/orgs","repos_url":"https://api.github.com/users/dmand/repos","events_url":"https://api.github.com/users/dmand/events{/privacy}","received_events_url":"https://api.github.com/users/dmand/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2016-06-07T10:34:45Z","updated_at":"2016-06-07T10:34:45Z","closed_at":null,"body":"OS:   Ubuntu Linux 14.04\r\nSelenium Version:  2.53.0\r\nBrowser:  Firefox\r\nBrowser Version: 46.0.1\r\n\r\n---------------\r\n\r\nConsider the following program:\r\n```java\r\npackage seleniumdemo;\r\n\r\nimport org.openqa.selenium.By;\r\nimport org.openqa.selenium.WebDriver;\r\nimport org.openqa.selenium.firefox.FirefoxDriver;\r\nimport org.openqa.selenium.chrome.ChromeDriver;\r\n\r\nimport java.util.*;\r\nimport java.util.concurrent.ExecutionException;\r\nimport java.util.concurrent.ExecutorService;\r\nimport java.util.concurrent.Executors;\r\nimport java.util.concurrent.Future;\r\nimport java.util.logging.Logger;\r\n\r\npublic class Runner {\r\n    private static final Logger log = Logger.getLogger(Runner.class.getName());\r\n\r\n    public static void main(String[] args) throws ExecutionException, InterruptedException {\r\n        ExecutorService executor = Executors.newFixedThreadPool(6);\r\n\r\n        ArrayList<Future> futures = new ArrayList<>();\r\n\r\n        long startTime = System.currentTimeMillis();\r\n        log.info(\"Starting tasks\");\r\n        for(int i = 0; i < 100; i++) {\r\n            Future future = executor.submit(new Runnable() {\r\n                @Override\r\n                public void run() {\r\n                    WebDriver driver = new FirefoxDriver();\r\n                    driver.get(\"http://blazedemo.com\");\r\n                    driver.findElement(By.cssSelector(\"input.btn.btn-primary\")).click();\r\n                    driver.findElement(By.xpath(\"//table[@class='table']/tbody/tr[4]/td[1]/input\")).click();\r\n                    driver.close();\r\n                }\r\n            });\r\n            futures.add(future);\r\n        }\r\n\r\n        log.info(\"Awaiting tasks\");\r\n        for (Future future : futures)\r\n            future.get();\r\n        log.info(\"All tasks finished\");\r\n\r\n        long endTime = System.currentTimeMillis();\r\n        double duration = (endTime - startTime) / 1000;\r\n        log.info(String.format(\"Tests took %f seconds\", duration));\r\n\r\n        executor.shutdownNow();\r\n    }\r\n\r\n}\r\n```\r\n\r\nThis simple program creates a thread pool of 6 threads and then attempts to execute 100 simple  WebDriver tasks in parallel, distributed between these threads. It takes ~4 minutes to complete when using FirefoxDriver (and i can obverse that at most two instances of Firefox are opened at the same time, most of the time it's only one instance). If i replace FirefoxDriver with ChromeDriver - this program takes only ~1 minute to complete (and i can observe all 6 browsers opened at the same time).\r\n\r\nI don't think that this behaviour is expected, so it's probably a bug on FirefoxDriver side.\r\n\r\nHere's the JVM thread dump in the middle of execution:\r\n```\r\n\"pool-1-thread-6\" prio=10 tid=0x00007f205c303000 nid=0x68a0 waiting for monitor entry [0x00007f205031a000]\r\n   java.lang.Thread.State: BLOCKED (on object monitor)\r\n\tat org.openqa.selenium.internal.SocketLock.lock(SocketLock.java:81)\r\n\t- waiting to lock <0x00000007b1102948> (a java.lang.Object)\r\n\tat org.openqa.selenium.firefox.internal.NewProfileExtensionConnection.start(NewProfileExtensionConnection.java:80)\r\n\tat org.openqa.selenium.firefox.FirefoxDriver.startClient(FirefoxDriver.java:271)\r\n\tat org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:119)\r\n\tat org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:216)\r\n\tat org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:211)\r\n\tat org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:207)\r\n\tat org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:120)\r\n\tat seleniumdemo.Runner$1.run(Runner.java:29)\r\n\tat java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)\r\n\tat java.util.concurrent.FutureTask.run(FutureTask.java:262)\r\n\tat java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)\r\n\tat java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)\r\n\tat java.lang.Thread.run(Thread.java:745)\r\n\r\n\"pool-1-thread-5\" prio=10 tid=0x00007f205c301800 nid=0x689f waiting for monitor entry [0x00007f205041b000]\r\n   java.lang.Thread.State: BLOCKED (on object monitor)\r\n\tat org.openqa.selenium.internal.SocketLock.lock(SocketLock.java:81)\r\n\t- waiting to lock <0x00000007b1102948> (a java.lang.Object)\r\n\tat org.openqa.selenium.firefox.internal.NewProfileExtensionConnection.start(NewProfileExtensionConnection.java:80)\r\n\tat org.openqa.selenium.firefox.FirefoxDriver.startClient(FirefoxDriver.java:271)\r\n\tat org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:119)\r\n\tat org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:216)\r\n\tat org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:211)\r\n\tat org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:207)\r\n\tat org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:120)\r\n\tat seleniumdemo.Runner$1.run(Runner.java:29)\r\n\tat java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)\r\n\tat java.util.concurrent.FutureTask.run(FutureTask.java:262)\r\n\tat java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)\r\n\tat java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)\r\n\tat java.lang.Thread.run(Thread.java:745)\r\n\r\n\"pool-1-thread-4\" prio=10 tid=0x00007f205c300000 nid=0x689e waiting for monitor entry [0x00007f205051c000]\r\n   java.lang.Thread.State: BLOCKED (on object monitor)\r\n\tat org.openqa.selenium.internal.SocketLock.lock(SocketLock.java:81)\r\n\t- waiting to lock <0x00000007b1102948> (a java.lang.Object)\r\n\tat org.openqa.selenium.firefox.internal.NewProfileExtensionConnection.start(NewProfileExtensionConnection.java:80)\r\n\tat org.openqa.selenium.firefox.FirefoxDriver.startClient(FirefoxDriver.java:271)\r\n\tat org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:119)\r\n\tat org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:216)\r\n\tat org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:211)\r\n\tat org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:207)\r\n\tat org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:120)\r\n\tat seleniumdemo.Runner$1.run(Runner.java:29)\r\n\tat java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)\r\n\tat java.util.concurrent.FutureTask.run(FutureTask.java:262)\r\n\tat java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)\r\n\tat java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)\r\n\tat java.lang.Thread.run(Thread.java:745)\r\n\r\n\"pool-1-thread-3\" prio=10 tid=0x00007f205c2fe000 nid=0x689d waiting for monitor entry [0x00007f205061d000]\r\n   java.lang.Thread.State: BLOCKED (on object monitor)\r\n\tat org.openqa.selenium.internal.SocketLock.lock(SocketLock.java:81)\r\n\t- waiting to lock <0x00000007b1102948> (a java.lang.Object)\r\n\tat org.openqa.selenium.firefox.internal.NewProfileExtensionConnection.start(NewProfileExtensionConnection.java:80)\r\n\tat org.openqa.selenium.firefox.FirefoxDriver.startClient(FirefoxDriver.java:271)\r\n\tat org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:119)\r\n\tat org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:216)\r\n\tat org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:211)\r\n\tat org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:207)\r\n\tat org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:120)\r\n\tat seleniumdemo.Runner$1.run(Runner.java:29)\r\n\tat java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)\r\n\tat java.util.concurrent.FutureTask.run(FutureTask.java:262)\r\n\tat java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)\r\n\tat java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)\r\n\tat java.lang.Thread.run(Thread.java:745)\r\n\r\n\"Forwarding newSession on session null to remote\" prio=10 tid=0x00007f205c2fc800 nid=0x689c runnable [0x00007f205071d000]\r\n   java.lang.Thread.State: RUNNABLE\r\n\tat java.net.SocketInputStream.socketRead0(Native Method)\r\n\tat java.net.SocketInputStream.read(SocketInputStream.java:152)\r\n\tat java.net.SocketInputStream.read(SocketInputStream.java:122)\r\n\tat org.apache.http.impl.io.SessionInputBufferImpl.streamRead(SessionInputBufferImpl.java:139)\r\n\tat org.apache.http.impl.io.SessionInputBufferImpl.fillBuffer(SessionInputBufferImpl.java:155)\r\n\tat org.apache.http.impl.io.SessionInputBufferImpl.readLine(SessionInputBufferImpl.java:284)\r\n\tat org.apache.http.impl.conn.DefaultHttpResponseParser.parseHead(DefaultHttpResponseParser.java:140)\r\n\tat org.apache.http.impl.conn.DefaultHttpResponseParser.parseHead(DefaultHttpResponseParser.java:57)\r\n\tat org.apache.http.impl.io.AbstractMessageParser.parse(AbstractMessageParser.java:261)\r\n\tat org.apache.http.impl.DefaultBHttpClientConnection.receiveResponseHeader(DefaultBHttpClientConnection.java:165)\r\n\tat org.apache.http.impl.conn.CPoolProxy.receiveResponseHeader(CPoolProxy.java:167)\r\n\tat org.apache.http.protocol.HttpRequestExecutor.doReceiveResponse(HttpRequestExecutor.java:272)\r\n\tat org.apache.http.protocol.HttpRequestExecutor.execute(HttpRequestExecutor.java:124)\r\n\tat org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:271)\r\n\tat org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:184)\r\n\tat org.apache.http.impl.execchain.RetryExec.execute(RetryExec.java:88)\r\n\tat org.apache.http.impl.execchain.RedirectExec.execute(RedirectExec.java:110)\r\n\tat org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:184)\r\n\tat org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:71)\r\n\tat org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:55)\r\n\tat org.openqa.selenium.remote.internal.ApacheHttpClient.fallBackExecute(ApacheHttpClient.java:144)\r\n\tat org.openqa.selenium.remote.internal.ApacheHttpClient.execute(ApacheHttpClient.java:90)\r\n\tat org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:142)\r\n\tat org.openqa.selenium.firefox.internal.NewProfileExtensionConnection.execute(NewProfileExtensionConnection.java:160)\r\n\tat org.openqa.selenium.firefox.FirefoxDriver$LazyCommandExecutor.execute(FirefoxDriver.java:380)\r\n\tat org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:644)\r\n\tat org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:249)\r\n\tat org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:131)\r\n\tat org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:216)\r\n\tat org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:211)\r\n\tat org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:207)\r\n\tat org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:120)\r\n\tat seleniumdemo.Runner$1.run(Runner.java:29)\r\n\tat java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)\r\n\tat java.util.concurrent.FutureTask.run(FutureTask.java:262)\r\n\tat java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)\r\n\tat java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)\r\n\tat java.lang.Thread.run(Thread.java:745)\r\n\r\n\"pool-1-thread-1\" prio=10 tid=0x00007f205c2f2800 nid=0x689b waiting on condition [0x00007f205081f000]\r\n   java.lang.Thread.State: TIMED_WAITING (sleeping)\r\n\tat java.lang.Thread.sleep(Native Method)\r\n\tat org.openqa.selenium.internal.SocketLock.lock(SocketLock.java:91)\r\n\t- locked <0x00000007b1102948> (a java.lang.Object)\r\n\tat org.openqa.selenium.firefox.internal.NewProfileExtensionConnection.start(NewProfileExtensionConnection.java:80)\r\n\tat org.openqa.selenium.firefox.FirefoxDriver.startClient(FirefoxDriver.java:271)\r\n\tat org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:119)\r\n\tat org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:216)\r\n\tat org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:211)\r\n\tat org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:207)\r\n\tat org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:120)\r\n\tat seleniumdemo.Runner$1.run(Runner.java:29)\r\n\tat java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)\r\n\tat java.util.concurrent.FutureTask.run(FutureTask.java:262)\r\n\tat java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)\r\n\tat java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)\r\n\tat java.lang.Thread.run(Thread.java:745)\r\n```\r\n\r\nFrom the looks of it, most of the threads are locked in `NewProfileExtensionConnection.start()` that uses `SocketLock`."}}
{"actor":{"display_login":"dmand"}}