You can make a difference in the Apple Support Community!

When you sign up with your Apple Account, you can provide valuable feedback to other community members by upvoting helpful replies and User Tips.

Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

com.apple.apfsd.wbc_drain

This task has now been running for a month now, when will it stop.

Just upgraded to MacOS 10.15.2 in hope that it would stop running. 😕

It prevents my iMac to go to sleep automatic.



iMac with Retina 5K display, macOS 10.15

Posted on Dec 10, 2019 12:52 PM

Reply
66 replies

Dec 15, 2019 3:06 AM in response to gjdkeu

I have exactly the same problem on my Mac Mini 2012. It's never entering sleep mode anymore since I moved to Catalina. It was working very well before on Mojave. Too bad.... The update 10.15.2 did not change anything.


The command shell "pmset -g log" shows com.apple.apfsd.wbc_drain is the culprit running for hours, with an external media disk mounted, and preventing the system to sleep as follows:


2019-12-15 10:02:13 +0100 Assertions          PID 172(powerd) Summary ExternalMedia "com.apple.powermanagement.externalmediamounted" 47:13:57  id:0x0x800008002 [System: BGTask kCPU]          

2019-12-15 10:02:13 +0100 Assertions          PID 160(UserEventAgent) Summary BackgroundTask "com.apple.apfsd.wbc_drain" 47:08:25  id:0x0xb0000819b [System: BGTask kCPU]

Dec 15, 2019 10:13 AM in response to ThomasAtToulouse

% pmset -g live          

System-wide power settings:

Currently in use:

 standby              1

 Sleep On Power Button 1

 womp                 1

 autorestart          1

 hibernatefile        /var/vm/sleepimage

 powernap             0

 networkoversleep     0

 disksleep            10

 standbydelayhigh     86400

 sleep                1 (sleep prevented by UserEventAgent)

 autopoweroffdelay    14400

 hibernatemode        0

 autopoweroff         1

 ttyskeepawake        1

 displaysleep         1

 highstandbythreshold 50

 standbydelaylow      86400

Dec 16, 2019 9:28 AM in response to gjdkeu

My mac mini server 2012 has a fusion drive with an Intel SSD I put in it (non Apple SSD).


I figured out the kernel is writing, slowly but it is always writing on the disk. The total written size increases a lot among hours, up to several gigabytes. I don't know if this is expected or not?


I made a spindump and figured out there are some fusion_wbc_xxx functions called in a loop. As per the function name it seems linked to the fusion drive. I enabled the trim option a long time ago on High Sierra or even before with no problem before I migrated to Catalina. I will make a try by disabling trim to check if the wbc_drain disappears or not?


Do you have a fusion drive too? Is trim enabled?

Dec 18, 2019 11:57 PM in response to ThomasAtToulouse

I found a trick in https://forums.macrumors.com/threads/no-sleep-after-catalina.2204818.


Killing twice the UserAgent task that runs the culprit wbc_drain solves the problem on my Mac mini.


Execute twice: ps -ef | grep UserEventAgent | grep -v grep | awk '{print $2}'| sudo xargs kill -9


If you reboot you need to execute again those commands.


I did it yesterday evening and my Mac entered sleep mode for the whole night.


Jan 29, 2020 8:26 AM in response to bkunze

OK, here is what I did to automate. I created the below python script:


#

# Fix apfsd assertion for Mac power management under Catalina

# (C) 2020-01-29 Bernd Kunze

#

import subprocess

import os

import time


Done = 0;


while Done == 0:

time.sleep (60);

Result = subprocess.Popen(['pmset', '-g', 'assertions'],

stdout=subprocess.PIPE,

stderr=subprocess.STDOUT)

PMSet = Result.communicate();


if "wbc_drain" in str (PMSet):

os.system ("ps -ef | grep UserEventAgent | grep -v grep | awk '{print $2}'| xargs kill -9");

time.sleep (5);

os.system ("ps -ef | grep UserEventAgent | grep -v grep | awk '{print $2}'| xargs kill -9");

print('\a');

print('\a');

Done = 1;


Using hhttp://launched.zerowidth.com/

a plist file is created and installed.


FixSleep.py basically waits for the assertion to appear, then kills UserEventAgent twice.


Works here, no warranties, use at your own risk.

Jan 31, 2020 1:05 PM in response to bkunze

I think I understand how to build launched…. I tried but the script did not work, however, because I think I made some errors in filling the form. In particular, the tick should be placed under the heading "RUN AT LOAD" or under the heading "LAUNCH ONLY ONCE"? Please let me know ... I am attaching how I filled out the form ... Tell me if I'm wrong ... Thanks ...

com.apple.apfsd.wbc_drain

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.