Subject: 25.0.92; OS X app nap slows down tty emacsclient
From: "Aaron Jensen" <[email-masked]>
To: <[email-masked]>
Date: Fri, 11 Mar 2016 22:07:20 -0800
List-Id: <debbugs-submit.debbugs.gnu.org>

This has been a terribly frustrating bug to track down, but here it is, along with a repro. The gist is that if you run gui emacs  as a server on OS X, tty emacsclients connected to it are adversely affected when the Emacs.app goes into “App Nap” mode on OS X.

Repro:

- On OS X El Capitan (probably works on Mavericks as well) run emacs -Q

- Do M-x server-start

- In terminal, run emacsclient --tty somefile

- Eval the following:

(defun test-app-nap ()

(interactive)

(message "Before %s" (current-time-string))

(redisplay)

(message "After redisplay %s" (current-time-string))

(message "read-event %s" (read-event nil t 0.001))

(message "After %s" (current-time-string)))

- M-x test-app-nap and observe that it immediately shows "After

"

- Wait for Emacs to switch to app nap. You may be able to monitor with

Activity Monitor, but emacs -Q doesn't always show up there. As long

as you are not focused on the GUI emacs, it should start to nap in a

minute or two.

- Back in the terminal, M-x test-app-nap

- You should see the "After redisplay

" message for several

(probably 10) seconds before seeing the "After

" message

- Switch to the emacs gui app, then back to the terminal and M-x

test-app-nap

- It should be back to the immediate "After

" message

App nap needs to be disabled in emacs, at least when the server is

running, but probably always. The typical workaround is to disable app

nap by going to the info window on the Emacs.app, but for some reason,

that checkbox is not available.

In GNU Emacs 25.0.92.1 (x86_64-apple-darwin15.3.0, NS appkit-1404.34 Version 10.11.3 (Build 15D21))

of 2016-03-10 built on aaronmbp.local

Windowing system distributor 'Apple', version 10.3.1404

Configured using:

'configure --prefix=/usr/local/Cellar/emacs/25.0.92

--enable-locallisppath=/usr/local/share/emacs/site-lisp

--infodir=/usr/local/Cellar/emacs/25.0.92/share/info/emacs --with-xml2

--without-dbus --with-gnutls --with-rsvg --with-imagemagick --with-ns

--disable-ns-self-contained'

Configured features:

JPEG RSVG IMAGEMAGICK NOTIFY ACL GNUTLS LIBXML2 ZLIB TOOLKIT_SCROLL_BARS

NS

Important settings:

value of $LC_CTYPE: en_US.UTF-8

value of $LANG: en_US.UTF-8

locale-coding-system: utf-8-unix

Major mode: Lisp Interaction

Minor modes in effect:

tooltip-mode: t

global-eldoc-mode: t

electric-indent-mode: t

mouse-wheel-mode: t

tool-bar-mode: t

menu-bar-mode: t

file-name-shadow-mode: t

global-font-lock-mode: t

font-lock-mode: t

blink-cursor-mode: t

auto-composition-mode: t

auto-encryption-mode: t

auto-compression-mode: t

line-number-mode: t

transient-mark-mode: t

Recent messages:

Making completion list...

You can run the command ‘server-start’ with M-x ser-s RET

When done with a buffer, type C-x #

Mark set

Auto-saving...

wtf

Before wtf Fri Mar 11 21:58:32 2016

After redisplay Fri Mar 11 21:58:32 2016

read-event nil

After wtf Fri Mar 11 21:58:38 2016

Load-path shadows:

None found.

Features:

(shadow sort mail-extr emacsbug message dired format-spec rfc822 mml

mml-sec epg epg-config gnus-util mm-decode mm-bodies mm-encode

mail-parse rfc2231 mailabbrev gmm-utils mailheader sendmail rfc2047

rfc2045 ietf-drums mm-util help-fns help-mode easymenu cl-loaddefs pcase

cl-lib mail-prsvr mail-utils term/xterm xterm server time-date mule-util

tooltip eldoc electric uniquify ediff-hook vc-hooks lisp-float-type

mwheel ns-win ucs-normalize term/common-win tool-bar dnd fontset image

regexp-opt fringe tabulated-list newcomment elisp-mode lisp-mode

prog-mode register page menu-bar rfn-eshadow timer select scroll-bar

mouse jit-lock font-lock syntax facemenu font-core frame cl-generic cham

georgian utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao

korean japanese eucjp-ms cp51932 hebrew greek romanian slovak czech

european ethiopic indian cyrillic chinese charscript case-table epa-hook

jka-cmpr-hook help simple abbrev minibuffer cl-preloaded nadvice

loaddefs button faces cus-face macroexp files text-properties overlay

sha1 md5 base64 format env code-pages mule custom widget

hashtable-print-readable backquote kqueue cocoa ns multi-tty

make-network-process emacs)

Memory information:

((conses 16 202233 6734)

(symbols 48 19770 0)

(miscs 40 57 215)

(strings 32 15988 5464)

(string-bytes 1 458233)

(vectors 16 33517)

(vector-slots 8 645323 6669)

(floats 8 170 338)

(intervals 56 234 0)

(buffers 976 14))

Aaron