Fletcher Cox was animated.

Moments after the Eagles had what appeared to be a defensive breakthrough, forcing a fumble late in the fourth quarter of the team’s 17-11 loss to the San Francisco 49ers on Sunday, the defensive tackle tracked down an official to find out the cause for the flag on the play.

Once he found out, he pleaded his defense’s case, but to no avail. The play was called back because of an unnecessary roughness penalty on safety K’Von Wallace, who had a scary collision with 49ers running back Trey Sermon. The unnecessary roughness call negated the fumble, which was recovered and returned by cornerback Darius Slay deep into 49ers territory.

San Francisco capitalized on the automatic first down. Instead of giving up the ball in their own territory, the 49ers forced the Eagles to use all three of their timeouts and kicked a field goal to go up two touchdowns.

“That was a big turning point in the game for us,” Cox said afterward. “As a player, it honestly kind of sucks the air out of you when things like that happen.”

Despite the loss and the costly penalty, the Eagles’ defense represented itself quite well against a 49ers offense that was coming off a 41-point performance in Week 1, albeit against a seemingly subpar Detroit Lions team. On Sunday, the Eagles’ held the 49ers and their renowned running game to 117 yards on 38 attempts, good for 3.1 yards per attempt. Jimmy Garoppolo threw for just 189 yards and one touchdown, but added another score on a quarterback sneak.

Eagles linebacker Alex Singleton credited the defensive line as the reason for the strong performance against 49ers coach Kyle Shanahan’s run-focused scheme.

“They played exactly how they should,” Singleton said. “They reset the line of scrimmage. With that team and that running game, you have to. [The 49ers] are physical and they get off the ball and they play their brand no matter the situation. Those guys, especially up front, came out with the mindset that they were going to set the line of scrimmage and hats off to them.”

» READ MORE: Eagles’ Brandon Graham suffers serious injury in loss to 49ers

Most of San Francisco’s rushing yards came in the second half while protecting a lead. In the first half, the Eagles held the team to 24 rushing yards on 12 attempts. Eagles coach Nick Sirianni said the strong defensive performance in the first half gave the offense a chance to go ahead early and force Shanahan to change his game plan.

“I thought the defense really played well,” Sirianni said. “We wanted to get an early lead to make the team play from behind, and we didn’t capitalize. It’s a different game if you’re up 10-0. Maybe it takes them out of some of the stuff that they really like to do.”

The Eagles held the 49ers scoreless for most of the first half, but surrendered a 12-play, 97-yard drive to close out the second quarter.

After the game, Garoppolo said the long, sustained drive helped the offense get into a rhythm going into the second half.

“That defense makes you earn it,” Garoppolo said. “Their front is as good as it gets. They get after you and make you earn every yard. It’s just one of those ‘bend, don’t break’ type of defenses. It was a good challenge for us.”

The Eagles are still waiting for their first takeaway of the season. New defensive coordinator Jonathan Gannon has been preaching the importance of turnovers since the offseason, but they’ve evaded his group so far.

There were chances Sunday. Steven Nelson got his hands on an errant pass but couldn’t hang on. The 49ers had two fumbles on consecutive plays in the fourth quarter. One was kicked out of bounds as Derek Barnett was flagged for roughness, and the following fumble was negated by Wallace’s penalty.

It was unclear whether Wallace initiated contact with his helmet or shoulder, but he did lower his head on what resulted in an ugly hit. Sermon laid on the ground in pain for several minutes after the hit and was helped off by trainers. The rookie from Ohio State didn’t return with an apparent head injury.

Sirianni said he didn’t see a replay of the hit, but would review it on film.

“I’m looking at it live just like they are,” Sirianni said. “It’s not like I saw a replay, I didn’t see much of it. They said he led with his helmet, I just gotta trust that they did their job right. The tape doesn’t lie, we’ll figure it out from the tape, but I just gotta trust that they did their job well and it was what it was.”