The screen of my 2019 16-inch MacBook Pro regularly (maybe 1 out of 5 times) turns black when connecting external monitors (which then remain black as well). There are occasional flickers where the MacBook's screen turns on and looks normal for a fraction of a second every few seconds. Meanwhile the external displays remain black continuously. If I disconnect the external monitor, the MacBook's screen is back to normal. It happens both with an LG display connected via USB-C to DisplayPort and a Samsung display connected via USB-C to USB-C (with power delivery in case that's relevant).
I've tried multiple SMC and NVRAM resets as well as enabling and disabling different display settings like True Tone and Automatic Brightness Adjustment to no avail. The only thing that does help is to restart the machine which is very annoying. I don't want to have to restart several times a day.
I've had a 2017 15-inch MacBook Pro before with exactly the same issues. Meanwhile a Linux machine has no problems with these screens (admittedly using different cables but I don't think the cables are the problem). It's most likely a macOS software/driver issue.
Is anyone having similar problems? Any ideas how to fix?