protractor icon indicating copy to clipboard operation
protractor copied to clipboard

PhantomJS sometimes crashes

Open mcalthrop opened this issue 12 years ago • 61 comments

I have been successfully running a fairly comprehensive suite of Protractor e2e tests using Chrome on OSX (Mavericks: 10.9.2).

We have a technical requirement to run these tests headlessly, so I swapped in PhantomJS instead of Chrome, and after 20 seconds (consistently), I get the following error:

Runner Process Exited With Error Code: 8
Fatal error: protractor exited with code: 1

Now for some more detailed information.

Here is the full error output from the grunt task I am running:

Running "protractor:phantomjs" (protractor) task
------------------------------------
PID: 9678 (capability: phantomjs #1)
------------------------------------
Starting selenium standalone server...
Selenium standalone server started at http://192.168.1.111:4444/wd/hub
/path/node_modules/protractor/node_modules/selenium-webdriver/lib/webdriver/promise.js:1562
throw error;
^
UnknownError: null
at new bot.Error (/path/node_modules/protractor/node_modules/selenium-webdriver/lib/atoms/error.js:109:18)
at Object.bot.response.checkResponse (/path/node_modules/protractor/node_modules/selenium-webdriver/lib/atoms/response.js:106:9)
at /path/node_modules/protractor/node_modules/selenium-webdriver/lib/webdriver/webdriver.js:135:24
at /path/node_modules/protractor/node_modules/selenium-webdriver/lib/goog/base.js:1178:15
at webdriver.promise.ControlFlow.runInNewFrame_ (/path/node_modules/protractor/node_modules/selenium-webdriver/lib/webdriver/promise.js:1455:20)
at notify (/path/node_modules/protractor/node_modules/selenium-webdriver/lib/webdriver/promise.js:328:12)
at notifyAll (/path/node_modules/protractor/node_modules/selenium-webdriver/lib/webdriver/promise.js:297:7)
at fulfill (/path/node_modules/protractor/node_modules/selenium-webdriver/lib/webdriver/promise.js:402:7)
at /path/node_modules/protractor/node_modules/selenium-webdriver/lib/goog/base.js:1178:15
at webdriver.promise.ControlFlow.runInNewFrame_ (/path/node_modules/protractor/node_modules/selenium-webdriver/lib/webdriver/promise.js:1455:20)
==== async task ====
    WebDriver.createSession()
at Function.webdriver.WebDriver.acquireSession_ (/path/node_modules/protractor/node_modules/selenium-webdriver/lib/webdriver/webdriver.js:132:49)
at Function.webdriver.WebDriver.createSession (/path/node_modules/protractor/node_modules/selenium-webdriver/lib/webdriver/webdriver.js:111:30)
at Builder.build (/path/node_modules/protractor/node_modules/selenium-webdriver/builder.js:105:20)
at LocalDriverProvider.getDriver (/path/node_modules/protractor/lib/driverProviders/local.dp.js:128:9)
at /path/node_modules/protractor/lib/runner.js:327:35
at _fulfilled (/path/node_modules/protractor/node_modules/q/q.js:797:54)
at self.promiseDispatch.done (/path/node_modules/protractor/node_modules/q/q.js:826:30)
at Promise.promise.promiseDispatch (/path/node_modules/protractor/node_modules/q/q.js:759:13)
at /path/node_modules/protractor/node_modules/q/q.js:573:44
    [launcher] Runner Process Exited With Error Code: 8
>>
Fatal error: protractor exited with code: 1

Package versions:

"grunt-protractor-runner": "~0.2.3"
"protractor": "0.19.0"
"selenium-webdriver": "~2.40"

Contents of protractor.conf.js:

exports.config = {
    seleniumServerJar: '../../node_modules/protractor/selenium/selenium-server-standalone-2.39.0.jar',
    seleniumPort: 4444,
    seleniumArgs: ['-browserTimeout=60'],
    specs: [
        '../e2e/utils.js',
        '../e2e/**/*-suite.js'
    ],
    capabilities: {
        browserName: 'phantomjs',
        'phantomjs.binary.path': './node_modules/karma-phantomjs-launcher/node_modules/phantomjs/bin/phantomjs',
        'phantomjs.cli.args': ['--debug=true', '--webdriver', '--webdriver-logfile=webdriver.log', '--webdriver-loglevel=DEBUG']
    },
    baseUrl: 'http://localhost:9292',
    rootElement: 'body',
    onPrepare: function () {
        require('jasmine-reporters');
        jasmine.getEnv().addReporter(new jasmine.JUnitXmlReporter('test/results/', true, true));
    },
    framework: 'jasmine',
    jasmineNodeOpts: {
        onComplete: function () {
        },
        isVerbose: true,
        showColors: true,
        includeStackTrace: true,
        defaultTimeoutInterval: 30000
    }
};

I have tried installing version ~1.9.7-1 of the phantomjs package independently of the one that protractor depends upon, and updating the phantomjs.binary.path property in protractor.conf.js, but I get the same result.

After spending far too long debugging the JS to try to isolate where the error is occurring, I know that it is falling over in runner.js.

Specifically in Runner.prototype.runJasmine_(), the anonymous function passed to webdriver.promise.controlFlow().execute() here is never executed.

Can anyone help?

Let me know if you need more information.

Matt

mcalthrop avatar Feb 27 '14 16:02 mcalthrop

From the stacktrace, it looks like a webdriver session is never being created (async task at WebDriver.createSession()).

I am running phantomjs 1.9.7-1 and it's working just fine, so it must be somewhere else.

It would be helpful to see the output of your selenium standalone server. Could you run that with webdriver-manager start and change your configuration to use seleniumAddress: http://localhost:4444/wd/hub?

juliemr avatar Mar 05 '14 06:03 juliemr

Ok, thanks Julie.

Here's the output:

seleniumProcess.pid: 15184
Mar 05, 2014 10:12:38 AM org.openqa.grid.selenium.GridLauncher main
INFO: Launching a standalone server
Setting system property webdriver.chrome.driver to /full/path/node_modules/protractor/selenium/chromedriver
10:12:44.383 INFO - Java: Oracle Corporation 24.45-b08
10:12:44.384 INFO - OS: Mac OS X 10.9.2 x86_64
10:12:44.403 INFO - v2.39.0, with Core v2.39.0. Built from revision ff23eac
10:12:44.572 INFO - Default driver org.openqa.selenium.ie.InternetExplorerDriver registration is skipped: registration capabilities Capabilities [{platform=WINDOWS, ensureCleanSession=true, browserName=internet explorer, version=}] does not match with current platform: MAC
10:12:44.632 INFO - RemoteWebDriver instances should connect to: http://127.0.0.1:4444/wd/hub
10:12:44.633 INFO - Version Jetty/5.1.x
10:12:44.634 INFO - Started HttpContext[/selenium-server/driver,/selenium-server/driver]
10:12:44.635 INFO - Started HttpContext[/selenium-server,/selenium-server]
10:12:44.636 INFO - Started HttpContext[/,/]
10:12:44.674 INFO - Started org.openqa.jetty.jetty.servlet.ServletHandler@71f993c
10:12:44.674 INFO - Started HttpContext[/wd,/wd]
10:12:44.685 INFO - Started SocketListener on 0.0.0.0:4444
10:12:44.685 INFO - Started org.openqa.jetty.jetty.Server@2db45934
10:15:29.843 INFO - Executing: [new session: Capabilities [{phantomjs.cli.args=[--debug=true, --webdriver, --webdriver-logfile=webdriver.log, --webdriver-loglevel=DEBUG], browserName=phantomjs, phantomjs.binary.path=./node_modules/karma-phantomjs-launcher/node_modules/phantomjs/bin/phantomjs}]] at URL: /session)
10:15:29.867 INFO - Creating a new session for Capabilities [{phantomjs.cli.args=[--debug=true, --webdriver, --webdriver-logfile=webdriver.log, --webdriver-loglevel=DEBUG], browserName=phantomjs, phantomjs.binary.path=./node_modules/karma-phantomjs-launcher/node_modules/phantomjs/bin/phantomjs}]
10:15:29.896 INFO - executable: /full/path/./node_modules/karma-phantomjs-launcher/node_modules/phantomjs/bin/phantomjs
10:15:29.896 INFO - port: 35651
10:15:29.896 INFO - arguments: [--debug=true, --webdriver, --webdriver-logfile=webdriver.log, --webdriver-loglevel=DEBUG, --webdriver=35651, --webdriver-logfile=/full/path/phantomjsdriver.log]
10:15:29.896 INFO - environment: {}
Error: Option webdriver need a value
10:15:50.280 WARN - Exception thrown
java.util.concurrent.ExecutionException: org.openqa.selenium.WebDriverException: java.lang.reflect.InvocationTargetException
Build info: version: '2.39.0', revision: 'ff23eac', time: '2013-12-16 16:11:15'
System info: host: 'MattRetina.local', ip: '172.16.4.64', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.9.2', java.version: '1.7.0_45'
Driver info: driver.version: unknown
    at java.util.concurrent.FutureTask.report(FutureTask.java:122)
    at java.util.concurrent.FutureTask.get(FutureTask.java:188)
    at org.openqa.selenium.remote.server.DefaultSession.execute(DefaultSession.java:177)
    at org.openqa.selenium.remote.server.DefaultSession.<init>(DefaultSession.java:113)
    at org.openqa.selenium.remote.server.DefaultSession.createSession(DefaultSession.java:90)
    at org.openqa.selenium.remote.server.DefaultDriverSessions.newSession(DefaultDriverSessions.java:104)
    at org.openqa.selenium.remote.server.handler.NewSession.handle(NewSession.java:63)
    at org.openqa10:15:50.293 WARN - Exception: null

