From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Alan Third Newsgroups: gmane.emacs.bugs Subject: bug#25345: 26.0.50; crash on mac, just rebuilt from git tip Date: Tue, 3 Jan 2017 17:54:49 +0000 Message-ID: <20170103175449.GB49916@breton.holly.idiocy.org> References: NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="uAKRQypu60I7Lcqm" Content-Transfer-Encoding: 8bit X-Trace: blaine.gmane.org 1483466123 7082 195.159.176.226 (3 Jan 2017 17:55:23 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Tue, 3 Jan 2017 17:55:23 +0000 (UTC) User-Agent: Mutt/1.7.1 (2016-10-04) Cc: 25345@debbugs.gnu.org To: Sam Steingold Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Tue Jan 03 18:55:17 2017 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cOTIk-00009N-0X for geb-bug-gnu-emacs@m.gmane.org; Tue, 03 Jan 2017 18:55:10 +0100 Original-Received: from localhost ([::1]:35270 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cOTIm-0003zd-F7 for geb-bug-gnu-emacs@m.gmane.org; Tue, 03 Jan 2017 12:55:12 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:41080) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cOTIf-0003y9-TI for bug-gnu-emacs@gnu.org; Tue, 03 Jan 2017 12:55:07 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cOTIc-0001jP-O9 for bug-gnu-emacs@gnu.org; Tue, 03 Jan 2017 12:55:06 -0500 Original-Received: from debbugs.gnu.org ([208.118.235.43]:53379) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cOTIc-0001jH-LD for bug-gnu-emacs@gnu.org; Tue, 03 Jan 2017 12:55:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1cOTIc-0005df-5M for bug-gnu-emacs@gnu.org; Tue, 03 Jan 2017 12:55:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Alan Third Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 03 Jan 2017 17:55:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 25345 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 25345-submit@debbugs.gnu.org id=B25345.148346610121671 (code B ref 25345); Tue, 03 Jan 2017 17:55:02 +0000 Original-Received: (at 25345) by debbugs.gnu.org; 3 Jan 2017 17:55:01 +0000 Original-Received: from localhost ([127.0.0.1]:40545 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cOTIb-0005dN-8r for submit@debbugs.gnu.org; Tue, 03 Jan 2017 12:55:01 -0500 Original-Received: from mail-wm0-f47.google.com ([74.125.82.47]:38202) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cOTIZ-0005d6-8R for 25345@debbugs.gnu.org; Tue, 03 Jan 2017 12:54:59 -0500 Original-Received: by mail-wm0-f47.google.com with SMTP id k184so240464697wme.1 for <25345@debbugs.gnu.org>; Tue, 03 Jan 2017 09:54:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20161025; h=sender:date:from:to:cc:subject:message-id:references:mime-version :content-disposition:content-transfer-encoding:in-reply-to :user-agent; bh=A+UOKHKlNoSyptX2OcuHSP0AFWHYn3yVtikzK7dsbCs=; b=MnRckeE9gmKxTZELNwKLrAVDXGdy5eGCQ/XqOlju7nYacwUdIIrTHRTvTMJ2tDSa7J 3FDRHeEbIwh2dPLEOp4PIzRjBq6tPKAJg6xcbWPq28rOLQOAuls+TyRq6akjd0LurCUq N/ca7b8b4++47LWGnupSSCnE+dQIC3+ff6kGlAOoyTsAN9JohAkouT9+sZ2/5YHsCWV4 Mes3JM8/YhfG9Xm2sCWeVu+gjAI+RyCaCnTlj4CTgoxelMVSfVYbDan0FkncVoHVXUBP W+B1hp22lBe9sPVYBjNxVY5G137GowGQWQgeDVUEGj0NuKY1np/JuwEHWN8y6/PAqiIA oR2g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:from:to:cc:subject:message-id :references:mime-version:content-disposition :content-transfer-encoding:in-reply-to:user-agent; bh=A+UOKHKlNoSyptX2OcuHSP0AFWHYn3yVtikzK7dsbCs=; b=We7mkGHyhzz6Zeu3zgFjp3fnlEaiizZNnNcrY4lrcP0y8mNHuDNhVOqtqRS0F/KxpN ZPI3bcTZpv6rd/ws8v1dWDGFFtw07Ck0UMJH1TrCrX42T8FDPq+nxVADdE6ZTh3IXBqB ztLQS+uFrGqCsCb6qNKdystu8ZYWnETEQX9PNhApv1YdQWEaS+wW33dUgsaDLmfQy22K Wliq8whiVb8qdUg/NPvMpweS25sSYBNmKfel3G+gkmkS4zX56DBOAoMDm16T141lUuHL ly2+F5peXjadLmiJIaYIUDxu58tZCsu7kIQ/RgqmN/m3FCs6l8aFps33HhDPOsJj88wa T0Rw== X-Gm-Message-State: AIkVDXLLC4rQYHaFPYswEbNFTwn7zlvsMOGlPW5/gUPBDnSVDH6RWhDCp+Hd5y0O2sv/7w== X-Received: by 10.28.141.18 with SMTP id p18mr52999755wmd.31.1483466091931; Tue, 03 Jan 2017 09:54:51 -0800 (PST) Original-Received: from breton.holly.idiocy.org (ip6-2001-08b0-03f8-8129-8471-fd78-dc83-6a18.holly.idiocy.org. [2001:8b0:3f8:8129:8471:fd78:dc83:6a18]) by smtp.gmail.com with ESMTPSA id jz1sm68742192wjc.38.2017.01.03.09.54.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 03 Jan 2017 09:54:51 -0800 (PST) Content-Disposition: inline In-Reply-To: X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:127707 Archived-At: --uAKRQypu60I7Lcqm Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit On Tue, Jan 03, 2017 at 12:29:54PM -0500, Sam Steingold wrote: > In GNU Emacs 26.0.50.3 (x86_64-apple-darwin16.3.0, NS appkit-1504.76 Version 10.12.2 (Build 16C67)) > of 2017-01-03 built on clr-sds > Repository revision: 134e86b360cab0d0a5cb634b71a4b06ec26c5f1f > Windowing system distributor 'Apple', version 10.3.1504 > > rebuilt from git tip. > now emacs is very slow: it takes up to a second for the character to > appear on the screen as I type. Sorry about this, we’re trying to rework the NS port so it can handle the new concurrency code. Can you please try applying the attached patch, and let us know whether it improves things? Thanks! -- Alan Third --uAKRQypu60I7Lcqm Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="0001-Improve-NS-event-handling-bug-25265.patch" >From 9663d300d231242fc77f93a35219d56ba9c90601 Mon Sep 17 00:00:00 2001 From: Alan Third Date: Tue, 3 Jan 2017 14:16:37 +0000 Subject: [PATCH] Improve NS event handling (bug#25265) * src/nsterm.h: Remove reference to timeout_handler. * src/nsterm.m (ns_select): Monitor fd changes using NSFileHandler. --- src/nsterm.h | 1 - src/nsterm.m | 62 +++++++++++++++++++++++++++++++++++++++++++----------------- 2 files changed, 45 insertions(+), 18 deletions(-) diff --git a/src/nsterm.h b/src/nsterm.h index dc222a7..8b5b691 100644 --- a/src/nsterm.h +++ b/src/nsterm.h @@ -392,7 +392,6 @@ char const * nstrace_fullscreen_type_name (int); - (void)sendEvent: (NSEvent *)theEvent; - (void)showPreferencesWindow: (id)sender; - (BOOL) openFile: (NSString *)fileName; -- (void)timeout_handler: (NSTimer *)timedEntry; - (BOOL)fulfillService: (NSString *)name withArg: (NSString *)arg; #ifdef NS_IMPL_GNUSTEP - (void)sendFromMainThread:(id)unused; diff --git a/src/nsterm.m b/src/nsterm.m index 98fd8ab..51cccd0 100644 --- a/src/nsterm.m +++ b/src/nsterm.m @@ -4098,28 +4098,55 @@ overwriting cursor (usually when cursor on a tab) */ return pselect(nfds, readfds, writefds, exceptfds, timeout, sigmask); - result = pselect(nfds, readfds, writefds, exceptfds, - &(struct timespec){.tv_sec = 0, .tv_nsec = 100}, - sigmask); - [outerpool release]; outerpool = [[NSAutoreleasePool alloc] init]; + /* Set up one NSFileHandle for each fd we want to monitor. */ + for (int i = 0 ; i < nfds ; i++) + { + if ((readfds != NULL && FD_ISSET(i, readfds)) + || (writefds != NULL && FD_ISSET(i, writefds)) + || (exceptfds != NULL &&FD_ISSET(i, exceptfds))) + { + NSFileHandle *fh = [[NSFileHandle alloc] initWithFileDescriptor: i + closeOnDealloc: NO]; + /* Send a notification to EmacsApp:fileHandleDataAvailable, + which will raise an appDefined event. */ + /* NOTE: I don't think this will pick up writes and + exceptions, so ns_select may not always behave correctly. + I've yet to see a problem, though. */ + [fh waitForDataInBackgroundAndNotify]; + [fh autorelease]; + } + } + if (timeout) { double time = timespectod (*timeout); - timeout_date = [NSDate dateWithTimeIntervalSinceNow:time]; + timeout_date = [NSDate dateWithTimeIntervalSinceNow: time]; } /* Listen for a new NSEvent. */ - ns_event = [NSApp nextEventMatchingMask:NSEventMaskAny - untilDate:timeout_date - inMode:NSDefaultRunLoopMode - dequeue:NO]; + ns_event = [NSApp nextEventMatchingMask: NSEventMaskAny + untilDate: timeout_date + inMode: NSDefaultRunLoopMode + dequeue: NO]; if (ns_event != nil) { - raise (SIGIO); + if ([ns_event type] == NSEventTypeApplicationDefined + && [ns_event data1] == -3) + { + result = pselect(nfds, readfds, writefds, exceptfds, + &(struct timespec){.tv_sec = 0, .tv_nsec = 0}, + sigmask); + } + else + { + raise (SIGIO); + errno = EINTR; + return -1; + } } return result; @@ -5132,6 +5159,12 @@ - (void)applicationDidFinishLaunching: (NSNotification *)notification object:nil]; #endif + [[NSNotificationCenter defaultCenter] + addObserver: self + selector: @selector (fileHandleDataAvailable:) + name: NSFileHandleDataAvailableNotification + object: nil]; + ns_send_appdefined (-2); } @@ -5315,14 +5348,9 @@ - (void)applicationDidResignActive: (NSNotification *)notification ========================================================================== */ - -- (void)timeout_handler: (NSTimer *)timedEntry -/* -------------------------------------------------------------------------- - The timeout specified to ns_select has passed. - -------------------------------------------------------------------------- */ +- (void)fileHandleDataAvailable: (NSNotification *)notification { - /*NSTRACE ("timeout_handler"); */ - ns_send_appdefined (-2); + ns_send_appdefined (-3); } - (void)sendFromMainThread:(id)unused -- 2.10.2 --uAKRQypu60I7Lcqm--