Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Screen flickering #7

Closed
osy opened this issue Jun 27, 2019 · 85 comments
Closed

Screen flickering #7

osy opened this issue Jun 27, 2019 · 85 comments
Labels
graphics Graphics/GPU issues kernel KEXT and kernel issues

Comments

@osy
Copy link
Owner

osy commented Jun 27, 2019

Probably an AMD framebuffer issue. Only appears if resolution is set to 2560x1440.

Workaround

One workaround is to always reset the resolution on display wakeup. We can use the displayplacer and sleepwatcher utilities to do this automatically after every display wakeup.

  1. Install https://github.com/jakehilborn/displayplacer
  2. Install https://www.bernhard-baehr.de with brew install sleepwatcher
  3. Run displayplacer list and get a string with all your displays, order, etc
  4. Create ~/Library/LaunchAgents/de.bernhard-baehr.sleepwatcher-displayfix.plist with the template below
  5. Run launchctl load ~/Library/LaunchAgents/de.bernhard-baehr.sleepwatcher-displayfix.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
	<key>Label</key>
	<string>de.bernhard-baehr.sleepwatcher-displayfix</string>
	<key>ProgramArguments</key>
	<array>
		<string>/usr/local/sbin/sleepwatcher</string>
		<string>-W</string>
		<string>sleep 10; /usr/local/bin/displayplacer "id:E5BB9F08-9D64-22D5-06B5-9872624162C9 res:3008x1692 hz:60 color_depth:8 scaling:on origin:(0,0) degree:0" ; /usr/local/bin/displayplacer "id:E5BB9F08-9D64-22D5-06B5-9872624162C9 res:2560x1440 hz:60 color_depth:8 scaling:on origin:(0,0) degree:0"</string>
	</array>
	<key>RunAtLoad</key>
	<true/>
	<key>KeepAlive</key>
	<true/>
</dict>
</plist>

Replace the two displayplacer argument strings with your own custom string. The difference between the two instances is that first we set the res to a higher one res:3008x1692 and then to what we want res:2560x1440. The sleep 10 prevents any issues trying to set the resolution before the display turns on.

@osy osy added the kernel KEXT and kernel issues label Jun 27, 2019
@qibinghua
Copy link

Do you fix it in kernel?

@osy
Copy link
Owner Author

osy commented Sep 29, 2019

It’s very difficult. I’ve been looking but I can’t find anything. The workaround is the best I can come up with right now.

@ccsnake
Copy link

ccsnake commented Oct 2, 2019

same issue after wakeup, on dell p2715q 3840 x 2160

@osy
Copy link
Owner Author

osy commented Oct 2, 2019

With workaround?

@ccsnake
Copy link

ccsnake commented Oct 2, 2019

Just 1.4.1 , is there any progress?thx:)

@qibinghua
Copy link

What about Inject EDID? @osy86

@osy
Copy link
Owner Author

osy commented Oct 6, 2019

I have not tried, please let me know if you try.

@qibinghua
Copy link

it is not working. and how do fix preview image?

@osy
Copy link
Owner Author

osy commented Oct 6, 2019

You're referring to #18 ?

@derfbwh
Copy link

derfbwh commented Nov 23, 2019

Just chiming in to relay my configuration and confirm that I'm seeing severe flickering on one of my monitors at any resolution when HiDPI is enabled:

HVK
10.15.1 (and also tested w/ 10.15.2 beta)
HP Envy 27" 4K (flickering)
QNIX 27" QHD (not flickering)

So far I've tried two cables - a mDP to DP cable, and a USB-C to USB-C cable. Both experience flickering that makes the system more or less unusable.

Thank you for all your hard work getting us this far!

@osy osy added the graphics Graphics/GPU issues label Dec 21, 2019
@petermaple
Copy link

I've got 24k AOC U2879G6 screens. when use 1 screen and set HIDPI to 19201080,everything works fine. When I plug into the 2rd screen, all the 2 screens flickering, whatever HIDPI setting. Then I plug out the 2rd screen, everything become normal again without rebooting or log out.

@petermaple
Copy link

and no flicker happened when both screen are orignal 4K definition.

@petermaple
Copy link

delete whatevergreen changes nothing,still flickering

@osy osy changed the title Screen flickering on wakeup when resolution is 2560x1440 Screen flickering on wakeup Jan 25, 2020
@KrisCris
Copy link

Just chiming in to relay my configuration and confirm that I'm seeing severe flickering on one of my monitors at any resolution when HiDPI is enabled:

