Ever since I got it about 5 months ago I changed the 'Keep Wi-Fi on during sleep' setting to 'Only when plugged in' because it saves battery. It worked so far, the Wi-Fi would turn off when not using my phone and it would turn back on instantly again after pressing the power button.
But a few days ago when the Wi-Fi turned off and I pressed the power button to unlock my phone it wasn't turning on again anymore. This is when other weird things start to happen on the phone with the Wi-Fi off, for example when going to the Wi-Fi settings it would freeze for a few minutes, when I go to the battery usage settings and the storage settings pages it just shows a spinning circle and they don't show up. Also when I try to restart the phone when it's in this state it takes about 10 minutes to restart it.
The only way to turn the Wi-Fi back on is to go to the 'Keep Wi-Fi on during sleep' setting, which would then freeze for a few minutes and then change it to 'Always'. When the Wi-Fi connects again the battery usage and storage settings pages work again.
I didn't install any new apps or change anything right before this started happening. I also tried doing a factory reset but I still have the same issue. Can anyone please help me with this?