Note that I've replaced the actual path in the logs above with /full/path/.

mcalthrop avatar Mar 05 '14 10:03 mcalthrop

So from the Error: Option webdriver need a value message, it looks like the --webdriver option now needs to have a value assigned to it (previously the parameter was required, but did not need a value assigned to it).

I tried removing it, and also assigning to it the value for the webdriver (--webdriver=http://localhost:4444/wd/hub), and both had the same result: I was able to get PhantomJS running. Great!

However, Protractor failed on every assertion with the following error:

UnknownError: Error communicating with the remote browser. It may have died.
Build info: version: '2.39.0', revision: 'ff23eac', time: '2013-12-16 16:11:15'
System info: host: 'Hostname.local', ip: '172.16.4.64', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.9.2', java.version: '1.7.0_45'
Driver info: driver.version: PhantomJSDriver

And the output from webdriver-manager start included the following:

11:24:27.491 INFO - Executing: [find element: By.id: sign-out] at URL: /session/30e3013c-a159-4c31-adfc-3be450ebed54/element)
[ERROR - 2014-03-05T11:24:27.699Z] WebElementLocator - _handleLocateCommand - Element(s) NOT Found: GAVE UP. Search Stop Time: 1394018667695
11:24:28.628 WARN - Exception thrown
org.openqa.selenium.NoSuchElementException: {"errorMessage":"Unable to find element with id 'sign-out'","request":{"headers":{"Accept":"application/json, image/png","Connection":"Keep-Alive","Content-Length":"33","Content-Type":"application/json; charset=utf-8","Host":"localhost:39666"},"httpVersion":"1.1","method":"POST","post":"{\"using\":\"id\",\"value\":\"sign-out\"}","url":"/element","urlParsed":{"anchor":"","query":"","file":"element","directory":"/","path":"/element","relative":"/element","port":"","host":"","password":"","user":"","userInfo":"","authority":"","protocol":"","source":"/element","queryKey":{},"chunks":["element"]},"urlOriginal":"/session/b3928c50-a458-11e3-a030-95aefe148b93/element"}}
Command duration or timeout: 404 milliseconds
For documentation on this error, please visit: http://seleniumhq.org/exceptions/no_such_element.html
Build info: version: '2.39.0', revision: 'ff23eac', time: '2013-12-16 16:11:15'
System info: host: 'MattRetina.local', 11:24:28.637 WARN - Exception: {"errorMessage":"Unable to find element with id 'sign-out'","request":{"headers":{"Accept":"application/json, image/png","Connection":"Keep-Alive","Content-Length":"33","Content-Type":"application/json; charset=utf-8","Host":"localhost:39666"},"httpVersion":"1.1","method":"POST","post":"{\"using\":\"id\",\"value\":\"sign-out\"}","url":"/element","urlParsed":{"anchor":"","query":"","file":"element","directory":"/","path":"/element","relative":"/element","port":"","host":"","password":"","user":"","userInfo":"","authority":"","protocol":"","source":"/element","queryKey":{},"chunks":["element"]},"urlOriginal":"/session/b3928c50-a458-11e3-a030-95aefe148b93/element"}}
Build info: version: '2.39.0', revision: 'ff23eac', time: '2013-12-16 16:11:15'
System info: host: 'MattRetina.local', ip: '172.16.4.64', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.9.2', java.version: '1.7.0_45'
Driver info: driver.version: unknown

