Understanding What Affects Generalization Gap in Visual Reinforcement Learning: Theory and Empirical Evidence