HVK
10.15.1 (and also tested w/ 10.15.2 beta)
HP Envy 27" 4K (flickering)
QNIX 27" QHD (not flickering)

So far I've tried two cables - a mDP to DP cable, and a USB-C to USB-C cable. Both experience flickering that makes the system more or less unusable.

Thank you for all your hard work getting us this far!

Have you ever tried to output 3 screens, like 2 via DP(or USB-C since ultimately it uses DP) and 1 via HDMI (you can connect both HDMI and DP to one of your display if possible).

@diskdude
Copy link

I have the same issue:

  1. When connecting only one 4K display (1.5:1 scaling, "looks like" 2560x1440), the workaround fixes the problem.
  2. If I then connect a second display (a 2K, 1200x1600; rotated) the 4K display starts flickering (even after the workaround which fixed it above). The workaround no-longer works when attempted after connecting the display. If I disconnect the 2K display, so there is only one 4K display connected, the workaround works again. Reconnecting the same 2K display a second time causes the 4K display to start flickering again.
  3. If I then connect a third display (another 2K, 1200x1600; rotated), the 4K display resets to 2:1 retina scaling. If I change it to 1.5:1 scaling, everything works again (i.e. workaround OK).
  4. With three displays connected, if I sleep and wake up the computer, the 4K display flickers again. The workaround doesn't help. One new workaround I found was to physically unplug the 4K display and plug it back in. That seems to reset the framebuffer, but is not ideal. Right now I am just disabling computer sleep in System Preferences, but would much rather have it sleep overnight when I do. ;-)

I am using two USB-C to DP adapters (one for 4K, one for 2K) and one DP port (second 2K). I found that using the HDMI port for the 4K display, and using both DP ports for each of the 2K displays, did not change the above behavior.

On a separate note, I found that using the HDMI port for the 4K display caused my windows to re-arrange on display wake up (not necessarily computer wake up). This hasn't happened so far when using two USB-C DP adapters and the DP port. Perhaps a lag in the AMD card initializing the HDMI chipset? Do they use a discrete IC that performs a DP > HDMI signal conversion like some of the other NUCs?

Happy to perform other tests, and any hacks the legendary @osy86 might come up with!

@deftdawg
Copy link

Adding a 3rd display fixes the headache inducing flicker I was experiencing with a 2nd display...

Building on @Yrp said in #212 (that bug should probably be a dupe of this):

  • Going from 1 to 2 displays causes intermittent flickering
  • Going from 2 to 3 displays resolves the flickering
  • Dropping down from 3 to 2 displays -> no flickering either
  • Going 2 to 3 to 2 again -> no flickering
  • Dropping from 2 to 1 and then back up to 2 again results in flickering

