SANTA CLARA, Calif. (AP) — Robert Saleh sometimes beams with pride when watching film of his 49ers defense.

Other times he wants to hide his eyes.

It's been a perplexing season for San Francisco's defensive coordinator, as Saleh has found it difficult to get his young unit to string together four quarters of mistake-free football.

"You see the flashes," Saleh said Thursday. "You can go to every game, and there's a block of plays where those guys are executing and performing at a very high level and they look unbelievable.

"But when we trip over ourselves, it looks horrendous."

The 49ers' knack for giving up big plays cost them dearly in Monday night's 33-30 loss to Green Bay.

Packers quarterback Aaron Rodgers carved up San Francisco's secondary during a game-winning drive in the final minute.

Another big test awaits the 49ers (1-5) on Sunday afternoon when they host the undefeated Los Angeles Rams, who have the NFL's top-ranked offense led by quarterback Jared Goff.

To have any chance at an upset, San Francisco's defense has to avoid the blown coverages and game-changing plays that have marked its season so far.

"It's just being where you're supposed to be, when you're supposed to be there, and doing that for 60, 70, 80 plays," veteran cornerback Richard Sherman said.

Against the Packers, the 49ers gave up a 60-yard completion to a wide-open receiver on their first defensive snap, setting up a Green Bay touchdown. Two series later, a 54-yard completion on another busted coverage led to another touchdown.

The 49ers then clamped down, holding the Packers to just two field goals over their next seven possessions, spanning the end of the first quarter to midway through the fourth.

But trying to hold a 30-23 lead, San Francisco allowed 10 points in the final two minutes and lost. Rodgers picked apart the 49ers' pass defense on the tying and game-winning drives.

San Francisco ranks 25th in the league in pass defense (279 yards per game), too often leaving receivers wide open with plenty of room to run after the catch.

The key is "guys staying on their details, doing their job," defensive tackle DeForest Buckner said. "We've been having too many busts, and we can't have that."

Saleh called for more blitzes than normal against Green Bay, and the result was three sacks and good pressure on other plays that threw Rodgers off his rhythm.

But the 49ers need better play from whichever cornerback is playing opposite Sherman. Second-year corner Ahkello Witherspoon has lost his starting job for the time being.

Jimmie Ward, who started in place of Witherspoon at Green Bay, is nursing a hamstring injury. His status for Sunday is unknown. Greg Mabin, who spelled Ward after he was injured Monday, gave up several completions as the Packers made their late comeback.

Saleh, in his second season running San Francisco's defense, said he's examining his own game plans and preparation to make sure he's putting players in the best position to succeed.

"When we're not communicating and there's a lack of execution, it is not pretty. And that's the thing that's happening," Saleh said. "We make the smallest mistake and it's going for a lot of yards."

NOTES: Ward didn't practice Thursday. Witherspoon (concussion protocol) and nickel back K'Waun Williams (shoulder) both practiced but were held out of contact. Among the receivers, Trent Taylor (back) and Pierre Garcon (shoulder, knee) were both limited. Dante Pettis (knee) worked on a side field.

___

More AP NFL: https://apnews.com/tag/NFL and https://twitter.com/AP_NFL