Maybe bcz incorrect tempered glass application check if it has a cut for sensors if no thn apply compatible glass. If yes then Find nearby service center its a factory defect.
I have this issue , ithink some apps conflict with the light sensor i didnot know which app is that, because in my device i am using lot more apps iam using always on amoled app i think the wrong configuration of this app.. ( not sure)
And the problem SOLVED just restart my device
Try restart your device device and chek with sensor test app