webkit_server hangs periodically when run from Capybara in Ruby

I am having a problem where an instance of webkit_server with Capybara and capybara-webkit running headless connected to a local Xvfb screen hangs when visiting a URL. It seems to happen after several minutes of repeatedly visiting different URLs and executing finders. (I'm using capybara for a screen scraping application in vanilla Ruby, not for testing.)

I've confirmed that when it hangs the site is still accessible (for example, through curl or wget on the command line). I've also tried wrapping the Ruby code that invokes the visit and subsequent finders in a Timeout block so that after 60 seconds of waiting a new URL is visited, but any visit() attempt fails after the first time this occurs. The only way to fix the problem is to kill both the Ruby process invoking Capybara/capybara-webkit and the webkit_server process and restart.

When I strace the webkit_server process, I see output like this repeatedly:

clock_gettime(CLOCK_MONOTONIC, {5821, 680279627}) = 0
gettimeofday({1330890176, 712033}, {0, 33052112}) = 0
gettimeofday({1330890176, 712087}, {0, 140736435864256}) = 0
gettimeofday({1330890176, 712137}, {0, 33108640}) = 0
clock_gettime(CLOCK_MONOTONIC, {5821, 680486036}) = 0
clock_gettime(CLOCK_MONOTONIC, {5821, 680530091}) = 0
read(7, 0x1fac1b4, 4096)                = -1 EAGAIN (Resource temporarily unavailable)

And if I strace the Ruby process that invokes it, it is hung on a read():

Process 3331 attached - interrupt to quit
^C <unfinished ...>
Process 3331 detached

I know that the Ruby code hangs on the Capybara visit() method.

Any ideas on what I can do to troubleshoot or correct this is appreciated. I'm assuming the problem has something to do with some resource webkit_server needs to visit the URL but am not sure what to try next.


Selected Answer (from Grimmo)

Capybara.server do |app, port| require 'rack/handler/thin' Rack::Handler::Thin.run(app, :Port => port) end

Seems to work.

Oculus VR gets bought by Facebook for $2bil:

Most important, Facebook understands the potential for VR. Mark and his team share our vision for virtual reality’s potential to transform the way we learn, share, play, and communicate. Facebook is a company that believes that anything is possible with the right group of people, and we couldn’t agree more.

I never would have seen my hero John Carmack working for Mark Zuckerburg. In "Masters of Doom," he expressed interest in creating a metaverse as portrayed in Neal Stephenson's "Snow Crash" after completing Quake. But we kind of already had that - it was called Second Life. And it wasn't very good. Or useful. I don't see VR making the "virtual social space" any more engaging. The problem with 3D gaming-based social spaces is that they don't provide any real benefits beyond something like Google Hangouts besides better avatar customization, and narcissistic self-expression doesn't have a huge business case.

That's about the only thing I can think of that Facebook could do with this technology, besides maybe viewing 3D videos or photos from Instagram. Maybe they're just looking for a competitor to Google Glass, but that's definitely not the direction Oculus was going, and I think they would do better to stay focused as a gaming company for the next 10 years or so.

This could go well. Facebook bought Parse, and they still operate as a mostly independent entity doing great work. But I was more excited about Oculus when they were an independent company, and I'd have been happy for them had Valve bought them out.

Update Palmer Luckey answers some of the hate via Reddit. Seems like they definitely intend to go the Parse route, and the main driver was using Facebook's money to lower hardware costs, build their own components, do publishing deals with indies, and hire more people. Seems pretty reasonable. We'll see how it plays out; I just hope they don't stray from gaming. No one outside game devs have the 3D chops to do VR right now.

From Cult of Mac:

It’s a new kind of app because it uses an iOS feature unavailable until version 7: the Multipeer Connectivity Framework. The app was developed by the crowdsourced connectivity provider Open Garden and this is their first iOS app.

The Multipeer Connectivity Framework enables users to flexibly use WiFi and Bluetooth peer-to-peer connections to chat and share photos even without an Internet connection. Big deal, right?

But here’s the really big deal — it can enable two users to chat not only without an Internet connection, but also when they are far beyond WiFi and Bluetooth range from each other — connected with a chain of peer-to-peer users between one user and a far-away Internet connection.

It’s called wireless mesh networking. And Apple has mainstreamed it in iOS 7. It’s going to change everything.

Holy. Crap.

I've been getting excited about mesh networks lately, mostly due to reading too much sci-fi. I try to follow Apple developer news, as I'm always just on the edge of writing a mobile app. And yet, I hadn't heard about this.

Okay, okay. Forget the stuff about chatting during a marathon through the woods in Washington (as cool as that is). This could be a major, major fix for the internet as a whole. Let's take some examples.

Netflix has agreed to pay Comcast to stream videos across the pipes. That's the beginning of the end for network neutrality, and anyone who consistently sends a lot of data over the tubes is in danger of being put in the slow lane (or taken off completely) unless they pay carriers. That's horrible, but it's the state of things due to state-granted monopolies on fiber lines built in the 80's.

As of WWDC circa 2012, Apple had sent 1.5 trillion push notifications reaching rates of about 7 billion per day. I can only guess those numbers have gotten bigger. So what happens when Comcast or Time Warner (and God help us if that merger goes through) says to Apple, "Nice messaging service ya got there... shame if someone were to... mess with it" ? Well now, Apple can flip a switch and route straight around them.

Or what happens when the NSA plants a parasite on the backbone of the internet to siphon copies of all data running through it? Strong crypto is good enough for now, but when the NSA starts stocking quantum computers or builds enough qubits in house to start breaking that? You'd need to route around the internet. Especially if you're saying mean things about the NSA. Or, say, your ex-boyfriend who works there. Firechat, or iMessage + mesh networking could be answers.

Mesh networking may never be a substitute for real-time, bandwidth-hungry applications like Netflix or Twitch.tv. There are simply too many hops compared to the backbone-centric structure of the DNS. But for small-bandwidth systems like email, text messaging, deliveries, Bitcoin, algorithms and software, this could be a game changer.

The next steps are (hopefully) for Google and Microsoft to build cooperative, or even competing mesh-network solutions into their devices. Or for someone to release a cheap device that does mesh networking by default. The advantages of having this in phones are: a) lots of people already have phones and b) people have a reason to buy phones. I don't foresee a time when lots of people buy mesh networking repeaters that do little to nothing else - I doubt the mass market will ever understand the concept at that level. But if you package mesh networking with existing products, say wireless routers for example, we could start seeing a ton of coverage.

