A few years ago, a particular male cardinal perched outside my dining room window and pecked, pecked, pecked against the pane ... all ... day ... long. Apparently, when some birds — robins also apparently display this behavior frequently — spot their own reflection, they interpret this as an intruder and begin attacking or pecking at the window to chase the intruder away, according to the website Wild-Bird-Watching.com.
My cardinal hasn't reappeared this season, but he's been replaced by a male bluebird who is just as incessant, and perhaps even more aggressive. I spotted this one dive-bombing a squirrel that ventured too close to its nesting box.
Here's a YouTube video I made of the cardinal several years ago when I was bored one Saturday afternoon ...
... and here's one of the new visitor.