The displays I'm using are:

  1. LG 4K via miniDP
  2. Samsung 2K via miniDP
  3. 720p MPi3508 Raspberry Pi Display (3.5")

The resolutions of the displays doesn't seem to matter, the 4K w/ the 720p had flickering going from 1 to 2 displays.

I might be able to hook up a 4th display to the second HDMI, if knowing that behaviour would be helpful.

Haven't tried with any screens sleeping.

There are HDMI and DP Dummy (ghost) display adapter plugs that can be used to fake a screen which could be an inexpensive hardware workaround (~$2 on ebay from China)

@Yrp
Copy link

Yrp commented Apr 10, 2020

Adding a 3rd display fixes the headache inducing flicker I was experiencing with a 2nd display...

Building on @Yrp said in #212 (that bug should probably be a dupe of this):

  • Going from 1 to 2 displays causes intermittent flickering
  • Going from 2 to 3 displays resolves the flickering
  • Dropping down from 3 to 2 displays -> no flickering either
  • Going 2 to 3 to 2 again -> no flickering
  • Dropping from 2 to 1 and then back up to 2 again results in flickering

The displays I'm using are:

  1. LG 4K via miniDP
  2. Samsung 2K via miniDP
  3. 720p MPi3508 Raspberry Pi Display (3.5")

The resolutions of the displays doesn't seem to matter, the 4K w/ the 720p had flickering going from 1 to 2 displays.

I might be able to hook up a 4th display to the second HDMI, if knowing that behaviour would be helpful.

Haven't tried with any screens sleeping.

There are HDMI and DP Dummy (ghost) display adapter plugs that can be used to fake a screen which could be an inexpensive hardware workaround (~$2 on ebay from China)

Your summary is very good!

@deftdawg
Copy link

I've now done some additional testing with 4 displays. The displays I'm using are:

  1. LG 4K via miniDP
  2. Samsung 2K via miniDP
  3. 720p MPi3508 Raspberry Pi Display (3.5") via HDMI
  4. SyncMaster 206 (1680x1050 res) via HDMI
  • Mirroring w/ 2 Displays -> no flickering
  • 1 to 2 mirrored to 2 not mirrored -> flickering
  • 1 to 3 to 2 mirrored to 2 not mirrored -> no flickering
  • 2 to 3 to 4 -> no flickering
  • 4 to 3 to 2 -> no flickering

This seems to confirm the flickering effects only occur when a second display is added and clear after adding a 3rd or more displays until the number of active displays falls back to 1 and rises to 2 again.

@KrisCris
Copy link

I've now done some additional testing with 4 displays. The displays I'm using are:

  1. LG 4K via miniDP
  2. Samsung 2K via miniDP
  3. 720p MPi3508 Raspberry Pi Display (3.5") via HDMI
  4. SyncMaster 206 (1680x1050 res) via HDMI
  • Mirroring w/ 2 Displays -> no flickering
  • 1 to 2 mirrored to 2 not mirrored -> flickering
  • 1 to 3 to 2 mirrored to 2 not mirrored -> no flickering
  • 2 to 3 to 4 -> no flickering
  • 4 to 3 to 2 -> no flickering

This seems to confirm the flickering effects only occur when a second display is added and clear after adding a 3rd or more displays until the number of active displays falls back to 1 and rises to 2 again.

In my case, mirroring displays can cause consistent flickering...
(4K+2K)

@deftdawg
Copy link

@KrisCris interesting... My 2K display is rotated 90 degrees. I wonder if that has an effect (certainly the mirrored resolution is lower)

@deftdawg
Copy link

I have noticed with single 4k monitor usage, I see sometimes see very occasional glitches like once every minute or two, this isn't consistent. I tend to notice it when I have google chrome up with something with a white background; I think because it's most obvious to my eyes.

I usually power up my other two displays to workaround the issue.

On a side note, I was also able to observe a strange occurrence where by my primary 4k display and tertiary 720p displays would not wake up... This was after 5 days + 20 hours of uptime... Rather, when I had them powered on my secondary display would glitch out hard until I shut the other two displays off. The machine eventually kernel panic'd (your machine has crashed OSX screen). Prior to it's crashing I was able to capture the Console log for a few seconds during which I powered up the other screens to induce the flickering on the secondary display, then shut them off and save the log. I'm attaching that here in case it is helpful.

AMD-Video-Driver-Bug.txt

@osy
Copy link
Owner Author

osy commented Jun 15, 2020

@KrisCris I ran some benchmarks before and after SLForceFPS. Both geekbench 4 and 5. CPU and OpenCL benchmarks. I computed the percent difference between before and after.

GB4 GPU: 2.25808601 %
GB4 CPU Single: -3.8524256 %
GB4 CPU Multi: -1.89718865 %

GB5 GPU: 5.18569413 %
GB5 CPU Single: -4.84460694 %
GB5 CPU Multi: 3.08264682 %

The fact that some of the results show a gain in performance after enabling SLForceFPS means that it's probably within the margin of error. I think running two benchmarks one after the other will result in something like that. Anyways, on my machine it doesn't seem like SLForceFPS has any real performance impact. Do you see the same results?

@osy
Copy link
Owner Author

osy commented Jun 24, 2020

To summarize:

  • The root issue is deeply rooted in Apple/AMD drivers + firmware and after tens of hours spent debugging this, I cannot find a good fix.
  • A general workaround is released in the installer which forces SkyLight to refresh at a constant rate of 20FPS (or higher). Unfortunately this costs some CPU/GPU usage but the GeekBench scores are not more than 5% different.
  • Other people have found workarounds including: a headless HDMI adapter, changing the resolution on a second display, using a lower or higher resolution, rotating the display.
  • There does not seem to be a display configuration based workaround (no CPU/GPU consumption) that works for everyone, so the workaround in in the installer is still the easiest/best option.

This is as good as we are going to get without help from Apple/AMD so I will close the issue for now.

@osy osy closed this as completed Jun 24, 2020
@osy
Copy link
Owner Author

osy commented Aug 19, 2020

macOS Big Sur fixed the issue! I no longer see flashes/flickering with LG 4K (DP) or LG 5K UltraFine (TB3). No workaround needed. #308

@KrisCris
Copy link

That's good news! Does it work with all scaling options?

@osy
Copy link
Owner Author

osy commented Aug 19, 2020

I haven’t tested all of them but the ones that gave me issues before no longer had issues.

@KrisCris
Copy link

OK, can't wait to test it out after its release!

Btw, is there a guide for installing Big Sur for HacMini? I heard it's kinda troublesome right now.

@osy
Copy link
Owner Author

osy commented Aug 19, 2020

Not yet but the easiest way is to install Mojave on a new partition and upgrade to Big Sur.

@KrisCris
Copy link

Thanks for the information! I'll give it a try after I finished my work :)

@XiaoLong1473
Copy link

After booting 10.15.6 with Hacmini 2.10, changing the model to imac19, 2 can solve the problem of flickering after sleep.
image

@bughunt8
Copy link

I'm on Catalina, Macmini8,1 with a 4k monitor and it started after the monitor awakes from sleep.

My workaround was to change down the Hertz on the same resolution and that seem to stop Chrome from flickering the screen - it was driving me crazy.

@XiaoLong1473
Copy link

Plug the wireless keyboard receiver into the front blue USB port, which seems to reduce the flickering.

@cubytz
Copy link

cubytz commented Sep 18, 2020

@bughunt8 could you explain what you did in more details?

@guiyanakuang
Copy link

After booting 10.15.6 with Hacmini 2.10, changing the model to imac19, 2 can solve the problem of flickering after sleep.
image

My Environment 2k Dell U2515H + 4k Dell U2720QM
My situation.
Upgraded to the latest 2.13, 2k normal 4k blinky.
Then install 2.10 and everything is fine.
I hope my way works for you.

@mzcabc
Copy link

mzcabc commented Nov 13, 2020

Big Sur is still flickering

@deftdawg
Copy link

@9ft did you install the screen flickering workaround? I'm on OSX 11.0.1 w/ Intel iGPU drivers and screen flicker workaround and the flickering problem is gone for me (4k and 2k dual screen); I was able to shutoff my 3rd 720p screen that I needed to stop the flickering before.

The only thing I would say is video performance sucks a little bit, twitch streams and youtube videos experience a little bit of tearing sometimes; 4k/60 HEVC video I recorded stalls out during playback (same video works fine on an iGPU MBP2020)...

I'm thinking to try switching to the AMD drivers to see if they help with that.

Oh and left side window edge has a line 10 px in, but it doesn't bother me.

@deftdawg
Copy link

I'll have to eat my words, seems the problem has returned for me. I got it after wake up after trying to install 2.14. I don't know if 2.14 actually applied or not, I turned on the verbose boot setting, but I got the usual status bar on boot; so I'm not really sure. 😢

@hangdiao
Copy link

hangdiao commented Dec 2, 2021

Thanks to you all for all the discussion above, me myself ran into the same problem recently, unfortunately the work around provided by dear osy caused severe performance suffering on my HaCMini.

Luckily, I happened to notice that if I plugin three or more screens, and then unplug them all except two(4K&1080P), both left two screens stop flickering.

Is it possible that we fake one or more visual screen every time macOS boots and then remove the visual ones to fix flickering problem? @osy Thanks for your noticing and looking forward to your words, wish you happy day😁

@osy
Copy link
Owner Author

osy commented Dec 2, 2021

I tried that before (make a fake disconnect and reconnect) and it wasn’t reliable.

@hangdiao
Copy link

hangdiao commented Dec 2, 2021

I tried that before (make a fake disconnect and reconnect) and it wasn’t reliable.

Well, that is a sad news for me, thank u all the same~
Just out of curiosity, does fake connection relate with port type? Is it possible that fake HDMI connection differs from fake mini-DP connection?

@fpytloun
Copy link

fpytloun commented Dec 27, 2021

Running Monterey, 4k display HDMI output and also flickers after resume from display sleep. Changing resolution fixes the issue so also @osy's workaround works.

osy pushed a commit that referenced this issue Jul 12, 2022
* Revert "fix boot stuck on Monterey 12.1+ for brcm wifi card"

This reverts commit 240c0f5.

* Use boot-arg instead of DSDT to "fix boot stuck on Monterey 12.1+ for brcm wifi card"

DSDT will cause unexpected behavior on my test machine

* add brcmfx boot-args for Monterey 12.1+ for brcm card
@anti-decoy
Copy link

A type-c to hdmi cable will work.

@sxz799
Copy link

sxz799 commented Mar 12, 2024

Using Hackintool to customize the resolution can solve the problem of screen flickering when using dual screens. Customize the resolution you want to use by multiplying by 0.9

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
graphics Graphics/GPU issues kernel KEXT and kernel issues
Projects
None yet
Development

No branches or pull requests