And that's a future I'm pretty excited about.

Make a rails app in a single file. Neat!

Interesting - James basically argues with replacing many versions of unit testing with assertions and the associated integration / system / whitebox tests. Any test that checks something redundant is probably worthless.

I tend to agree - tests should encapsulate business logic, and not really any level below that. You shouldn't test that a library or language does what it says it does; the library / language should have its own tests for that. Essentially, this looks like testing at the highest level that's reasonable.

On Gary Taubs and "Why We Get Fat":

His demonization of the calories-in/calories-out principle strikes me as a bit of a straw man argument. He says exercising and reducing total calorie intake don’t work; moreover, he says they can’t work. Most of us would argue that they can and do; the problem is not with the principle, but with its implementation.

This is not what Taubs is saying. Yes, calorie restriction works. It absolutely does. Anyone who's looked at the studies knows this. Low-carb diets usually result in eating fewer calories per day. But that's all beside the point.

The point is, if you eat 1500 calories / day of twinkies, you are going to feel miserable. You will be hungry and starved for energy, both of which are bad if you're trying to maintain new eating habits and exercise. You will lose weight, but it will suck, and failure is easy.

If you're looking at it like "I can eat all the bacon I want!" without counting calories, you will probably hit the same calorie target without the misery. High-fat foods are satiating. Low insulin levels mean leptin is actually working for you, and you feel more full, faster. Low insulin also means your fat cells aren't struggling to store everything they can, and triglycerides float freely through your blood to provide you with energy.

It's not a magic cure-all; you may still get the 3pm slump. But it takes a lot less willpower to say "no ice cream" when your fat cells aren't screaming "HEY WE NEED MORE CARBS." It's also easier to say "no cake tonight" when the alternative is all the steak you want rather than just enough sweets to make you crave more.

But the broader point is that those now questioning the utility or relevance of the concept of the dignity of work are responding to reality. They are not so much pushing people away from work as acknowledging that work has moved away from people.

So much this.

There are two features I wish current e-readers would add (notably Kindle, since that's the reader I use most often).

  1. A dynamic dictionary for books. I read a lot of genre fiction (fantasy and sci-fi) which uses a lot of invented words. It would be awfully nice if an e-reader could build these words into its dictionary only for that particular book. You could have definitions for place names, magic systems, important people, etc. that would pop up when the word is highlighted, just like the normal dictionary. These definitions could even be crowdsourced to readers, though that may bring up issues of spoilers.

  2. Support for series of books. There are three books in Peter F Hamilton's "Void" trilogy, but the Amazon titles and descriptions don't say which are which, and the description for the third book spoils part of the second. Same for disconnected series like Iaian M Bank's "Culture" novels - they're not sequels to one another, but how easy is it to find all of them in one place? Not easy. I hate to even think of series with multiple authors contributing, like books in the Cthulhu Mythos or Forgotten Realms settings. I'd love to have a page dedicated to each series with the books in reading order, or failing that, publication order.

These things are small, but would be unbelievably helpful. I'd like to do it myself for a mobile reading app, but I couldn't be arsed to deal with the nightmare that is eBook publishing. Anyone at Amazon / Apple / etc listening?

From Rob Sheldon

What are you going to do, stand up in a coffee house one night and show off your code on a projector? "And this, ladies and gentlemen, is where I got the brilliant idea to use my new mutex to manage simultaneous multithreaded access to the same chunk without the risk of a race condition!" There's wild cheering, somebody buys you drinks, and you get to go home with a cute girl who thinks your brain is super hot.

Looking for external validation will always lead to depression. When I've done some good work that I'm excited about, I do like to tell someone, but it's not so much for validation but to get someone as excited as I am about the tiny bit of awesome I've added to the world.

From the linked article. This is fucked, man. This is why I don't like mobile games - I want to pay up front for a good game, then get lost in it for hours. It's escapism, and an almost meditative state of flow when you really get into it. Not this "tap twice every day" BS.

Seriously, game devs: stop it. Just. Stop.

Update Great quote from metro.co.uk

We were going to refer to Dungeon Keeper as a non-game, but that’s not really accurate. It’s an anti-game. It is purposefully designed not to require thought, skill, or experimentation. Instead it rewards only money and, begrudgingly, patience.