I wonder if there is something else incorrect/missing in the array I am assigning to 'phantomjs.cli.args'?

mcalthrop avatar Mar 05 '14 11:03 mcalthrop

Hmmm... I just discovered this in the webdriver-manager start logs:

2014-03-05T11:45:01 [DEBUG] Network - Resource request error: 5 ( "Operation canceled" ) URL: "http://username:password@localhost:9292/path/to/static1.json" 
2014-03-05T11:45:01 [DEBUG] Network - Resource request error: 5 ( "Operation canceled" ) URL: "http://username:password@localhost:9292/path/to/static2.json" 
2014-03-05T11:45:01 [DEBUG] Network - Resource request error: 5 ( "Operation canceled" ) URL: "http://username:password@localhost:9292/path/to/service" 
2014-03-05T11:45:01 [DEBUG] WebPage - updateLoadingProgress: 10 
2014-03-05T11:45:01 [DEBUG] WebPage - evaluateJavaScript result QVariant(QString, "{"status":0,"value":null}") 
PhantomJS has crashed. Please read the crash reporting guide at https://github.com/ariya/phantomjs/wiki/Crash-Reporting and file a bug report at https://github.com/ariya/phantomjs/issues/new with the crash dump file attached: /tmp/710344B2-2CBA-4B9B-9352-8A016F894B94.dmp

