• Tech Tips

    Mac High CPU Usage – WindowServer

    DISCLAIMER: I’m writing about my personal experience here. I am by no means doing some exhaustive investigation. The changes I explain below seem to make a difference, at least according to what Activity Monitor is showing for CPU usage.

    My laptop (3.1GHz i7 MacBook Pro with 16GB of RAM) has enough of power, so why has it been such a dog since starting from scratch with a fresh OS? A colleague posted an animated Gif today in Slack and my MacBook fans kicked in and it sounded like it was getting ready to fly away. This was the last straw in what has been weeks of wondering why my laptop has been slow.

    I opened Activity Monitor and found that my WindowServer process was using a significant amount of CPU resources (up to 77% when the animated gif was visible on my screen), and that it has used significantly more than the next heaviest process since I last rebooted.

    I understand that it’s probably a pretty heavy process, but it got me thinking, and Googling. As it turns out, when something is being drawn to the screen it takes processing power; go figure! One of the top suggestions was removing or disabling things from the menu bar that are constantly updating. The suggestions included CrashPlan and Little Snitch Network Monitor. Wow. I use the latter! I opened the Little Snitch preferences and unchecked “Show network activity in menu bar” and voila! the WindowServer process memory dropped about 15%. Then I closed the animated gif my colleague posted in Slack (the only other thing on the screen that was moving) and voila! it dropped again.

    Now, as I’m looking at my CPU Time in Activity Monitor I’m thinking through what I really need running. Is the “Next Meeting” (which shows the name and time of my next meeting in the menu bar) application really worth running 24/7? I don’t think so; especially if I have more important things for my CPU to be doing. After quitting this application my WindowServer CPU usage dropped to 6.6%.

    I’m going to continue to trim the fat to see how lean I can make my machine. Obviously it doesn’t stop at just trimming out running applications, but I’m blown away by the impact of small changes like these.

  • Development

    Drupal 8 User Photo Update Form

    Recently I had to come up with a simple way for users to change their member profile photo without requiring them to visit the user edit screen. Here’s the result:

    Member Photo Output

    First, I added a new Image field called “Member Photo” to the user account fields (machine name field_user_picture). Here are the settings I used:

    • Allowed extensions: png, gif, jpg, jpeg
    • File directory: users/[date:custom:Y]-[date:custom:m]
    • Max size: 10 MB
    • Checked: Enable alt field
    • Checked: Alt field required
  • Development

    Creating a Drupal 8 Route to a User Page with Dynamic User Object

    It took me some time to figure out the right combination of properties to make this work.

    My goal was to create a form that lives at /user/UID/photo (think /user/1/edit).

    I wanted the user object to be passed into the form as an argument.

    Here’s the mymodule.routing.yml file:

    Here’s the src/Form/ProfilePhoto.php file: