Perovskite solar cells have been the subject of several studies aimed at increasing their operational stability, but few have looked at the underlying degradation mechanisms. The influence of the environment on the performance of devices during operation has been neglected in previous studies . Using synchrotron radiation-based operando grazing-incidence X-ray scattering techniques, we study the degradation processes of perovskite solar cells operating in vacuum and a nitrogen environment. We discover that light-induced phase segregation, lattice shrinkage, and morphological deformation occur in vacuum, contrary to earlier findings. Only lattice shrinkage occurs during the operation of solar cells under nitrogen, resulting in improved device stability. A higher energy barrier for lattice distortion and phase segregation is related to the different behaviors. Finally, we discovered that the migration of excessive PbI2 in the perovskite layer to the interface between the perovskite and the hole transport layer degrades device performance in both vacuum and nitrogen.