So by the looks of things, PhantomJS is crashing. Which is not good.

I have noticed that on the odd occasion when I run the tests, they actually pass (although I have restricted the tests to just a single one while I'm trying to get PhantomJS running).

For reference, when I run node_modules/karma-phantomjs-launcher/node_modules/phantomjs/lib/phantom/bin/phantomjs --version, I get 1.9.7.

mcalthrop avatar Mar 05 '14 12:03 mcalthrop

I wonder if the HTTP authentication is causing a problem with PhantomJS.

So far, I have been putting the authentication details in the baseUrl in protractor.conf.js:

baseUrl: 'http://http_username:http_password@localhost:9292'

Have dug around, and the only PhantomJS documentation on how to pass in HTTP username and password I could find was here.

So I modified my protractor.conf.js as follows:

capabilities: {
    'phantomjs.binary.path': './node_modules/karma-phantomjs-launcher/node_modules/phantomjs/bin/phantomjs',
    'phantomjs.cli.args': ['--debug=true', '--webdriver=localhost:4444', '--webdriver-logfile=webdriver.log', '--webdriver-loglevel=INFO'],
    "phantomjs.page.settings.userName": 'http_username',
    "phantomjs.page.settings.password": 'http_password'
},

I also tried adding the --webdriver= parameter as well:

'phantomjs.cli.args': ['--debug=true', '--webdriver=localhost:4444', '--webdriver-logfile=webdriver.log', '--webdriver-loglevel=INFO'],

Unfortunately none of the above solves the problems I have been having.

@juliemr, could you let me know what parameters you are passing to PhantomJS via phantomjs.cli.args?

And are you able to set up an HTTP auth test?

many thanks

Matt

mcalthrop avatar Mar 05 '14 14:03 mcalthrop

I also see problems with the --webdriver option. I don't think you should specify that one.

I can add phantomjs.page.settings.userName and phantomjs.page.settings.password and my tests still pass.

Can you try testing against a page which doesn't require HTTP auth, to see if we can rule that out? e.g. run this test against http://www.angularjs.org

describe('angularjs homepage', function() {
  it('should greet the named user', function() {
    browser.get('http://www.angularjs.org');

    element(by.model('yourName')).sendKeys('Julie');

    var greeting = element(by.binding('yourName'));

    expect(greeting.getText()).toEqual('Hello Julie!');
  });
});

juliemr avatar Mar 05 '14 18:03 juliemr

Good call. I'll try that tomorrow (UK time).

Could you let me know what parameters you are passing to phantom?

Matt

mcalthrop avatar Mar 05 '14 22:03 mcalthrop

I used the same parameters as you, minus the --webdriver one, and then I also tried with no parameters.

juliemr avatar Mar 05 '14 23:03 juliemr

Ok, I've tried the what you suggested.

It works fine using Chrome, but when using PhantomJS, I still get the message that PhantomJS has crashed.

Here's what I have in my protractor.conf.js:

exports.config = {
    seleniumAddress: 'http://localhost:4444/wd/hub',
    seleniumArgs: ['-browserTimeout=60'],
    specs: [
        'bug-tester-suite.js'
    ],
    browserName: 'phantomjs',
    capabilities: {
        'phantomjs.binary.path': './node_modules/karma-phantomjs-launcher/node_modules/phantomjs/bin/phantomjs'
    },
    rootElement: 'body',
    onPrepare: function () {
        require('jasmine-reporters');
        jasmine.getEnv().addReporter(new jasmine.JUnitXmlReporter('test/results/', true, true));
    },
    framework: 'jasmine',
    jasmineNodeOpts: {
        isVerbose: true,
        showColors: true,
        includeStackTrace: true,
        defaultTimeoutInterval: 30000
    }
};

And of course the bug-tester-suite.js file contains the exact contents you specified above.

Here is the protractor output, run via grunt:

Running "protractor:phantomjs" (protractor) task

------------------------------------
    PID: 39204 (capability: phantomjs #1)
------------------------------------

    Using the selenium server at http://localhost:4444/wd/hub

    angularjs homepage
should greet the named user

Failures:

    1) angularjs homepage should greet the named user
Message:
    UnknownError: Error communicating with the remote browser. It may have died.
    Build info: version: '2.39.0', revision: 'ff23eac', time: '2013-12-16 16:11:15'
System info: host: 'MattRetina.local', ip: '192.168.50.1', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.9.2', java.version: '1.7.0_45'
Driver info: driver.version: EventFiringWebDriver
Stacktrace:
    UnknownError: Error communicating with the remote browser. It may have died.
    Build info: version: '2.39.0', revision: 'ff23eac', time: '2013-12-16 16:11:15'
System info: host: 'MattRetina.local', ip: '192.168.50.1', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.9.2', java.version: '1.7.0_45'
Driver info: driver.version: EventFiringWebDriver
    ==== async task ====
    WebDriver.executeScript()
at Protractor.waitForAngular (/full/path/node_modules/protractor/lib/protractor.js:407:22)
at Protractor.findElement (/full/path/node_modules/protractor/lib/protractor.js:568:8)
at Object.elementFinder.(anonymous function) [as sendKeys] (/full/path/node_modules/protractor/lib/protractor.js:88:24)
at null.<anonymous> (/full/path/test/config/bug-tester-suite.js:5:39)
at /full/path/node_modules/protractor/jasminewd/index.js:54:12
    ==== async task ====
    at null.<anonymous> (/full/path/node_modules/protractor/jasminewd/index.js:53:12)
at null.<anonymous> (/full/path/node_modules/protractor/node_modules/minijasminenode/lib/async-callback.js:45:37)
at Timer.listOnTimeout [as ontimeout] (timers.js:110:15)

Finished in 6.811 seconds
1 test, 1 assertion, 1 failure

    [launcher] Runner Process Exited With Error Code: 1
>>
Fatal error: protractor exited with code: 1

And here is the output from running node_modules/protractor/bin/webdriver-manager start:

10:41:37.765 INFO - Executing: [new session: Capabilities [{browserName=phantomjs, phantomjs.binary.path=./node_modules/karma-phantomjs-launcher/node_modules/phantomjs/bin/phantomjs}]] at URL: /session)
10:41:37.767 INFO - Creating a new session for Capabilities [{browserName=phantomjs, phantomjs.binary.path=./node_modules/karma-phantomjs-launcher/node_modules/phantomjs/bin/phantomjs}]
10:41:37.773 INFO - executable: /full/path/./node_modules/karma-phantomjs-launcher/node_modules/phantomjs/bin/phantomjs
10:41:37.773 INFO - port: 6823
10:41:37.773 INFO - arguments: [--webdriver=6823, --webdriver-logfile=/full/path/phantomjsdriver.log]
10:41:37.773 INFO - environment: {}
PhantomJS is launching GhostDriver...
    [INFO  - 2014-03-06T10:41:39.450Z] GhostDriver - Main - running on port 6823
    [INFO  - 2014-03-06T10:41:39.794Z] Session [e64f3ee0-a51b-11e3-8aba-d31758324c72] - page.settings - {"XSSAuditingEnabled":false,"javascriptCanCloseWindows":true,"javascriptCanOpenWindows":true,"javascriptEnabled":true,"loadImages":true,"localToRemoteUrlAccessEnabled":false,"userAgent":"Mozilla/5.0 (Macintosh; Intel Mac OS X) AppleWebKit/534.34 (KHTML, like Gecko) PhantomJS/1.9.7 Safari/534.34","webSecurityEnabled":true}
    [INFO  - 2014-03-06T10:41:39.794Z] Session [e64f3ee0-a51b-11e3-8aba-d31758324c72] - page.customHeaders:  - {}
    [INFO  - 2014-03-06T10:41:39.795Z] Session [e64f3ee0-a51b-11e3-8aba-d31758324c72] - Session.negotiatedCapabilities - {"browserName":"phantomjs","version":"1.9.7","driverName":"ghostdriver","driverVersion":"1.1.0","platform":"mac-unknown-32bit","javascriptEnabled":true,"takesScreenshot":true,"handlesAlerts":false,"databaseEnabled":false,"locationContextEnabled":false,"applicationCacheEnabled":false,"browserConnectionEnabled":false,"cssSelectorsEnabled":true,"webStorageEnabled":false,"rotatable":false,"acceptSslCerts":false,"nativeEvents":true,"proxy":{"proxyType":"direct"}}
    [INFO  - 2014-03-06T10:41:39.795Z] SessionManagerReqHand - _postNewSessionCommand - New Session Created: e64f3ee0-a51b-11e3-8aba-d31758324c72
