Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[4.0.0-alpha5] Selenium creates never ending Thread #8159

Closed
carsonwah opened this issue Apr 3, 2020 · 8 comments
Closed

[4.0.0-alpha5] Selenium creates never ending Thread #8159

carsonwah opened this issue Apr 3, 2020 · 8 comments

Comments

@carsonwah
Copy link

carsonwah commented Apr 3, 2020

🐛 Bug Report

After simply starting and quiting the webdriver, the browser started and quitted normally. But just the program never ends after running all the steps. I found that there is dead thread (AsyncHttpClient) left running.

Detail steps

My simple program:

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
public class SeleniumTestChromiumEdge {
    public static void main(String[] args) {
        WebDriver driver = new FirefoxDriver();
        System.out.println("Before quit");
        driver.quit();
        System.out.println("After quit");
    }
}

Callstack before WebDriver driver = new xxxxDriver();:
image

Callstack after WebDriver driver = new xxxxDriver();:
image

Callstack after driver.quit();:
image

After program ends:
image

Console output: (e.g. Firefox driver)

1585930423908   mozrunner::runner       INFO    Running command: "C:\\Program Files\\Mozilla Firefox\\firefox.exe" "-marionette" "-foreground" "-no-remote" "-profile" "C:\\Users\\TSZCHU~1\\AppData\\Local\\Temp\\rust_mozprofilezIRvii"
1585930424530   addons.webextension.doh-rollout@mozilla.org     WARN    Loading extension 'doh-rollout@mozilla.org': Reading manifest: Invalid extension permission: networkStatus
1585930425313   addons.webextension.screenshots@mozilla.org     WARN    Loading extension 'screenshots@mozilla.org': Reading manifest: Invalid extension permission: mozillaAddons
1585930425314   addons.webextension.screenshots@mozilla.org     WARN    Loading extension 'screenshots@mozilla.org': Reading manifest: Invalid extension permission: telemetry
1585930425314   addons.webextension.screenshots@mozilla.org     WARN    Loading extension 'screenshots@mozilla.org': Reading manifest: Invalid extension permission: resource://pdf.js/
1585930425314   addons.webextension.screenshots@mozilla.org     WARN    Loading extension 'screenshots@mozilla.org': Reading manifest: Invalid extension permission: about:reader*
JavaScript error: resource://gre/modules/XULStore.jsm, line 66: Error: Can't find 
profile directory.
1585930428409   Marionette      INFO    Listening on port 49442
1585930428628   Marionette      WARN    TLS certificate errors will be ignored for this session
4月 04, 2020 12:13:48 上午 org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Detected dialect: W3C
Before quit
After quit

I have tried for ChromeDriver, FirefoxDriver and EdgeDriver, in VS Code and Eclipse. Still the same problem.

This problem does not exist when running the same code with v3.14159.

Compare to the callstack from v3.14159 (after starting the driver):
image

Expected behavior

The program should ends.

Environment

OS: Windows 10
Browser:

  • Chrome Version 80.0.3987.163 (Official Build) (64-bit)
  • Firefox 74.0 (64-bit)
  • Microsoft Edge 80.0.361.109 (Official build) (64-bit)
    Browser Driver version: All in respective versions
    Language Bindings version: 4.0.0-alpha-5
    IDE: Tried in VS Code and Eclipse
@barancev
Copy link
Member

Yes, there are long-running threads, but they should not prevent stopping the VM.

Can you please get a complete thread dump and attach it here for investigation?

@alstafeev
Copy link

thread dump
thread_dump.txt

@mark-5-9
Copy link

mark-5-9 commented Aug 7, 2020

Hi, I have a use case for Selenium where I can't just use System.exit to close the JVM (like in JUnit), making this a significant issue for me. I've noticed this problem in all the 4.0.0-alpha's I've tried, including my last test using :

  • Chrome Version 85.0.4183.59 (Official Build) beta (64-bit) (Windows)
  • ChromeDriver 85.0.4183.38
  • Eclipse IDE (ran in debug mode to confirm the non-daemon threads)
  • Language Bindings version (Java) 4.0.0-alpha-6

In my test I instantiated the driver using the ChromeDriverService, but output was identical to that described above.
This issue has been raised before : #8258

@Mdillon123
Copy link

I am experiencing this never ending thread with Chromium edge and Selenium 4 alpha-4 and higher. Is there any way to gracefully close out a test besides killing the java processes?

@mark-5-9
Copy link

@Mdillon123 I believe Add shutdown hook to close AsyncHttpClient. #8763 has fixed the issue, at least in Chrome when I tested using alpha-7. It also allowed me to run the same Selenium script concurrently on 4 threads. Above that failures occurred with an interrupted sleep exception inside FluentWait, but that won't have anything to do with this problem.

@barancev barancev closed this as completed Feb 2, 2021
@barancev barancev reopened this Feb 2, 2021
@barancev
Copy link
Member

barancev commented Feb 2, 2021

Closed by mistake, reopening.

@barancev
Copy link
Member

Can you please retest in Selenium 4.0-beta-1 (released today) if the issue is still actual.

@diemol
Copy link
Member

diemol commented Mar 10, 2021

Seems beta-1 also had the issue, which was fixed by a5d5af2. It will be included in beta-2.

@diemol diemol closed this as completed Mar 10, 2021
@github-actions github-actions bot locked and limited conversation to collaborators Sep 5, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

8 participants