ariya / phantomjs

Scriptable Headless Browser
http://phantomjs.org
BSD 3-Clause "New" or "Revised" License
29.46k stars 5.76k forks source link

PhantomJS stops working while loading page #11526

Closed floriansemm closed 4 years ago

floriansemm commented 11 years ago

Our Behat-Tests use PhantomJS as browser via selenium2/webdriver. The execution stops occasionally during page loading.

We have no idea how to solve this problem, as it occurs not always at the same step/scenario.

Any ideas what the problem is or how to solve it?

Config:

PhantomJS Debug-Output

    2013-07-26T11:11:33 [DEBUG] WebPage - updateLoadingProgress: 14
2013-07-26T11:11:33 [DEBUG] WebPage - updateLoadingProgress: 26
2013-07-26T11:11:33 [DEBUG] WebPage - setupFrame ""
2013-07-26T11:11:33 [DEBUG] WebPage - updateLoadingProgress: 52
2013-07-26T11:11:33 [DEBUG] WebPage - updateLoadingProgress: 55
2013-07-26T11:11:33 [DEBUG] WebPage - updateLoadingProgress: 82
2013-07-26T11:11:54 [DEBUG] WebPage - updateLoadingProgress: 84
2013-07-26T11:12:04 [DEBUG] WebPage - updateLoadingProgress: 84
[INFO  - 2013-07-26T09:15:21.610Z] SessionManagerReqHand - _cleanupWindowlessSessions - Asynchronous Sessions clean-up phase starting NOW
[INFO  - 2013-07-26T09:20:21.610Z] SessionManagerReqHand - _cleanupWindowlessSessions - Asynchronous Sessions clean-up phase starting NOW
[INFO  - 2013-07-26T09:25:21.609Z] SessionManagerReqHand - _cleanupWindowlessSessions - Asynchronous Sessions clean-up phase starting NOW
[INFO  - 2013-07-26T09:30:21.610Z] SessionManagerReqHand - _cleanupWindowlessSessions - Asynchronous Sessions clean-up phase starting NOW
[INFO  - 2013-07-26T09:35:21.610Z] SessionManagerReqHand - _cleanupWindowlessSessions - Asynchronous Sessions clean-up phase starting NOW
[INFO  - 2013-07-26T09:40:21.610Z] SessionManagerReqHand - _cleanupWindowlessSessions - Asynchronous Sessions clean-up phase starting NOW
[INFO  - 2013-07-26T09:45:21.610Z] SessionManagerReqHand - _cleanupWindowlessSessions - Asynchronous Sessions clean-up phase starting NOW
[INFO  - 2013-07-26T09:50:21.609Z] SessionManagerReqHand - _cleanupWindowlessSessions - Asynchronous Sessions clean-up phase starting NOW
[INFO  - 2013-07-26T09:55:21.610Z] SessionManagerReqHand - _cleanupWindowlessSessions - Asynchronous Sessions clean-up phase starting NOW
[INFO  - 2013-07-26T10:00:21.610Z] SessionManagerReqHand - _cleanupWindowlessSessions - Asynchronous Sessions clean-up phase starting NOW
[INFO  - 2013-07-26T10:05:21.610Z] SessionManagerReqHand - _cleanupWindowlessSessions - Asynchronous Sessions clean-up phase starting NOW

regards florian

mmenozzi commented 11 years ago

Same situation for us (behat + selenium2 driver + phantomjs webdriver) and we have the same problem!!! The strange thing is that the problem, for now, occurs only on our continuous integration environment (Jenkins) and not on our dev machines... Do you have any suggestions?

floriansemm commented 11 years ago

This is a good point: the debug-log was generated during a jenkins-build

startupz commented 11 years ago