10:41:39.799 INFO - Done: /session
10:41:39.810 INFO - Executing: [set script timeoutt: 11000] at URL: /session/6bb308da-46f1-47e2-9b99-57fab05b1e6c/timeouts/async_script)
10:41:39.819 INFO - Done: /session/6bb308da-46f1-47e2-9b99-57fab05b1e6c/timeouts/async_script
10:41:39.855 INFO - Executing: [get: about:blank] at URL: /session/6bb308da-46f1-47e2-9b99-57fab05b1e6c/url)
10:41:39.871 INFO - Done: /session/6bb308da-46f1-47e2-9b99-57fab05b1e6c/url
10:41:39.877 INFO - Executing: [execute script: window.name = "NG_DEFER_BOOTSTRAP!" + window.name;window.location.assign("http://www.angularjs.org/");, []] at URL: /session/6bb308da-46f1-47e2-9b99-57fab05b1e6c/execute)
10:41:39.885 INFO - Done: /session/6bb308da-46f1-47e2-9b99-57fab05b1e6c/execute
10:41:39.910 INFO - Executing: [get current url] at URL: /session/6bb308da-46f1-47e2-9b99-57fab05b1e6c/url)
10:41:39.916 INFO - Done: /session/6bb308da-46f1-47e2-9b99-57fab05b1e6c/url
10:41:40.036 INFO - Executing: [get current url] at URL: /session/6bb308da-46f1-47e2-9b99-57fab05b1e6c/url)
10:41:40.043 INFO - Done: /session/6bb308da-46f1-47e2-9b99-57fab05b1e6c/url
10:41:40.161 INFO - Executing: [get current url] at URL: /session/6bb308da-46f1-47e2-9b99-57fab05b1e6c/url)
10:41:40.169 INFO - Done: /session/6bb308da-46f1-47e2-9b99-57fab05b1e6c/url
10:41:40.293 INFO - Executing: [get current url] at URL: /session/6bb308da-46f1-47e2-9b99-57fab05b1e6c/url)
10:41:40.302 INFO - Done: /session/6bb308da-46f1-47e2-9b99-57fab05b1e6c/url
10:41:40.336 INFO - Executing: [execute async script: return (function () {
    var attempts = arguments[0];
    var asyncCallback = arguments[arguments.length - 1];
    var callback = function(args) {
        setTimeout(function() {
            asyncCallback(args);
        }, 0);
    };
    var check = function(n) {
        try {
            if (window.angular && window.angular.resumeBootstrap) {
                callback([true, null]);
            } else if (n < 1) {
                if (window.angular) {
                    callback([false, 'angular never provided resumeBootstrap']);
                } else {
                    callback([false, 'retries looking for angular exceeded']);
                }
            } else {
                window.setTimeout(function() {check(n - 1)}, 1000);
            }
        } catch (e) {
            callback([false, e]);
        }
    };
    check(attempts);
}).apply(null, arguments);, [10]] at URL: /session/6bb308da-46f1-47e2-9b99-57fab05b1e6c/execute_async)
10:41:42.120 INFO - Done: /session/6bb308da-46f1-47e2-9b99-57fab05b1e6c/execute_async
10:41:42.132 INFO - Executing: [execute script: return (function () {
    // Continue to bootstrap Angular.
    angular.resumeBootstrap(arguments[0]);
}).apply(null, arguments);, [[]]] at URL: /session/6bb308da-46f1-47e2-9b99-57fab05b1e6c/execute)
10:41:43.336 INFO - Done: /session/6bb308da-46f1-47e2-9b99-57fab05b1e6c/execute
10:41:43.348 INFO - Executing: [execute async script: return (function () {
    var el = document.querySelector(arguments[0]);
    var callback = arguments[1];
    try {
        angular.element(el).injector().get('$browser').
            notifyWhenNoOutstandingRequests(callback);
    } catch (e) {
        callback(e);
    }
}).apply(null, arguments);, [body]] at URL: /session/6bb308da-46f1-47e2-9b99-57fab05b1e6c/execute_async)
PhantomJS has crashed. Please read the crash reporting guide at https://github.com/ariya/phantomjs/wiki/Crash-Reporting and file a bug report at https://github.com/ariya/phantomjs/issues/new with the crash dump file attached: /tmp/96DD66B3-7F6D-452D-BFD8-B7A3DC11748B.dmp
10:41:46.650 INFO - Executing: [delete session: 6bb308da-46f1-47e2-9b99-57fab05b1e6c] at URL: /session/6bb308da-46f1-47e2-9b99-57fab05b1e6c)

