Ok, well you are making some progress; on your process of elimination to narrow down the problem. The issue is repeatable with BOTH the new and original head unit, so we can assume, it is not the stereos themselves. The main variable, is the door manipulation, by being shut; we have a long history of wiring problems with the wiring harness gong, from the body to the door. That would be the next thing to check, a visual inspection of the harness, going from the body to the door and a continuity check, can be done with a multimeter. The flex area of the harness, will get bent; every time the door opens and closes, eventually the wires will break or strands of wires will be reduced to just some strands of copper and often, this will cause a intermittent issue (the connection of the circuit; will move with the door being opened/ closed and then connect, when changed movement with the door open/closed, {which can kill the circuit or possibly cause a grounding out issue). You have narrowed the issue down to the door; focus, on testing the wiring and new replacement speaker.
NOTE: keep in mind, we are not looking at the car with you and we don't know how you hooked things up or the history of the car, the stereo system, how things have worked or how you upgraded things, along with the previous stock system.