From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.ciao.gmane.io!not-for-mail From: Marc Herbert Newsgroups: gmane.emacs.bugs Subject: bug#24472: - a workaround/fix for the menubar crashes on macOS Date: Fri, 1 May 2020 01:47:19 -0700 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="ciao.gmane.io:159.69.161.202"; logging-data="124691"; mail-complaints-to="usenet@ciao.gmane.io" To: 24472@debbugs.gnu.org, Eli Zaretskii , michael.albinus@gmx.de Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Fri May 01 17:42:33 2020 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jUXo8-000WJ8-CJ for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 01 May 2020 17:42:32 +0200 Original-Received: from localhost ([::1]:60548 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jUXo7-0006uW-7e for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 01 May 2020 11:42:31 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:56362) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jUXng-0006tU-0C for bug-gnu-emacs@gnu.org; Fri, 01 May 2020 11:42:05 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.90_1) (envelope-from ) id 1jUXnf-00086k-8C for bug-gnu-emacs@gnu.org; Fri, 01 May 2020 11:42:03 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:38908) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jUXne-000858-RC for bug-gnu-emacs@gnu.org; Fri, 01 May 2020 11:42:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1jUXne-0002xx-OS for bug-gnu-emacs@gnu.org; Fri, 01 May 2020 11:42:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Marc Herbert Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 01 May 2020 15:42:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 24472 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: confirmed Original-Received: via spool by 24472-submit@debbugs.gnu.org id=B24472.158834771711374 (code B ref 24472); Fri, 01 May 2020 15:42:02 +0000 Original-Received: (at 24472) by debbugs.gnu.org; 1 May 2020 15:41:57 +0000 Original-Received: from localhost ([127.0.0.1]:50452 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jUXnY-0002xN-LB for submit@debbugs.gnu.org; Fri, 01 May 2020 11:41:56 -0400 Original-Received: from mail-pl1-f182.google.com ([209.85.214.182]:34682) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jURKq-0006DA-AN for 24472@debbugs.gnu.org; Fri, 01 May 2020 04:47:52 -0400 Original-Received: by mail-pl1-f182.google.com with SMTP id s10so3465667plr.1 for <24472@debbugs.gnu.org>; Fri, 01 May 2020 01:47:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :content-transfer-encoding; bh=ZDV4lvJH6OCdGr3fYezpyM/F5I/4ERO1FuRF4Jbwvd0=; b=F4GzRi01f1Xk0g44oTN/kEih+WL1zeWjBZs63Kus2PHUBYpmPMU8X4Qz8XNjqs/QrL Yzu4FiTcg6gUKOen1ahymTQjxpLmM6dB1RxFgjg48bfJkdrBnwQyzFuYFH1WfrTYEqqx +7ruitPcRjxxWPVZd1+bZ4ElN5RpbH8DLYXCabpqI+zi8dUf8r3ojVDL9ZxJpd/yE2Yy iA8c6ErO6pOzxgagacEnlvNFdpX7UszdfTUgRZDCjGcXP0zMGwv/EyeQ5uSPPhaPvHVr Is9lgEswgF/miA28pUwqbpO0KRFJhLQ9MUUC/FssKuYQFG+deVwvEKSF41I+RnHUfr+Z QFMQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:content-transfer-encoding; bh=ZDV4lvJH6OCdGr3fYezpyM/F5I/4ERO1FuRF4Jbwvd0=; b=TMiomSPT8mNOplgBNu6pt/JUPz95af2t0yK9SyIvBgnL1ItZQAZT6MZxWW+NSNVN1H nkJTwOgdkGoq/pZY0kP6momm6zuHWqlwKsunA4qxppxNm22EZvXnds+CpYxBDEYPKsud PQwXhZ8XDDhHNCqtxpu5sbWF8p2oydTGCKi5hqfRwqpsDdixr+MlXsCEZNUn/C7/DurO DpgMQ/eafxyXZfAPrponCctLExd0MKutxkY3rSxKvsGRJebqBchfKDyW1Uizw82khNuh y5eSOIw0shEujk6lFshBLCgDbsYwAlMrMGigAxcT3k8sXeRoX2WFnotFT++S/4z+307N pB5Q== X-Gm-Message-State: AGi0PuYrUEOOXOJywRxCzKiL8jnP6vD6cM9sIz6fQ2aR7mE/wLs7+I2H fZqIiKwJ2jcK6PNMVngumN5zq+IjApEMARdoNEtNjEH1KzIZoA== X-Google-Smtp-Source: APiQypLwi3Zg4z3TxXAJ0U7JhuFc76aWPqOb7tWYzB6nLLUCXy1uxGfM9PV0DVUSa81T27w6KPDH3IBSg0Av+ROVleI= X-Received: by 2002:a17:90a:3ea7:: with SMTP id k36mr3307943pjc.125.1588322865841; Fri, 01 May 2020 01:47:45 -0700 (PDT) In-Reply-To: X-Mailman-Approved-At: Fri, 01 May 2020 11:41:55 -0400 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-Received-From: 209.51.188.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-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:179437 Archived-At: > This delay and sometimes missing menus happen only when the current > buffer of the current frame is a tramp buffer. Switch the top frame to > a local file and everything is fine again. So I fired up Wireshark and > as expected I saw some ssh traffic when opening the 26.1 menus with a > tramp buffer. > > Now this is where I find things get really interesting: > > On my system, > - with 26.1, the "Apple" and "Emacs" menus don't cause any network > traffic or lag. All other menus do. > - with 26.2 and above, the "Apple" and "Emacs" menus don't cause any > crash. All other menus do. > > Coincidence? Mmmm.... Not. I leveraged the milder symptoms in 26.1 to debug the issue and found a workaround/fix. I then upgraded to 26.3 and ta-da: the crashes are gone! The root cause is in menu-bar.el which defines the revert-buffer item like = this: '(menu-item "Revert Buffer" revert-buffer :enable (or (blah) (blah) (and buffer-file-number (or (buffer-modified-p) (not (verify-visited-file-modtime (current-buffer)))))) This greys out the "Revert Buffer" menu item when (among others) no one modified the file outside Emacs. verify-visited-file-modtime calls tramp-sh-handle-verify-visited-file-modtime that temporarily hardcodes remote-file-name-inhibit-cache to 't that causes the network accesses that cause the delays and/or crashes. After a few other attempts, my final workaround is dead simple: remove the "Revert Buffer" item from the menu by adding this one line to your .emacs file: (define-key global-map [menu-bar file revert-buffer] nil) Enjoy. I think it's better than a "workaround" actually, it's almost a "feature" that I'm going to keep that in my .emacs file permanently because trying to use the network every time you click the menubar is just... silly? I also tried to hack menu-bar.el directly but any change I made to it was completely ignored. Anyone knows why? > [Bonus question: Apple cares about latency. Does macOS allow > networking while merely trying to open a menu?] Somewhat related: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D32864 26.1; "menus don't work correctly in Mac OS Mojave" > Elisp code doesn=E2=80=99t guarantee it will return, it can longjmp when = you > hit C-g, for example. This means you can end up with the application > attempting to run the event loop while it is still INSIDE the previous > event loop, and the toolkit really doesn=E2=80=99t like that. It will, in > fact, kill Emacs on the spot. Must also be why the debugger can't be used for this issue. This didn't make my first Emacs bug any easier :-)