mcalthrop avatar Mar 06 '14 10:03 mcalthrop

A bit more info... today I actually got it to run about a dozen tests (out of a suite of around 100) before it crashed.

Plus: a colleague tried running it on an up to date Gentoo installation.

mcalthrop avatar Mar 07 '14 15:03 mcalthrop

Hm. You've reached the limits of my phantomjs knowledge.

Any proxies or firewalls? What's the version of phantomJS at /node_modules/karma-phantomjs-launcher/node_modules/phantomjs/bin/phantomjs?

juliemr avatar Mar 07 '14 19:03 juliemr

Version 1.9.7. No firewalls or proxies.

I have built a very simple project that works independently of grunt, so I can hopefully isolate the issue.

Could you have a look at protractor-phantomjs-testing, and see if it always runs ok for you?

I have tried running that several times, and sometimes it works fine, but other times I get the PhantomJS has crashed message.

I have also tried running the same project on Gentoo and Ubuntu installations, and the same thing happens on both of them: sometimes it works, and other times phantomjs crashes.

mcalthrop avatar Mar 10 '14 13:03 mcalthrop

Hi again Julie

Since I made that post, the tests I originally wrote have changed quite a bit: I discovered that when the target location for protractor & phantomjs is a minimal Angular installation, there are no crashes.

