I had this happen on the iPhone 6s Plus. Turned out it may have been temperature. I was flying with direct sunlight hitting the phone screen and it was pretty hot out. I was also running the iOS 12 beta at the time too so not sure if that played a factor or not. I now am running the public release of iOS 12 and it hasn’t happened again, but I also have not flown in those same hot conditions again either.
To be safe, I always close all other apps and refresh the memory before a flight. I use an app that displays free memory and cpu usage too so I know the current state of the phone before I take off.