I first noticed this issue when with my new iPhone 8 back in November. At the time, the folks at the Apple Store made me run lots of tests including restoring from backup, then installing new OS. They eventually gave me a new replacement phone. I have since given my wife the iPhone 8 and picked up a new iPhone X. I have had the same intermittent dimming issues with the iPhone X. I have tried all the settings folks recommend on this thread. Last week, the folks at the Apple Store replaced my iPhone X with a new one. They didn't even ask this time as I think they are well aware of the issue. I did ask the technician if he knew about a widespread problem. He said he had only seen the issue once before -- hmmm.
I play a lot of Pokemon Go which does use GPS and often I notice the phone warm. The problem isn't related to low charge and doesn't go away if I connect to external battery to charge. I often have to restart the phone, but that doesn't always do the trick.
I don't necessary think this is a hardware issue as others have speculated since it happens on more than just the iPhone X if you've read through this whole thread. I think this is an iOS 11 issue related with the auto-brightness setting being overridden by some environmental factor. Maybe the ambient light sensor is getting confused, but if auto-brightness is turned off, it should not matter.