Happened to my friend. His son dropped his phone one time too many and facial recognition didn't work from them on.
He took the phone to the service center and was told the true depth sensor was broken and would need to be replaced. Cost was 38000 INR to replace when the entire phone cost around 65000 INR.
He said fuck it and came back. After a couple of weeks, it started working on its own.