1

Over the past month or two the display on my old iMac 27-inch ("late 2009", running High Sierra 10.13.6) would randomly and suddenly go to sleep (sudden dead black) while in use (while typing, mousing, scrolling, etc.), but only about once a week or even less.

The first time I thought it had crashed (having the display go dead black while typing is very disconcerting) and I power-cycled it. The second time I realized the system was still running, and I logged in remotely with SSH to find everything "normal". I finally realized I could simply wake the display again with Control-Shift-Eject and then wiggling the cursor or hitting another key.

These past few days it started doing this very frequently -- every few minutes, or even more often for periods.

At first I thought it might be a software bug as it seemed to only happen when using the browser (perhaps a GPU bug).

Then, because it seemed OK for a short while after being idle for an hour or more, I thought it might be something to do with overheating, and I played with fan speeds (to the great annoyance of my ears). At first this seemed to make some difference, but I never really could make any strong correlation.

But then I realized it was probably being put to sleep under software control as apps were fully refreshing their windows upon waking the display (just as they do when returning from the screen saver, for example).

Finally I tried changing the Energy Saver settings to "Never" let the display go to sleep. This seems to have worked!

Now I've also quieted the fans, and so far (an hour or two of constant use) I have not had the screen suddenly go black since.

Does anyone have any deep understanding of how exactly the system controls display sleep, and whether or not there's any way to see logging of the events controlling display sleep?

1
  • Try running caffeinate -d to keep the display awake.
    – MarkHu
    Dec 18, 2020 at 19:53

2 Answers 2

1

You may have a Hot Corner checked. if your mouse touched a hot corner it will respond in a chosen way. One Hot Corner action is to put display to sleep. To check this go to System Preferences, Desktop & Screen Saver. Click on the Screen Saver tab and at the bottom of that pane is a button for Hot Corners. Click this and see if you hve a hot corner set up.

1
  • Nope, but I changed the one I used to start the screen saver over to instead put the display to sleep. Manual control over display sleep is much more satisfying than having it go black during use! :-) Apr 17, 2020 at 2:47
1

So, there is logging, of a sort, and I think I can now confirm the random display sleep I've been observing is indeed due to a software bug.

First off, the logging (and current status) of events and states related to system and display sleep can be found by running:

pmset -g assertionslog

Yesterday my screen stayed on for the rest of the day. However on returning to my computer this morning I found the display off. Pressing a key lit it up and the login window was there, as if I had not told it to keep the display on (but I still allowed it to lock the screen -- seems the screen saver still managed to turn off the display eventually).

About five to ten minutes later the screen went black again while I was scrolling. It continued to go black moments after being turned on again.

After experimenting for a while to see if there was a recognizable pattern in the pmset output, I decided to try killing the processes that seemed to be changing state (i.e. with a plain SIGTERM).

The first one I tried was /usr/libexec/hidd, which was promptly restarted by launchd. This made no difference to the screen going dark every few moments after being re-awoken.

The next one I tried was useractivityd. This had immediate, positive, effect. The screen has not gone black since. Interestingly this process did not die -- it's still running and has been using CPU, but it is no longer being mentioned in any pmset output.

The ongoing saga...

Today after an hour or so of normal use, the screen went black again, and again, and again, often only a second or so after waking it up. Sending SIGTERM to useractivityd again didn't do much so I sent it a SIGKILL. It was immediately restarted by launchd, but the battle to keep the display on continued.

Finally things have settled down again, but I'm not sure what I did to make it so.

Things get worse, then maybe better again

Yesterday I couldn't keep the display on for more than a few seconds, then managed to lock something up so the login screen wouldn't activate, and I ended up shutting the system down from an SSH session, powering off completely, and rebooting, only to have the problem begin again soon after.

Today it was OK for a little while, then started blanking out again and being basically unusable.

I was almost beginning to think it was a hardware problem.

Then on a whim I disabled and uninstalled f.Lux. Since then it went blank while unattended, then once more while in use, but otherwise has been much better than before.

NOT a software problem: Now the computer is basically unusable

Now the computer is basically unusable (at least from the keyboard and screen).

If the machine is really cold then the screen will stay on for a few minutes, at most. However if the machine is at "normal" operating temperature (according to all sensors and past history of all sensors), the screen may even blank out during the very early stages of booting (i.e. while the console boot messages are still scrolling during a verbose boot).

The interesting part is that the screen can be turned on by the OS (i.e. by pressing and then generating "activity" with keypresses or wiggling the mouse cursor, etc.), only to be turned off again moments or seconds later by whatever hardware and/or firmware that is failing.

If I can figure out how to programatically turn on the screen (e.g. by generating the same keyboard events that I use manually), then I may be able to continually re-light the screen with a daemon to make it possible to limp along until I'm able to replace the whole machine.

A Reprieve, of sorts....

So just after making the last edit I stumbled upon an article by someone describing this same problem. After the usual amount of entirely useless mis-directed pontification about the possible causes of the problem (all entirely impossible) and the regular raft of pointless suggested actions, there was a tiny hint that turning down the brightness might help.

I hadn't thought of that earlier because I had no luck improving the situation by running all the fans at full blast.

However I dropped the brightness to the minimum and left the screen activated all night -- and what do you know! It had not gone blank by the next morning!

I have now been using the machine, albeit with some eye strain, for a few days, including today with the room temperature climbing slightly (despite air conditioning -- it's 43C outside), with no blanking of the screen. I'm able to run the brightness at 5 bars shown on the on-screen control, or 0.33 with https://github.com/nriley/brightness

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .