I'm familiar with the iPhones turning dim while overheating, but it's pretty clear when this happens. For me, whenever I was outside in ~90 degree F while doing something intensive on the phone with full brightness, AKA in music with GPS, intensive app game, steaming. I understood the screen went dim because the phone was warm and I was using it more than normal in hot temperatures.
Now with my 12 Pro, after just plugging the phone indoors to charge and starting up a game, the phone instantly went dim as if it were overheating which is strange because the phone wasn't warm; the sun wasn't out nor was I outside to begin with. Brightness slider at max was still really dim, bringing it down makes the screen barely visible. After pressing the sleep button once and waking the phone, the screen was at normal brightness like normal. Maybe the phone is really overheating in just that one moment in some weird programming logic way, or it simply a bug/hardware issue. Maybe I'm unlucky and the other replies are overheating issues, I'm not sure. But it's definitely happened more on the 12 Pro for me compared to my old 5s, 6s, and Xs, not once did those phones get dim unless the phone or the environment were obviously warm. At least, I think it should be looked into.. this thread has a good number of replies compared to what I've read of older phones tbh.