New issue
Advanced search Search tips
Starred by 28 users

Issue metadata

Status: Started
Owner:



Sign in to add a comment

Chromedriver leaves forked Chrome instances hanging with large CPU load

Reported by foldig...@gmail.com, Mar 12

Issue description

Issue Description:
Whenever a test started with ChromeDriver (2.36 - Latest) it launches a Chrome instance (65 - Latest) then the forked instance stays as a process after the test finished. It is running with high CPU load (~25-30% per each). It can be reproduced multiple times so that the CPU usage can make the endpoint crawl. 

Steps to reproduce (if relevant, you MUST provide a simplified html page or
link to public site):
0. Prerequisites:
- ChromeDriver (2.36) 
- Chrome 65 x64
- Windows 10 x64
- Desktop
- NodeJS (v8.10.0)
1. Run at least 1 failing test with CucumberJS and Protractor ("cucumber": "^1.3.0","protractor": "^5.1.1").
2. Examine the processes in Task manager.

Actual result:
2. The chromedriver.exe stops 4-5 secs after the tests completed. Then the forked Chrome instances stay in the background as running processes with huge CPU usage.

Expected result:
2. The chromedriver.exe should stop and its Chrome instances as well.





 
i205^cimgpsh_orig.png
90.5 KB View Download
Since the latest stable Chrome version (v65) + latest Chromedriver(2.36) I can reproduce this issue whenever I trigger them with my tests.

Symptoms:
Executing tests resulted in ~100% of CPU load and additional memory usage. This behaviour negatively affects my test results.
Closing the chrome instances, some of them are still running in the background.

My expectation in terms of test execution is to automatically close the chrome/chromedriver and all of its instances (started by script) by finishing the test run.
This is the status of the task manager on windows after executing a single threaded test with ChromeDriver v2.36. The test has been crushed by the overloaded CPU.
chrome.png
47.5 KB View Download
Things I've tried but did not resolve the issue:
reinstall chrome (v65 x64)
disable and remove extensions
run it without a single chrome instance open in the background
delete npm-cache
redo npm i
update to npm 5.7 (latest)
update to node 8 (latest LTS)
update windows 10: Version 10.0.16299.248

Any other ideas?
Labels: Needs-Feedback
Please share your protractor project code so we could run it on our side.
Please describe the repro steps for your code.
Also please attach the chromedriver verbose log file to this bug.




Regarding #4

I am unable to share it since it is a corporate project.




I have also tested in the following configs and it is the same:
 - Chrome v65 / Chromedriver 2.33
 - Chrome v65 / Chromedriver 2.34
 - Chrome v65 / Chromedriver 2.35
 - Chrome v65 / Chromedriver 2.36
 - Chrome DEV v66 / Chromedriver 2.36

Note, that this issue did not exist with the following configs and before:
 - Chrome v64 / Chromedriver 2.35
 - Chrome DEV v66 / Chromedriver 2.35
 - Chrome BETA v65 / Chromedriver 2.35

There was no change neither on framework nor on Protractor side, both working scripts and current are using same configuration and code base.

I might be able to attack a log file which does not contain sensitive information. Which part of logs would be necessary to have? (I guess initialization of drivers/devtools and destuction of drivers.)

Comment 7 Deleted

You have opts.addArguments("--no-sandbox"); in your code? I have a similar problem if I use this option
Yes, it seems that was the problem because when we removed it the issue is fixed.
Do you have any info about why it is causing this issue?
No, I just ran into a similar problem, and I found out that this option affects the repeatability.
Sorry, but without a repro code we can't tell you what was the problem.
Please anybody of you provide a repro code.

We were not able to reproduce this issue on our side.

Starting ChromeDriver 2.37.543619 (a237acd3116cac3b3f0da42a000502ce3fafcb23) on port 31953
Only local connections are allowed.
Mar 21, 2018 1:30:28 AM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Detected dialect: OSS

===============================================
Default Suite
Total tests run: 1, Failures: 0, Skips: 0
===============================================

The following code was run with launched multiple instances of Chrome.

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;