I have the same problem here on my MacOS env and I have no solution :(

floriansemm commented 11 years ago

@startupz which phantomJS version do you use?

startupz commented 11 years ago

I used 1.9.2 so I came back to 1.9.1 and it works for now :/

varshith commented 11 years ago

same problem here on using behat-selenium2-phantomjs.. I was using 1.9.2 It works after downgrading to 1.9.1(but its deprecated).

this seems like the same issue but I cant follow the solution :( http://stackoverflow.com/questions/15345767/repeating-asynchronous-sessions-cleanup-phase-starting-now

leowmjw commented 11 years ago

Confirmed regression; my Codeception Acceptance tests works when run on v1.9.1; but hangs on v1.9.2; tested both on Linux and Windows.

wouterla commented 11 years ago

Confirmed from my side as well: downgrading to v1.9.1 immediately solves frequent "_cleanupWindowlessSessions - Asynchronous Sessions clean-up phase starting NOW" hangs.

Running linux x86_64 versions, from maven on the command-line.

guitarmind commented 10 years ago

Hi all,

I have the same problem even after downgrading to version 1.9.1. Still got "Asynchronous Sessions clean-up phase starting NOW" messages occasionally. (Although it has a bit lower chance to happen than version 1.9.2)

Running on Ubuntu 12.04.3 LTS 64-bit, with GhostDriver.

tomdw commented 10 years ago

Same problem here with version 1.9.1 and ghostdriver 1.0.3 on a jenkins CI machine. It basically makes phantomjs useless for it results in a very unstable build.

raghuariga commented 10 years ago

Running on Ubuntu 12.04.3 LTS 64-bit, with GhostDriver.

I am having problem here on using behat-selenium2-phantomjs version 1.9.2

It works after downgrading to 1.9.1(but its deprecated).

How could we track the issue and most importantly how to fix it.....Thanks

worldjoe commented 10 years ago

I have this problem as well. Using maven to run phantomjs 1.9.2. in reference to varshith, the suggestion on stackexchange here: http://stackoverflow.com/questions/15345767/repeating-asynchronous-sessions-cleanup-phase-starting-now

does help a little. Basically mock out any asynchronous calls in your javascript code to return immediately. That cuts down on the time phantomJS waits, but does not eliminate the problem.

ricoli commented 10 years ago

any clues?

gjoris commented 10 years ago

Same issue here. Running on PhantomJS 1.9.7.

Not that it matters, but to be complete: Ubuntu 12.04 LTS, Jenkins v1.558, Maven v.3.0.3.

Switched the build back to Firefox, in a Xvfb setup.

Any progress on this matter? Because it is a really annoying problem. PhantomJS is the faster browser, but because of this problem, it is really unstable. Working tests are failing in the build, due to the browser, which is the reason why I went back to the slower though trustworthy browser (FF).

ricoli commented 10 years ago

I was starting phantomjs with 'nohup' when I had this issue. I've now started it using 'screen' and haven't seen this issue again - but it has been only a few days. Someone care to try this too?

ltutar commented 10 years ago

Hi Ricoli,

Nohup is only making sure that the process is running in the background. I tried it and the processes were still there. But since it is running in the background, you do get your terminal back. The running processes may make your machine instable since they can hop up. Nohup is not really solving your problem.

ricoli commented 10 years ago

@ltutar indeed I thought it wouldn't make a difference - but alas I haven't seen this issue again, and didn't do anything differently apart from not using nohup lol But yes, all logic leads to it being unrelated I know :)

ltutar commented 10 years ago

I am also stuck with the "SessionManagerReqHand - _cleanupWindowlessSessions - Asynchronous Sessions clean-up phase starting NOW" issue since this morning. Until I have a real solution, I will also be using the nohup :) And maybe reboot the machine once in a week to clean these java processes.

ltutar commented 10 years ago

Hi, Our problem is solved by changing the following in our java code: WebDriver driver = new PhantomJSDriver(caps); with this.driver = new PhantomJSDriver(caps); Now, we get a shutdown. [INFO - 2014-05-01T13:21:09.095Z] ShutdownReqHand - _handle - About to shutdown

gjoris commented 10 years ago

Does that mean that at a given time, you had multiple instances open at the same time?

ltutar commented 10 years ago

No. I do not think so. See the answer of Udu at http://stackoverflow.com/questions/19157924/not-able-to-run-selenium-script-using-phantomjs-driver for the explanation.

nodefourtytwo commented 10 years ago

I have the same problem on 1.9.7 using se-interpreter (https://github.com/Zarkonnen/se-interpreter)

karmux commented 10 years ago

Same here with PhantomJS 1.9.0 on Ubuntu 14.04 LTS. It loads all pages correctly in first browser.get() call. If I do second browser.get() call, then it hangs with all pages I try. That means I'm limited with only one get() call per browser.

boogheta commented 10 years ago

Having the same issue with 1.9.7 while running heavy async scripts within a webpage through selenium. It seems like the freeze comes from some XmlHTTPRequests that get stuck, adding a .timeout to all XmlHTTPRequests seems to solve the issue in my case

arisAlexis commented 9 years ago

I still have this issue and it is open for 1,5 year. should we expect any kind of solution?

inka commented 9 years ago

ENV: jenkins triggered gradle cucumber with local phantomjsdriver 1.2.1 + selenium 2.44.0 + phantom 1.9.8 on osx 10.10.1 the same issue appears sometimes in the moment it's still stuck for now 7 hours

UlrichWickert commented 9 years ago

Same bug with version 1.9.7, used in jenkins/selenium builds. Any progress regarding this issue?

NithinManmohan commented 9 years ago

Same issue on RHEL 5.6 64 bit, PhantomJS version 1.9.2. It seems that PhantomJS cleans up the sessions every 5 minutes and that's what is causing the message to be thrown, although its an asynchronous call. How about we disable that in the source code and then compile and then run, will that work and will have any impact, has anybody here tried that? Is this stupid, as in trying to mess with phantomJS source code?Waiting...

beygi commented 9 years ago

Same problem in 1.9.7 , ubuntu 12.04 . about 80% of time phantomjs works fine , but sometime stocks and nothing happens

command :

phantomjs --debug=true phantom-server.js "http://didaniha.loc"

Debug :

2015-02-26T19:02:22 [DEBUG] CookieJar - Saved "_ga=GA1.2.912779759.1424964743; expires=Sat, 25-Feb-2017 15:32:22 GMT; domain=.didaniha.loc; path=/" 
2015-02-26T19:02:22 [DEBUG] CookieJar - Saved "_gat=1; expires=Thu, 26-Feb-2015 15:42:22 GMT; domain=.didaniha.loc; path=/" 
2015-02-26T19:02:23 [DEBUG] WebPage - updateLoadingProgress: 82 

phantom-server.js :

var page = require('webpage').create();
var system = require('system');
page.viewportSize = {
    width: 1024,
    height: 768
};
console.log(system.args[1]);
page.open(system.args[1], function(status) {
    console.log(page.content);
    phantom.exit();
});
jaywink commented 9 years ago

Same problem on two machines, one Jenkins Ubuntu server, one local dev machine. Interestingly, problem not reproducible on local vagrant Ubuntu dev box..

[ERROR - 2015-03-19T09:10:42.314Z] Session [3602f290-ce17-11e4-b5a9-374855c211cc] - page.onError - msg: TypeError: 'null' is not an object (evaluating 'document.getElementById("username").focus')
[ERROR - 2015-03-19T09:10:42.314Z] Session [3602f290-ce17-11e4-b5a9-374855c211cc] - page.onError - stack:
  sf (http://localhost:8081/saml2/login/:16)
  onload (http://localhost:8081/saml2/login/:46)
[INFO  - 2015-03-19T09:11:20.497Z] SessionManagerReqHand - _cleanupWindowlessSessions - Asynchronous Sessions clean-up phase starting NOW
[INFO  - 2015-03-19T09:16:20.497Z] SessionManagerReqHand - _cleanupWindowlessSessions - Asynchronous Sessions clean-up phase starting NOW

Tried also this change to page timeout capabilities but it doesn't help.

Jenkins server (timeouts happen): Debian GNU/Linux 7 (wheezy) -- 3.2.0-0.bpo.1-amd64 -- phantomjs 1.9.8

Local dev (timeouts happen): Ubuntu 14.04.2 -- 3.13.0-46-generic -- phantomjs 1.9.8

Local dev box vagrant vm (timeouts do not happen!): Ubuntu 12.04.4 -- 3.2.0-64-virtual - phantomjs 1.9.8

This problem started on our jenkins server gradually and it has gotten worse and now our tests are totally usable, we only get like 1/10 builds without timeout and pretty much phantomjs is unusable for us :(

wrschneider commented 9 years ago

+1

It sounds like my problem is similar. Our CI build occasionally gets stuck on browser.get calls and the PhantomJS output is similar: last thing I see is

2015-03-21T21:26:39 [DEBUG] WebPage - updateLoadingProgress: 86

I am running PhantomJS 1.9.7 or 1.9.8 (same results with both) on RedHat Enterprise Linux 5.9.

Also, I can't reproduce this problem outside the Jenkins CI build. Running tests from the command line or locally both work just fine.

If there is no fix for PhantomJS itself yet, does anyone know what the trigger condition is, for implementing a workaround in the application to avoid it?

duoduoxi commented 9 years ago

the same problem in win7 , phantomjs-2.0.0-windows .

mauricioromero86 commented 9 years ago

Same problem with windows 8,phantomjs-2.0.0-windows .

suvirg2015 commented 9 years ago

We were also using phantomjs in our product because of the multiple issues we switch to http://www.awesomium.com/ ...it is pretty cool and doing great for us.

hstaudacher commented 9 years ago

Same with phantomjs 2.0.0 on Max OS X

niraj7848 commented 9 years ago

observed the same issue with

{"XSSAuditingEnabled":false,"javascriptCanCloseWindows":true,"javascriptCanOpenWindows":true,"javascriptEnabled":true,"loadImages":true,"localToRemoteUrlAccessEnabled":false,"userAgent":"Mozilla/5.0 (Unknown; Linux x86_64) AppleWebKit/534.34 (KHTML, like Gecko) PhantomJS/1.9.7 Safari/534.34","webSecurityEnabled":true}

Any solution to this problem???

bgaifullin commented 9 years ago

the same problem with phantomjs 2.0.1-development on centos 6.5

jayesh22c commented 9 years ago

I am also having the same problem with phantomjs 1.2.1 and selenium 2.46.0 on ubuntu 14.04LTS. Anyone know how to fix this ?

jayesh22c commented 9 years ago

Hey Finally I found the solution for this . in Java you can use driver.manage().timeouts().pageLoadTimeout(10, TimeUnit.SECONDS); .

This fixed the problem for me. Hope same for all of you . :+1:

wrschneider commented 9 years ago

That just changes the failure mode - instead of hanging, it times out. Which is better in a CI environment, because you can just re-run the tests and hope it works the next time. But still not desired result.

On Thu, Jun 25, 2015 at 3:17 AM, Jayesh Choudhary notifications@github.com wrote:

Hey Finally I foun the solution for this . in Java you can use driver.manage().timeouts().pageLoadTimeout(10, TimeUnit.SECONDS); .

This fixed the problem for me. Hope same for all of you . [image: :+1:]

— Reply to this email directly or view it on GitHub https://github.com/ariya/phantomjs/issues/11526#issuecomment-115135376.

erinphemi commented 9 years ago

I am also having this problem. At some random point during the test run, one of the tests will get stuck, output.xml file does not get updated anymore, and the run has to be killed. I would really like to see a fix for this, otherwise we are going to have to abandon PhantomJS entirely. I am using a Virtualbox VM running Ubuntu 12.04 and using version 1.9.8 of PhantomJS.

Has anybody worked out a hack?

jaywink commented 9 years ago

Switched already to Selenium Firefox driver, almost as fast using a MySQL ramdisk and Xvfb. And it's super reliable.

erinphemi commented 9 years ago

@jaywink The fix for ghostdriver 380 didn't work for you? I was thinking of trying it but maybe it doesn't fix this particular problem?

jaywink commented 9 years ago

@erinphemi no I tried that too, see this comment.

erinphemi commented 9 years ago

Hmm, so from reading #12180, PhantomJS itself works fine on its own, the problem happens when trying to use it with Selenium?

erinphemi commented 9 years ago

Is there any chance this will be fixed? I don't know how to fix it myself.

ptahchiev commented 9 years ago

I have the same issue - sometimes my build times out and sometimes it runs fine.

gochev commented 9 years ago

+1 but see 2 years and still not fixed ? :) even after so many people complaining ?

zackw commented 9 years ago

Unfortunately, without a self-contained, minimal, reproducible test case there's basically nothing we (PhantomJS devs) can do about this bug report. We don't even know if this is a bug in PhantomJS! It could be a bug in Selenium or whatever webdriver glue you are using. If it is a bug in PhantomJS it is almost certainly a bug in Webkit that depends strongly on the contents of the pages y'all are testing -- and we don't know anything about those.

Also, I would bet a small amount of money that this is not one bug, but rather at least N/2 bugs (where N is the number of people who have commented that they "have the same problem") with the same symptoms.

sangajala commented 9 years ago

any fix for this issue yet?