Is your WiFi power-setting set to "on, only when charging"?
If so, try enabling "WiFi scanning always available", it's not (very) much impact in terms of battery, and seems to resolve some of these WiFi-based-hangs. 5.1.6 fixed this though, for me (it was a 5T bug that I had reported initially).
I see you are a new user here - welcome to Android Central!
With regards to your phone, is it still within the return/warranty period? I recommend contacting OnePlus Customer Support and seeing if you can return it and get a new device.