From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: YAMAMOTO Mitsuharu Newsgroups: gmane.emacs.devel Subject: Re: Emacs Mac port Date: Sat, 16 Feb 2013 15:46:00 +0900 Organization: Faculty of Science, Chiba University Message-ID: References: <0425CBCD-2419-45D1-83E6-BEB2E194FBBD@gmail.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset=US-ASCII X-Trace: ger.gmane.org 1360997175 3269 80.91.229.3 (16 Feb 2013 06:46:15 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 16 Feb 2013 06:46:15 +0000 (UTC) Cc: "emacs-devel@gnu.org developers" To: Pavlo Martynenko Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sat Feb 16 07:46:35 2013 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1U6bXe-00044C-FB for ged-emacs-devel@m.gmane.org; Sat, 16 Feb 2013 07:46:34 +0100 Original-Received: from localhost ([::1]:40841 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U6bXK-0006rc-I8 for ged-emacs-devel@m.gmane.org; Sat, 16 Feb 2013 01:46:14 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:46452) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U6bXH-0006rT-04 for emacs-devel@gnu.org; Sat, 16 Feb 2013 01:46:12 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1U6bXE-000094-Df for emacs-devel@gnu.org; Sat, 16 Feb 2013 01:46:10 -0500 Original-Received: from mathmail.math.s.chiba-u.ac.jp ([133.82.132.2]:61563) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U6bXD-00007v-Sc for emacs-devel@gnu.org; Sat, 16 Feb 2013 01:46:08 -0500 Original-Received: from church.math.s.chiba-u.ac.jp (church [133.82.132.36]) by mathmail.math.s.chiba-u.ac.jp (Postfix) with ESMTP id F352EC055D; Sat, 16 Feb 2013 15:46:00 +0900 (JST) In-Reply-To: <0425CBCD-2419-45D1-83E6-BEB2E194FBBD@gmail.com> User-Agent: Wanderlust/2.14.0 (Africa) SEMI/1.14.6 (Maruoka) FLIM/1.14.8 (=?ISO-8859-4?Q?Shij=F2?=) APEL/10.6 Emacs/22.3 (sparc-sun-solaris2.8) MULE/5.0 (SAKAKI) X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 133.82.132.2 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:157072 Archived-At: >>>>> On Thu, 14 Feb 2013 14:02:08 +0200, Pavlo Martynenko said: > "emacsclient -c" works fine when server was started from normally > running emacs by (server-start). > But when the server was started with --daemon option. The first time > when emacsclient connects emacs eats 100% of cpu in main thread. And > after client disconnects and connects again the server crashes on > EXC_BAD_ACCESS in check_x_display_info. > "emacsclient -t" terminates just after connect with exit code 1. The Mac port is supposed to provide TTY-only sessions if invoked with the --deamon option. I'll look into this problem later so as to avoid the crash at least. > Also I noticed increased cpu usage from 0.3 up to 4.0% when emacs > frame minimised in the Dock. The same can not be said about the NS > port. This is a serious problem and specific to the Mac port. Please try the following patch and send a report to me (not to the list) if you find some problem with this patch. YAMAMOTO Mitsuharu mituharu@math.s.chiba-u.ac.jp === modified file 'src/mac.c' *** src/mac.c 2013-01-11 07:33:09 +0000 --- src/mac.c 2013-02-16 03:41:22 +0000 *************** *** 3117,3122 **** --- 3117,3131 ---- return event; } + static bool + mac_has_non_cgs_events_p (void) + { + ItemCount count = GetNumEventsInQueue (GetCurrentEventQueue ()); + + return (count > 1 + || (count == 1 && GetEventClass (mac_peek_next_event ()) != 'cgs ')); + } + #if !SELECT_USE_GCD static struct { *************** *** 3272,3283 **** mac_run_loop_run_once again so as to avoid wasting CPU time caused by vacuous reactivation of delayed visible toolbar item validation via window update events issued ! in the application event loop. */ do { timeoutval = mac_run_loop_run_once (timeoutval); } ! while (timeoutval && !mac_peek_next_event () && !detect_input_pending ()); if (timeoutval == 0) timedout_p = 1; --- 3281,3297 ---- mac_run_loop_run_once again so as to avoid wasting CPU time caused by vacuous reactivation of delayed visible toolbar item validation via window update events issued ! in the application event loop. ! ! Also, on Mac OS X 10.5 or later, the application receives ! an event 'cgs '/15 if there is a miniaturized window. We ! don't want to break the loop in this case for a similar ! reason. */ do { timeoutval = mac_run_loop_run_once (timeoutval); } ! while (timeoutval && !mac_has_non_cgs_events_p () && !detect_input_pending ()); if (timeoutval == 0) timedout_p = 1; *************** *** 3394,3400 **** timeoutval = mac_run_loop_run_once (timeoutval); } while (timeoutval && !wokeup_from_run_loop_run_once_p ! && !mac_peek_next_event () && !detect_input_pending ()); if (timeoutval == 0) timedout_p = 1; --- 3408,3414 ---- timeoutval = mac_run_loop_run_once (timeoutval); } while (timeoutval && !wokeup_from_run_loop_run_once_p ! && !mac_has_non_cgs_events_p () && !detect_input_pending ()); if (timeoutval == 0) timedout_p = 1; *************** *** 3416,3422 **** timeoutval = mac_run_loop_run_once (timeoutval); } while (timeoutval && !wokeup_from_run_loop_run_once_p ! && !mac_peek_next_event () && !detect_input_pending ()); if (timeoutval == 0) timedout_p = 1; --- 3430,3436 ---- timeoutval = mac_run_loop_run_once (timeoutval); } while (timeoutval && !wokeup_from_run_loop_run_once_p ! && !mac_has_non_cgs_events_p () && !detect_input_pending ()); if (timeoutval == 0) timedout_p = 1;