Why does a Macbook pro's internal screen flicker ONLY when it is on a GPU? I have a Macbook pro 2017 (15 inch, touchbar).
Since a couple of months ago, once the laptop is on GPU for a long time (at least 3-4 hours), the internal screen starts to flicker, like this:

The flickering gets worse until the internal monitor turns into blank screen (even though it is technically ON, the backlight is working, but it shows just a black image). The external monitors have no issues at the same time and show the correct image.
I took the laptop to Apple genius bar and showed a recorded video of the issue. Apple repair team could not reproduce the issue even after a video triage (because it only appears after some hours of use). Despite that, they REPLACED the Logic Board, the Top Case, the I/O Board, and the battery, hoping that the issue will never show up again.
Unfortunately, screen flickering re-appeared after receiving it back.
What could be the cause of this issue?
Here are my speculations:

It's NOT a GPU issue: The GPU is attached to the logic board and is recently replaced, while the problem persists. Besides, when the internal monitor starts to flicker, the  external monitors that use the same GPU (though, via USB-C) do not flicker. It only happens for the internal monitor.

It's NOT an internal MONITOR issue: Screen flickering appears only after hours of use, when the GPU is enabled (i.e. when the laptop is connected to the external display, OR if I disable the internal Intel graphics card in power settings). Interestingly, when the screen flickers, switching back to the internal intel graphics card resolves the flickering. I just have to detach the external monitors and/or enable automatic graphics switching, and the flickering disappears after a few seconds. Detach the external monitors and the internal monitor starts to flicker again.

It is related to heat but not all about overheating: The problem only arises after a few hours of use, but I don't think there is an OVERheating issue. When the screen starts to flicker, none of the GPU sensors shows a high temperature. The internal sensor reports a GPU temperature of at most 55°C.


What else could be the cause of the this? It's weird enoguht that half of the laptop is replaced but the issue is still there..
My own hypothesis is that:

The LVDS cable that transfers data from the GPU to the internal monitor is affected by heat or damaged... But I wonder... Isn't it the same cable that transfers data from the &quot;Internal HD Graphics card&quot; to the internal monitor? Why does it only happen when I am using the GPU? Is it easy/cheap to replace this cable?

Since the GPU is OK for the external monitors (all 1080p) but flickers for the internal monitor (2880-by-1800), then maybe the GPU cannot feed a high-resolution screen when it is warmed up (again, heating issue?)


What could be the cause if this mystery?
P.S. Resetting the SMC and PRAM did not work.
P.S. Apple diagnostics shows no issue.
I've been diagnosing a similar issue. It's helpful to run this tool with various configurations, then use unix diff to compare the configuration settings.
/System/Library/Extensions/AppleGraphicsControl.kext/Contents/MacOS/AGDCDiagnose

e.g.
diff -u AGDCDiagnose-high-freq-after-detection.txt AGDCDiagnose-without-EDR.txt |
@@ -1772,8 +2354,8 @@
 Link Lanes 4 {4,4}
 Link Rate (Mbps)   3240 {3240,3240}
 Link Bits  30 {18,30}
-Voltage Swing (Level)  {255,255,255,255}
-Pre-Emphasis (Level)   {255,255,255,255}
+Voltage Swing (Level)  {0,0,0,0}
+Pre-Emphasis (Level)   {0,0,0,0}
 Spread Enabled
 Enhanced Framing   Enabled
 Scrambler  Enabled
@@ -1820,7 +2402,7 @@
 DIG FE B
 Number of Devices  1
 Timing DICT    21
-Display Mode   80004003
+Display Mode   80006003
 Refresh Rate (Calculated)  60 Hz
 Refresh Rate (Stored)  0.0 Hz
 Window (Active)    2880 x 1800
@@ -1924,7 +2506,7 @@
 DIG FE A
 Number of Devices  1
 Timing DICT    21
-Display Mode   80005022
+Display Mode   80003022
 Refresh Rate (Calculated)  60 Hz
 Refresh Rate (Stored)  0.0 Hz
 Window (Active)    3840 x 2160
@@ -1947,12 +2529,12 @@
 Dynamic Range  1 (SDR)