From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Alan Third Newsgroups: gmane.emacs.bugs Subject: bug#46155: 28.0.50; Regression: buffer contents flicker on macOS frames when Date: Sun, 31 Jan 2021 20:28:21 +0000 Message-ID: References: Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="Kn7Rco2INcPSMTe4" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="12814"; mail-complaints-to="usenet@ciao.gmane.io" To: Aaron Jensen , 46155@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun Jan 31 21:29:15 2021 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 1l6JLP-0003EM-9m for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 31 Jan 2021 21:29:15 +0100 Original-Received: from localhost ([::1]:53042 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l6JLO-0003wV-Bs for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 31 Jan 2021 15:29:14 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:38960) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l6JLC-0003vp-8O for bug-gnu-emacs@gnu.org; Sun, 31 Jan 2021 15:29:02 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:46606) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1l6JLB-0000Hm-Rc for bug-gnu-emacs@gnu.org; Sun, 31 Jan 2021 15:29:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1l6JLB-0005Nq-OK for bug-gnu-emacs@gnu.org; Sun, 31 Jan 2021 15:29:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Alan Third Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 31 Jan 2021 20:29:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 46155 X-GNU-PR-Package: emacs Original-Received: via spool by 46155-submit@debbugs.gnu.org id=B46155.161212491420646 (code B ref 46155); Sun, 31 Jan 2021 20:29:01 +0000 Original-Received: (at 46155) by debbugs.gnu.org; 31 Jan 2021 20:28:34 +0000 Original-Received: from localhost ([127.0.0.1]:58149 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1l6JKk-0005Mw-7g for submit@debbugs.gnu.org; Sun, 31 Jan 2021 15:28:34 -0500 Original-Received: from outbound.soverin.net ([116.202.65.218]:53061) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1l6JKh-0005Mh-AG for 46155@debbugs.gnu.org; Sun, 31 Jan 2021 15:28:32 -0500 Original-Received: from smtp.soverin.net (unknown [10.10.3.24]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by outbound.soverin.net (Postfix) with ESMTPS id DCA7D600C9 for <46155@debbugs.gnu.org>; Sun, 31 Jan 2021 20:28:24 +0000 (UTC) Original-Received: from smtp.soverin.net (smtp.soverin.net [159.69.232.138]) by soverin.net DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=idiocy.org; s=soverin; t=1612124904; bh=Ip9ofJr1x+pRlczWfevbCB0SBzWwq0S/Tu8QUT3Um1g=; h=Date:From:To:Subject:References:In-Reply-To:From; b=UkdLxjzCIHdfMAwJ82a/5ukcvlru9ZNae4ArZ6sVH2OKA+SypN5GH4fqF8ok2rvqU RNuHv6qQ3cNDLY/TH7iar0L1v5b2b+W/kh7vcTXS4n3SpvO10Bv+dp72ofSqVY6Vm5 x9PoX0MwPJExy0NX4qtVX4PZc3423Y7p0QOYPnVBaDel/4tug5ETRREEu0pxM3bZQ9 921gkd5rEUNlXc96vt4qU+CHxV7StKgs3tetesvxnrY/Fmx1xYbYUUpOjJjVVdvSJ4 oIpCVBO2Sy1dRthzBk9sHjwXBT5PSvFA89hduAjfqbSemdw+FCvg6/9i2bCAZFKdzl F5gd/NMdv5yIQ== Original-Received: by breton.holly.idiocy.org (Postfix, from userid 501) id 1C26D202A158DB; Sun, 31 Jan 2021 20:28:21 +0000 (GMT) Mail-Followup-To: Alan Third , Aaron Jensen , 46155@debbugs.gnu.org Content-Disposition: inline In-Reply-To: X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list 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:199036 Archived-At: --Kn7Rco2INcPSMTe4 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Thu, Jan 28, 2021 at 04:39:49PM +0000, Alan Third wrote: > On Thu, Jan 28, 2021 at 09:48:25AM -0600, Aaron Jensen wrote: > > From emacs -Q: > > > > (dotimes (n 10) > > (set-frame-parameter nil 'width (+ 80 n)) > > (sit-for 0.1)) > > > > This was previously fixed in bug#30699 > > > > I don't know if it was reverted at some point and I didn't notice, or it > > was started flickering again after Alan's recent (fantastic) performance > > improvements. > > > > This reproduces on master (non-native-comp) as of ac102bb966 as well. > > Apple deprecated the functions we were using to block screen drawing. > > It's possible we can have a neater work-around now since we're drawing > to an offscreen buffer and therefore have greater control over what's > displayed. I'll have to look into it again. Well... I tried something ridiculous and it appears to work... I suspect forcing redisplay this way within the NS run loop is bad form, but it appears to work. -- Alan Third --Kn7Rco2INcPSMTe4 Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="0001-Fix-flicker-when-resizing-NS-frame-programmatically-.patch" >From ed901d4219b996a72e5944c6b959086ef2b8431d Mon Sep 17 00:00:00 2001 From: Alan Third Date: Sun, 31 Jan 2021 20:19:53 +0000 Subject: [PATCH] Fix flicker when resizing NS frame programmatically (bug#46155) ; Incidentally fixes bug#21326. * src/nsterm.m ([EmacsView viewWillDraw]): New function. --- src/nsterm.m | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/src/nsterm.m b/src/nsterm.m index 1b2328628e..8f2b61a165 100644 --- a/src/nsterm.m +++ b/src/nsterm.m @@ -8452,6 +8452,33 @@ - (void)copyRect:(NSRect)srcRect to:(NSRect)dstRect } +#ifdef NS_IMPL_COCOA +/* If the frame has been garbaged but the toolkit wants to draw, for + example when resizing the frame, we end up with a blank screen. + Sometimes this results in an unpleasant flicker, so try to + redisplay before drawing. */ +- (void)viewWillDraw +{ + if (FRAME_GARBAGED_P (emacsframe)) + { + /* If there is IO going on when redisplay is run here Emacs + crashes. I think it's because this code will always be run + within the run loop and for whatever reason processing input + is dangerous. This technique was stolen wholesale from + nsmenu.m and seems to work. */ + bool owfi = waiting_for_input; + waiting_for_input = 0; + block_input (); + + redisplay(); + + unblock_input (); + waiting_for_input = owfi; + } +} +#endif + + #ifdef NS_DRAW_TO_BUFFER - (BOOL)wantsUpdateLayer { -- 2.29.2 --Kn7Rco2INcPSMTe4--