Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Tests hang when using capybara-webkit and WEBrick #242

Closed
jason-o-matic opened this Issue · 15 comments

6 participants

@jason-o-matic

Switching to Selenium, or using Thin, wouldn't hang. Using :webkit_debug it would hang right after printing a visit line. When I killed the tests, and had the WEBrick server debug logging, I would see it close many connections right before exiting (24 connections the last time I tried). Maybe WEBrick or capybara-webkit isn't closing connections properly? It hung on the 5th scenario, and two of the previous scenarios failed due to not finding an element with given text.

@niklasb

Can you check whether the same happens with my branch of webkit_server? I had some trouble with handling dropped connections and implemented a more robust error handling mechanism. If this works for you, I think I might suggest these changes as a pull request.

@jason-o-matic

niklasb,

I tried it with your fork, but it still hung. I'm 99% sure I built it correctly, though I will admit that it's been a long time since I've manually built any cpp stuff. If you'd be willing to fork the capybara-webkit gem and merge your changes into it I'll give it another shot to make sure I was building everything correctly.

@niklasb

@jason-o-matic: If you used qmake && make within my fork's directory, it should be okay. The only thing you have to do in addition is to replace the original webkit_server executable (possible in /usr/lib/ruby/gems/1.X.X/gems/capybara-webkit-X.X.X/bin/) with the newly built one.

@jason-o-matic

@niklasb: When I try that I get:

WARNING: Ignored (not found) '/Users/jason/projects/webkit-server/src/webkit_server.pbproj'
make: *** No targets specified and no makefile found.  Stop.

What I did to build it was install the gem normally, then replace the stock src dir with your src dir, then re-build webkit_server in the gem directory, and copy it over.

@niklasb

Why are you trying to somehow copy this over capybara-webkit? Just build my project from its root dir and only copy the resulting binary over your installation of capybara-webkit. The procedure should look something like that:

Install capybara-webkit, then do the following:

$ cd
$ git clone https://github.com/niklas/webkit-server.git
$ cd webkit-server
$ ./build.sh
$ sudo cp webkit_server `gem environment gemdir`/gems/capybara-webkit-X.X.X/bin/webkit_server

If you didn't install capybara-webkit as a Gem, the last line will vary, of course. Just adapt it to point to your installation of capybara-webkit.

@jason-o-matic

I tried that first, actually, but I got the error I posted above. Here's the whole transcript:

jason@lappy-2 [jason*] projects $ git clone https://github.com/niklasb/webkit-server.git
Cloning into webkit-server...
remote: Counting objects: 2151, done.
remote: Compressing objects: 100% (825/825), done.
remote: Total 2151 (delta 1319), reused 2069 (delta 1238)
Receiving objects: 100% (2151/2151), 251.41 KiB, done.
Resolving deltas: 100% (1319/1319), done.
jason@lappy-2 [jason*] projects $ cd webkit-server
jason@lappy-2 [master] webkit-server $ ./build.sh
WARNING: Ignored (not found) '/Users/jason/projects/webkit-server/src/webkit_server.pbproj'
make: *** No targets specified and no makefile found.  Stop.
jason@lappy-2 [master] webkit-server $ 

I'm on snow leopard, if that makes a difference.

The reason I copied it into the gem dir was that was the only way I could seem to get it to build. I'm not exactly sure what building the gem does differently that makes it work, but it seemed to build a new webkit_server binary, so I went with it.

@niklasb

@jason-o-matic: In that case I don't know exactly what the issue is, it seems related to how qmake works on Mac. So you got it to build and it didn't work. I guess that my changes simply haven't solved your particular issue then, unfortunately.

@neerajdotname

I am getting this issue even with Thin. capybara ,by default, first attempts to load Thin first. If that fails then it attempts to load webrick.

@jferris
Owner

Are you guys still having issues with this? Can you try again on the latest master?

@niklasb

@jferris: I assume d8020ce is the commit that is supposed to fix this issue? I will definitely try it out soon and will give you some feedback.

@jferris
Owner

@niklasb I think that will fix load errors, but I actually think the changes we've made in Connection, PageLoadingCommand, and WebPageManager with respect to tracking ongoing requests will fix hanging tests.

@niklasb

@jferris: Very nice. I had some serious issues with loading highly dynamic pages like Gmail or Facebook. loadProgress would sometimes just stop reporting progress at about 80% or something and loadFinished would never be triggered. I'm eager to test if those changes fixed some of the issues.

@jobseekerltd

@jferris I found out that the following methods in WebPageManager.cpp can cause webkit-server to hang:

void WebPageManager::replyFinished(QNetworkReply *reply) {
  int status = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt();
  logger() << "Received" << status << "from" << reply->url().toString();
  m_started.remove(reply);
  logger() << m_started.size() << "requests remaining";
  if (m_started.empty() && !m_success) {
    emitPageFinished();
  }
}

void WebPageManager::setPageStatus(bool success) {
  logger() << "Page finished with" << success;
  m_success = success && m_success;
  qDebug() << "m_started.empty() = " << m_started.empty();
  if (m_started.empty()) {
    emitPageFinished();
  }
}

There is a case where WebPage finishes loading (loadFinished called) and m_started is not empty. For example, before completing loading of resources, a page is still able to trigger additional requests using JavaScript. Therefore, we will have m_started.empty() = false and m_success = true. In this case emitPageFinished() method will never be triggered. I'm wondering if the following code:

  if (m_started.empty() && !m_success) {
    emitPageFinished();
  }

should really be:

  if (m_started.empty() && m_success) {
    emitPageFinished();
  }
@jferris
Owner

We just released 0.13 which has a bunch of async fixes. Can you try again with the latest release?

If you run into issues, can you paste the output from the webkit_debug driver?

@mhoran
Collaborator

Closing this out, as 0.14.0 has resolved many of the outstanding hang issues. The code mentioned by @climbingrose has also been removed. Please reopen if these issues are still present after upgrading to 0.14.0.

@mhoran mhoran closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.