When the three-hour running time of Avengers: Endgame was confirmed a few months ago, some Marvel fans were wetting themselves at the prospect, or at least worrying that they might. The question was when the average cinemagoer – one whose resolve has not been strengthened by exposure to the lengthier works of Béla Tarr or Jacques Rivette – could expect to spend a penny, especially if he or she had already spent a fortune on an extra-large Sprite. It was enough to make grown bladders weep. Kevin Feige, president of Marvel Studios, announced that Avengers: Endgame was going to be one of those movies in which “you just don’t ever find a good time to run out to the bathroom”.

Then again, Feige hasn’t met Dan Gardner, the 52-year-old creator of RunPee, an app that has become indispensable for anyone caught short during a long film. At the risk of turning the whole thing into a weeing contest, Gardner posted a philosophical response to Feige’s statement: “There is always time to pee,” he said.

RunPee subscribers select a title from the app’s database at the start of the movie, then set the timer and wait for their smartphone to vibrate at those two or three instances when it’s safe to leave the room without missing anything important; a mini-summary of the scene is available for users to catch up on as they return to their seat.

Making a dash for it: Karen Gillan in Avengers: Endgame. (Disney/Marvel Studios via AP) Photograph: null/AP

Gardner had the idea after squirming through Peter Jackson’s 201-minute King Kong in 2005. “I needed to go so badly, which made the end of that movie really uncomfortable,” he says from his home in Asheville, North Carolina. “If I’d known about this long inessential scene with the bugs earlier on, I could have gotten up to pee then.”

RunPee is now an integral part of the moviegoing experience for many Americans – it currently has more than 108,000 registered fans – though even its creator wasn’t anticipating quite how vital it would be during the opening weekend of Avengers: Endgame. “We crashed! We ran through our bandwidth limit in hours and we’ve never come close before.” He puts it down to the way that the length of the film has become part of the mainstream conversation about it. “They’re usually two-and-a-half, two-forty-five. But there’s a psychological effect to hearing ‘three hours’. That’s a range we don’t usually get into.”

Dan Gardner, the developer of RunPee. Photograph: @RunPee

There has been a surge of websites suggesting pee-times for Avengers: Endgame – the scene where Hulk is eating lunch is one popular suggestion – but they don’t understand the intricacy of Gardner’s craft. “Pee-times are delicate,” he says. “We considered the Hulk one but here’s the thing: the minimum length of any pee-time is three minutes. Then you need to give people a chance to settle back into their seat. I’m not going to send someone to the restroom and then have them return and be, like: ‘Oh, by the way, you missed this cool thing with Thor.’”

Identifying the ideal pee-time, he tells me, is harder than it looks. “One of the misconceptions is that they’re boring scenes that could have been cut, which is not the case. Most well-made movies have good pee-times because of their natural ebb and flow.” Only the taut horror film A Quiet Place came close to being un-pee-able. “That really was a hard one to do. Every scene feels like a masterpiece.”

When studying a movie for pee-times, Gardner and his colleagues, who include his mother and sister, look for scenes that recap what the audience already knows, as well as ones that can easily be summarised. It’s for that reason that the app is best-suited to plot-driven blockbusters rather than subtler works more dependent on mood and nuance. Don’t go there expecting to find Last Wee at Marienbad, A-pee-calypse Now or Al Gore’s An Incontinent Truth.

The Favourite, a particular challenge for the RunPee app. Photograph: Yorgos Lanthimos/Allstar/Film4

Give RunPee its due, though: it does try, though the app practically admits defeat when it comes to a film such as The Favourite. “This was a very difficult movie,” reads the summary, “due to the character development continually taking place.” If you really have to skip anything, it advises, try the bit when the naked buffoon is being pelted with fruit: “This Peetime contains an unusual scene with full-frontal nudity of a man. If you are uncomfortable with this, I’d recommend this time.”

It is on Schindler’s List, though, that the limitations of RunPee really become apparent. At the 70-minute mark, it cautions: “There’s a great deal of violence in this Peetime that you may want to avoid; it deals with the Jews being taken out of the ghetto to be sent to the trains.” Anyone who prefers to experience Spielberg’s Holocaust drama with the suffering and distress expunged may have problems other than a dicky bladder.

Gardner is aware that there are doubters. “It’s not for everybody. A few people on Twitter are, like: ‘Um, hello, just go to the rest room before the movie.’ We like to point out that RunPee is like insurance: it’s the app you want to have but not need, rather than needing it but not having it.”

Bertolucci’s 1900 requires ‘two or three intervals’. Photograph: Allstar/Paramount

Some of us, though, will be suspicious of anything that countenances the missing of even the smallest part of a film. “I think it’s a funny, innovative idea and I wouldn’t knock it,” says Justin Johnson, lead programmer at the BFI Southbank. “But I’m not sure it adds much to the cultural experience. Films are made by people to be seen in certain circumstances in a certain way. The film-makers have already decided in the editing process what they do and don’t want you to see, and viewers inevitably miss important bits of films when they leave their seat.”

Some movies make it easy by incorporating their own breather, such as 2001: A Space Odyssey, Barry Lyndon or Rivette’s 260-minute La Belle Noiseuse, the study of an artist and his model, which comes with a title card at the two-hour mark: “Before the next pose, a five-minute intermission.” Bollywood releases are structured specially around the midway interval, sending their audiences off to the bathroom or popcorn counter with a cliffhanger. And films of inordinate length demand a break. “If it’s really long, like Abel Gance’s Napoléon or Bertolucci’s 1900, we have two or three intervals,” says Johnson. “Gone With the Wind, too, is a bit longer than you could reasonably expect audiences to go without stretching their legs. Personally, I prefer not having a break. If you’re watching something on the big screen, it’s nice to really stay in it for the duration, but I understand that people’s bladders don’t work in tandem.”

Break built in: Barry Lyndon Photograph: Allstar/Warner Bros

Better, surely, that we all act like adults and exercise some forward-planning, some restraint in the matter of consumption – take a leak while the trailers are on and skip the jumbo soda. One argument against the RunPee app is that it is merely accelerating the miserable process by which our cinemas have become indivisible from our homes. To the constant chatter, the flagrant use of mobile phones and the sudden glare of the house lights snapping on the moment the end credits start rolling, we can now add the sound of the RunPee app vibrating in the pockets of audience members who treat the world as their living room. Our attention spans have become enfeebled along with our bladders, and anything that doesn’t help to arrest that slide could be accused of exacerbating it.

“The cinema isn’t dead,” said the director David Fincher in 2017. “The place is still filled with kids, it’s just they’re all on their phones. It’s a social event like a bonfire, and the movie is the bonfire. It’s why people gather but it’s not actually there to be looked at.”

What resembles a gloomy endgame for the cineaste is a bright future, a Yellow Brick Road, in fact, for the RunPee devotee (give or take the inevitably lengthening queues for those mid-film toilet breaks when everyone’s app buzzes at the same time). Gardner has even added several features, including one that tips off users about scenes that appear during or after the end credits, and another (“Alert Peetimes”) that branches out into MPAA territory by signalling upcoming instances of violence or animal abuse. I try to grab myself a piece of the action by suggesting to him a special symbol for films where extended scenes of running water may agitate sensitive bladders – Chinatown, say, or the Lord of the Rings cycle with its abundant waterfalls. And how about a RunPoo facility for those lengthier bathroom breaks? “Man, that’s a tough one,” he says, mulling it over. “You just never know how long that’s gonna take.”