However, it consistently fails when testing against www.angularjs.org.

So I wondered if maybe it had something to do with PhantomJS not being able to handle certain font formats, and I designed a set of tests to see what would happen when fonts were included on that minimal AngularJS page – results are on the github project I linked to in my previous message.

mcalthrop avatar Mar 10 '14 18:03 mcalthrop

Hi Matt,

Yes, I get occasional failures as well using protractor-phantomjs-testing - they seem to only occur when run individually on angularjs.org, but when run together it fails after about the second test. Maybe it's a time-related thing?

PhantomJS has crashed. Please read the crash reporting guide at https://github.com/ariya/phantomjs/wiki/Crash-Reporting ....

juliemr avatar Mar 10 '14 18:03 juliemr

To test that out, I tried just repeating the 'No fonts' tests a couple times and commenting out all the others. PhantomJS crashes after the third or fourth time. So, not a font thing as far as I can tell.

I can get tests to fail (with the phantomjs crash) occasionally using the following. Note that it doesn't use angular or protractor (just grabs the base webdriver).

describe('showing failures with lots of page reloads and async calls', function () {
    it('fails after lots of reloads', function () {
        var location = 'http://www.phantomjs.org';
        var driver = browser.driver;

        function trivialAsyncScript() {
            driver.executeAsyncScript(function() {
                var callback = arguments[0];
                setTimeout(function() {
                    callback();
                }, 500);
            });
        }
        for (var i = 0; i < 20; ++i) {
            driver.get(location);
            trivialAsyncScript();
        }
    });
});

