Penn grad and movie director Gavin O’Connor (Miracle) is one of the few people who didn’t know about Ben Affleck’s fraught personal life when they teamed up for The Way Back, a movie about (among other things) a man whose alcoholism has wrecked his marriage.

“I have no social media at all. I don’t read anything that has to do with celebrities. I honestly was not at all aware of Ben’s drinking issues," said O’Connor, even though the two had worked together on The Accountant.

"When he called me about doing the movie, and we met for dinner and he started to open up about his alcoholism, that’s really the first time I started thinking about the implications,” he said.

It worried him. Questions of “life imitating art, art imitating life” were bound to be swirling in the mind of the viewer.

And O’Connor didn’t know if that would help or hurt The Way Back (opening March 6), the story of a basketball coach (Affleck) trying to turn around a struggling basketball program at his Catholic school alma mater — and trying to manage his own troubled life, including a drinking problem that has left him estranged from his wife (Janina Gavankar).

Ultimately O’Connor and Affleck decided to forge ahead, so long as Affleck was willing to do some soul-baring work.

“I said, ‘Ben, the only way we can do this is if you are not only willing to confront the disease, but open up that box and let the demons out. And they are your demons because those are the character’s demons, they are running parallel. If you are unwilling to do that in an authentic way, then we’re wasting our time,’ ” he said.

Affleck said he was on board, Warner Bros. agreed to back the project, and O’Connor went to work in earnest.

Problem solved?

Not hardly. The ink was barely dry on the contracts when O’Connor learned Affleck had relapsed.

‘I suddenly couldn’t reach him'

“We had just started prep and started having all these conversations, and like two weeks later I suddenly couldn’t reach him for a couple days. And that’s very unlike Ben not to respond, because he’s such a pro, and then somebody said ‘Go online,’ and there was Jen [Garner, Affleck’s ex-wife], and I find out he went off the deep end and into rehab.”

Through it all, Affleck maintained his commitment to the film.

“He was getting furloughs every day and would leave with a sober buddy and come to meetings with me to work on the script and the character and the basketball part of the movie, because there are kind of two trains running in the story,” O’Connor said.

The Way Back contains two potential turnaround stories — one about a team, one about an alcoholic — and they don’t play out as you might expect, despite commercials that make the movie looklike a slick update of Hoosiers.

“Ben had literally gotten out of rehab the day we started shooting the movie,” O’Connor said, and that had its advantages. “I had a very raw, very vulnerable actor who was really just open and available.”

Affleck also put his salary in escrow, the director said, as a guarantee that he’d do the work. He was all in, financially and emotionally.

In the end, O’Connor is pleased with the result.

"[Affleck] was really game for all of it as an artist. He really put himself out there, and it was very brave of him to do it. I’m really proud of him for doing it, and it actually became very cathartic for him,” said O’Connor, who made a pit stop this week to talk about the film in Philly, where he played linebacker at Penn and was at one time the school’s sack leader.

How Penn football and Villanova basketball fit in

When he returned for a game last fall, O’Connor met another former player, Michael Turner, who gave him the bad news: Turner was the new record holder.

O’Connor was happy to pass the baton. Though tall and broad and fit in the manner of an ex QB terrorizer, he was always more of a movie buff than a sports nut. He played football, he said, because after his parents divorced, he knew it was a way to please and spend time with his father. (O’Connor grew up in North Jersey).

The complex intertwining of sports and fathers and sons is a theme that turns up repeatedly in O’Connor’s work, from Miracle to Warrior and now in The Way Back. O’Connor wanted to emphasize that aspect of the script, because he knew it would engage his own emotions, and he asked writer Brad Ingelsby to punch up those elements.

“I pushed the script in that direction, and Brad was very gracious, and he’s such a good writer he was really generous about that, and I’m very grateful to him.”

Ingelsby, from Berwyn, also knows his way around a basketball court. His father is former NBA and ABA player Tom Ingelsby who played at Villanova and coached at Archbishop Carroll. His brother Martin played point guard at Notre Dame and currently coaches at University of Delaware.

Inglesby has also written the TV series Mare of Easttown, starring Kate Winslet and currently shooting in Chester County. O’Connor is executive producer of the series, and had been lined up to direct some episodes before other commitments arose.

The Bradley Cooper connection

Speaking of near-misses, O’Connor said his proposed WWII movie, Atlantic Wall, with Bradley Cooper, is not going to happen. Cooper has committed to his Leonard Bernstein biopic, and O’Connor is doing another movie for Warner Bros. called Fast, from a Taylor Sheridan script about a special forces soldier in the middle of a conflict between the DEA and CIA.

O’Connor has also opted out of a chance to make another Green Hornet reboot, even though that’s where the money is in Hollywood.

“The landscape in the industry is changing so much. It’s hard to make a go of it unless you’re making a movie about a guy in a cape and tights,” he said. “I’m still a believer in the Little Movie That Could, smaller dramas. I make them, and I support them, because I want them to survive."

Warner Bros. green-lighted The Way Back “as a favor to Ben, because he wanted to do it and he’s made movies for them," O’Connor says. "We were this little movie over here that nobody paid much attention to. The head of the studio, when we made the deal, literally said. ‘I’ll see you at the premiere.’

"So it was great. It was like making an indie movie for a big studio.”