import java.util.concurrent.TimeUnit;

public class Issue2311 {

  private static WebDriver driver;

  @BeforeClass
  public static void setup() {
    ChromeOptions opts = new ChromeOptions();
    opts.addArguments("--no-sandbox");
    driver = new ChromeDriver(opts);
    driver.manage().window().maximize();
    driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
  }

  @Test
  public void test(){
    driver.get("https://google.com");
    //we have 6 chrome.exe processes
    driver.quit();
    //2 processes chrome.exe are not stop
  }
}

We have a same issue on Win10 & Win7 machines with Chrome x64 v65.0.3325.181 and Chrome driver v.2.37 (v.2.36 also doesn't help).
In Task Manager I see 2 instances(each for created session) of Chrome hanging in processes and eating ~12% of CPU on i7 4790, which is really painful.

In %TEMP% folder I see two folders scoped_dir%ID%, where I have only file with name CrashpadMetrics-active.pma and size 1024 KB. I can't delete this file(and folders) until I kill Chrome processes that hang.
Attaching one of the file here.
CrashpadMetrics-active.pma
1.0 MB Download
You can monitor chromedriver.exe process with procmon tool.

Please track in your test scenario how many driver.quit(); are being called. If all the driver.quit(); calls passed true but you still see chromedriver.exe is showing up in task manager, then please attach the procmon.pml and chromedriver verbose log files to this bug.

Also I would suggest you to take a look at events logs in your system.


I experience the exact same issue. I am running the 

ChromeDriver 2.37.543627
Java lib.    3.11.0
Chrome       65.0.3325.181

I also have Version 68.0.3399.0 (Official Build) canary (64-bit) installed but I am not running any test on it. Here is the log entry for class submitted by khachatryan@chromium.org which reads as follows 

////////////////////////////////////////

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;

import java.util.concurrent.TimeUnit;

public class Issue2311 {


    private static WebDriver driver;

    @BeforeClass
    public static void setup() {
        System.setProperty("webdriver.chrome.logfile", "c:\\temp\\chromedriver.log");
        System.setProperty("webdriver.chrome.verboseLogging", "true");
        System.setProperty("webdriver.chrome.driver", "c:\\temp\\chromedriver.exe");
        ChromeOptions opts = new ChromeOptions();
        opts.addArguments("--no-sandbox");
        driver = new ChromeDriver(opts);
        driver.manage().window().maximize();
        driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
    }

    @Test
    public void test(){
        driver.get("https://google.com");
        //we have 6 chrome.exe processes

        driver.quit();
        //2 processes chrome.exe are not stop
    }
}
 
////////////////////////////////////////

I tried the same thing with the a AfterClass fixture which has the same behaviour. 



chromedriver.log
23.7 KB View Download
Please run your code with the latest Chromedriver and Chrome versions and see if this issue is reproduced.

Just to add here, I've also been having the same issue since Chrome and Chromedriver both updated.  I am running the most recent version of both, but still having the CPU problem.
Chromedriver: 2.38.552522
Chrome: 66.0.3359.139
The most recent Chromium builds you can get from here: http://www.chromium.org/getting-involved/dev-channel


We couldn't reproduce this issue by running customer's pointed code.


Still have the issue with the latest Chrome (66.0.3359.139), latest ChromeDriver (2.38 and the library 3.11.0). Find included the driver log, the pml and a screen capture video if the issue as it happens. 
Issue2311.driver.log
21.9 KB View Download
Issue2311.flv
14.6 MB Download
This code runs on our Windows machine without overloading the CPU.
Please run procmon tool and attach the PML file to this bug.
Also please take a look at events logs on your Windows machine.

Comment 24 Deleted

There is no attachment.
Simply you should attach the PNL file to this bug but not send the attachment via email.


Sorry for that trouble but, I might have capture the pml wrong, but it makes 151mb hence having it sent through email.  
Please set the ProcMon filter for chrome and chromedriver processes only and get the PML log file while you run your test.

There you go
Issue2311.B.PML.zip
16.3 MB Download
Issue2311.B.log
22.7 KB View Download
Don't know if that can help narrowing down the issue but it appears that by removing the '--no-sandbox' I no longer have the issue. In other words all the instances of chrome close, apparently properly.
Project Member

Comment 31 by johnchen@chromium.org, May 1

Labels: -Needs-Feedback Pri-2
Owner: johnchen@chromium.org
Status: Started (was: Unconfirmed)
Project Member

Comment 32 by johnchen@chromium.org, May 1

 Issue 2393  has been merged into this issue.
Happened to me 2 on windows 10 '--no-sandbox' creating many instances that doesn't quit after process close.
Try "prevent chromge working at background" might help.
Project Member

Comment 34 by bugdroid1@chromium.org, May 8

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/3edba584fc9d669b16f26a6516dc080197144485

commit 3edba584fc9d669b16f26a6516dc080197144485
Author: John Chen <johnchen@chromium.org>
Date: Tue May 08 04:38:49 2018

[ChromeDriver] Use Browser.close to quit

Currently, ChromeDriver closes desktop Chrome by simply killing the
top-level Chrome process. This isn't graceful, and causes problems
in some scenarios. This commit sends a Browser.close command to close
the browser gracefully.

Bug: chromedriver:2311
Change-Id: Idec9338b094f0aab89022b8453dd2a98268ad1e7
Reviewed-on: https://chromium-review.googlesource.com/1037585
Commit-Queue: John Chen <johnchen@chromium.org>
Reviewed-by: Jonathon Kereliuk <kereliuk@chromium.org>
Cr-Commit-Position: refs/heads/master@{#556689}
[modify] https://crrev.com/3edba584fc9d669b16f26a6516dc080197144485/chrome/test/chromedriver/chrome/chrome_desktop_impl.cc

Project Member

Comment 35 by bugdroid1@chromium.org, May 8

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/13812bfec965c5811dcc4cfb403138831b675d81

commit 13812bfec965c5811dcc4cfb403138831b675d81
Author: John Chen <johnchen@chromium.org>
Date: Tue May 08 06:08:58 2018

Revert "[ChromeDriver] Use Browser.close to quit"

This reverts commit 3edba584fc9d669b16f26a6516dc080197144485.

Reason for revert: Code not working properly on Mac

Original change's description:
> [ChromeDriver] Use Browser.close to quit
> 
> Currently, ChromeDriver closes desktop Chrome by simply killing the
> top-level Chrome process. This isn't graceful, and causes problems
> in some scenarios. This commit sends a Browser.close command to close
> the browser gracefully.
> 
> Bug: chromedriver:2311
> Change-Id: Idec9338b094f0aab89022b8453dd2a98268ad1e7
> Reviewed-on: https://chromium-review.googlesource.com/1037585
> Commit-Queue: John Chen <johnchen@chromium.org>
> Reviewed-by: Jonathon Kereliuk <kereliuk@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#556689}

TBR=johnchen@chromium.org,kereliuk@chromium.org

Change-Id: I53f310a7745586fdcbebb1edd58b5eb0d7873475
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: chromedriver:2311
Reviewed-on: https://chromium-review.googlesource.com/1049146
Reviewed-by: John Chen <johnchen@chromium.org>
Commit-Queue: John Chen <johnchen@chromium.org>
Cr-Commit-Position: refs/heads/master@{#556708}
[modify] https://crrev.com/13812bfec965c5811dcc4cfb403138831b675d81/chrome/test/chromedriver/chrome/chrome_desktop_impl.cc

Project Member

Comment 36 by bugdroid1@chromium.org, May 10

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/47c575abefd23410eb2b4023a06b171dd3a8b64a

commit 47c575abefd23410eb2b4023a06b171dd3a8b64a
Author: John Chen <johnchen@chromium.org>
Date: Thu May 10 19:10:27 2018

Reland "[ChromeDriver] Use Browser.close to quit"

This is a reland of 3edba584fc9d669b16f26a6516dc080197144485

Original change's description:
> [ChromeDriver] Use Browser.close to quit
>
> Currently, ChromeDriver closes desktop Chrome by simply killing the
> top-level Chrome process. This isn't graceful, and causes problems
> in some scenarios. This commit sends a Browser.close command to close
> the browser gracefully.
>
> Bug: chromedriver:2311
> Change-Id: Idec9338b094f0aab89022b8453dd2a98268ad1e7
> Reviewed-on: https://chromium-review.googlesource.com/1037585
> Commit-Queue: John Chen <johnchen@chromium.org>
> Reviewed-by: Jonathon Kereliuk <kereliuk@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#556689}

TBR=kereliuk@chromium.org

Bug: chromedriver:2311
Change-Id: I302e064532fdadb1b6e40d53fbfe3cf72601a731
Reviewed-on: https://chromium-review.googlesource.com/1054117
Reviewed-by: John Chen <johnchen@chromium.org>
Commit-Queue: John Chen <johnchen@chromium.org>
Cr-Commit-Position: refs/heads/master@{#557613}
[modify] https://crrev.com/47c575abefd23410eb2b4023a06b171dd3a8b64a/chrome/test/chromedriver/chrome/chrome_desktop_impl.cc

If you want an example of how to reproduce it - have a look here: https://github.com/angular/protractor/issues/4690
Project Member

Comment 38 by bugdroid1@chromium.org, May 29

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/355a4c84b0d2ea3e6890c0f7ad88c3e91c712f9e

commit 355a4c84b0d2ea3e6890c0f7ad88c3e91c712f9e
Author: John Chen <johnchen@chromium.org>
Date: Tue May 29 19:04:16 2018

Revert "Reland "[ChromeDriver] Use Browser.close to quit""

This reverts commit 47c575abefd23410eb2b4023a06b171dd3a8b64a.

Reason for revert: Causes noticeable slowdown on Windows and some Mac.
Reverting for now, and will re-visit after ChromeDriver 2.39 release.

Original change's description:
> Reland "[ChromeDriver] Use Browser.close to quit"
> 
> This is a reland of 3edba584fc9d669b16f26a6516dc080197144485
> 
> Original change's description:
> > [ChromeDriver] Use Browser.close to quit
> >
> > Currently, ChromeDriver closes desktop Chrome by simply killing the
> > top-level Chrome process. This isn't graceful, and causes problems
> > in some scenarios. This commit sends a Browser.close command to close
> > the browser gracefully.
> >
> > Bug: chromedriver:2311
> > Change-Id: Idec9338b094f0aab89022b8453dd2a98268ad1e7
> > Reviewed-on: https://chromium-review.googlesource.com/1037585
> > Commit-Queue: John Chen <johnchen@chromium.org>
> > Reviewed-by: Jonathon Kereliuk <kereliuk@chromium.org>
> > Cr-Commit-Position: refs/heads/master@{#556689}
> 
> TBR=kereliuk@chromium.org
> 
> Bug: chromedriver:2311
> Change-Id: I302e064532fdadb1b6e40d53fbfe3cf72601a731
> Reviewed-on: https://chromium-review.googlesource.com/1054117
> Reviewed-by: John Chen <johnchen@chromium.org>
> Commit-Queue: John Chen <johnchen@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#557613}

TBR=johnchen@chromium.org,kereliuk@chromium.org

# Not skipping CQ checks because original CL landed > 1 day ago.

Bug: chromedriver:2311
Change-Id: Iabef56858621949e02e431e9df4a03649572f5da
Reviewed-on: https://chromium-review.googlesource.com/1077027
Reviewed-by: John Chen <johnchen@chromium.org>
Commit-Queue: John Chen <johnchen@chromium.org>
Cr-Commit-Position: refs/heads/master@{#562535}
[modify] https://crrev.com/355a4c84b0d2ea3e6890c0f7ad88c3e91c712f9e/chrome/test/chromedriver/chrome/chrome_desktop_impl.cc

 Issue 2447  has been merged into this issue.

Sign in to add a comment