juliemr avatar Mar 10 '14 20:03 juliemr

I have submitted an issue to ghostdriver: https://github.com/detro/ghostdriver/issues/328

juliemr avatar Mar 10 '14 20:03 juliemr

Yes, I've managed to reproduce what you noted in your comment from about 2 hours ago: if you hit the browser with several calls, it doesn't matter if there's a font loaded or not.

So the loading of the font could just be taking a bit more time, which triggers the browser crash earlier.

Any other suggestions?

I think the next step is to post the crash dump as directed here – although I'll have to do this from a Linux crash dump.

Note also that I tried using the Linux binary downloaded from the phantomjs website (onto my Ubuntu installation), and that crashed in the same way the others did.

mcalthrop avatar Mar 10 '14 20:03 mcalthrop

Just saw your last comment: thanks for the issue submission to detro!

mcalthrop avatar Mar 10 '14 20:03 mcalthrop

@juliemr: I just created a different project that demonstrates how to consistently crash phantomjs with Protractor: https://github.com/mcalthrop/protractor-phantomjs-crash

Check out the results section to see what results I get, and hence what results I'd expect you would get.

Feel free to use this on the detro issue you raised (although I'm not sure if it's useful, as it uses Protractor).

mcalthrop avatar Mar 11 '14 15:03 mcalthrop

Note that calls to driver.get() consistently pass, whereas calls to browser.get() usually fail after about 3 calls.

However, the confusing thing is that on occasions, all the browser.get() calls succeeded.

mcalthrop avatar Mar 11 '14 15:03 mcalthrop