From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.ciao.gmane.io!not-for-mail From: Alan Third Newsgroups: gmane.emacs.bugs Subject: bug#32932: 27.0.50; render bugs on macOS Mojave Date: Mon, 3 Feb 2020 21:28:17 +0000 Message-ID: <20200203212817.GB59034@breton.holly.idiocy.org> References: <2F867D49-6B1C-4CB5-A298-2A0E1BF45462@acm.org> <20200202134628.GB53430@breton.holly.idiocy.org> <20200202223052.GA53567@breton.holly.idiocy.org> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="ciao.gmane.io:159.69.161.202"; logging-data="43813"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Mattias =?UTF-8?Q?Engdeg=C3=A5rd?= , Robert Pluim , 32932@debbugs.gnu.org To: Aaron Jensen Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon Feb 03 22:29:13 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 1iyjHN-000BFy-EP for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 03 Feb 2020 22:29:13 +0100 Original-Received: from localhost ([::1]:47276 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iyjHM-0002DD-Dm for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 03 Feb 2020 16:29:12 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:57903) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iyjHF-0002D1-4X for bug-gnu-emacs@gnu.org; Mon, 03 Feb 2020 16:29:06 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iyjHD-0005mb-Sx for bug-gnu-emacs@gnu.org; Mon, 03 Feb 2020 16:29:05 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:36301) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iyjHD-0005k2-JC for bug-gnu-emacs@gnu.org; Mon, 03 Feb 2020 16:29:03 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1iyjHC-0001vT-Eh for bug-gnu-emacs@gnu.org; Mon, 03 Feb 2020 16:29: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: Mon, 03 Feb 2020 21:29:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 32932 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: fixed Original-Received: via spool by 32932-submit@debbugs.gnu.org id=B32932.15807653087361 (code B ref 32932); Mon, 03 Feb 2020 21:29:02 +0000 Original-Received: (at 32932) by debbugs.gnu.org; 3 Feb 2020 21:28:28 +0000 Original-Received: from localhost ([127.0.0.1]:42274 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1iyjGd-0001uf-Q2 for submit@debbugs.gnu.org; Mon, 03 Feb 2020 16:28:28 -0500 Original-Received: from mail-wm1-f54.google.com ([209.85.128.54]:39658) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1iyjGb-0001uS-Gr for 32932@debbugs.gnu.org; Mon, 03 Feb 2020 16:28:26 -0500 Original-Received: by mail-wm1-f54.google.com with SMTP id c84so1029670wme.4 for <32932@debbugs.gnu.org>; Mon, 03 Feb 2020 13:28:25 -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; bh=clz+qm1wp9VXoY+O0tpKGSmo70kK3FNeiOuNHkqD5DQ=; b=eNHP50M+kLkj+Xnj5Ut+8V9h4/7iSDsWByAaXaKwFo/WWo8aQCoPeUz64fJGzFskbB 0WHRimk5cGMwMoiqzUVl3EJS9hvTSoO8mA6vRnQKKDcFNi8vlbIsXDcUjdyr1RyiIH+Z pEuFKisbSOLrJyXej9RogSVn6Aeudb5MnlXlUyQ2n84M+5csb4n+mDZN72hhC31QidZn 0OjOfdTekPcAvtcs4XO0FvsJVTv+oIxZiiR4lPrc/YEKC7p9+i6q7nO9t6UiWccTDAWk 7Cye4pGHIv6YIJsi2ZIF4CSo1OZWltKGbojKuSX6WDJLkrREhGGwMhM0+uWyDKarWrjE GCCQ== 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; bh=clz+qm1wp9VXoY+O0tpKGSmo70kK3FNeiOuNHkqD5DQ=; b=NU0+rJD/GTgbm/TSa3ASK2ChQ22k9L1+9Now74hPA1fdp2468jDCfbdiXNL5w/tbcE ZlOHcfSlMno4m92xUaoW1SRdfS4dZCl2klOHTUM1b6qT2GpMlTbFJHX2dfZ76+AgIXtz l49iOG5upNFw9QIUuliW1ZOHaEuKxSH/pVC20B1iFklVD1uXf2oM6E1N2/5vKUunivet F/UqSxQHTjFGgam/XryXwKEDSqpRc1iWY/nS1Eru1RXl+7FqSvC9s6NqDRG2NA/8+Syn OrIhariTinOW+YlUNCGgphw0ozqW/CxGfYPcrhF3eLvzTM6bFRgrdlWzcVNLy1i5LC0l iN2A== X-Gm-Message-State: APjAAAV5NwVvqcQkqB4uDznpB4T1bLlmuXQ5SwbDeWhEYRwRzz3wNGM7 YkU6CN8buT6FIfUc7ht1Y2I= X-Google-Smtp-Source: APXvYqz60BNc0r8nMNQ3w2IlvksBNf2r/1jC3sBZ70V9GGv4yKPILLQdIhlTNoVyxX6/s3BGCWXKyQ== X-Received: by 2002:a7b:c088:: with SMTP id r8mr1028631wmh.18.1580765299647; Mon, 03 Feb 2020 13:28:19 -0800 (PST) Original-Received: from breton.holly.idiocy.org (ip6-2001-08b0-03f8-8129-a08b-b269-65be-dd6a.holly.idiocy.org. [2001:8b0:3f8:8129:a08b:b269:65be:dd6a]) by smtp.gmail.com with ESMTPSA id a1sm26881368wrr.80.2020.02.03.13.28.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Feb 2020 13:28:18 -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: 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:175651 Archived-At: On Sun, Feb 02, 2020 at 04:14:51PM -0800, Aaron Jensen wrote: > On Sun, Feb 2, 2020 at 2:30 PM Alan Third wrote: > > > > I know exactly what’s causing the glitching, but I’ll come back to > > this tomorrow. > > Looking forward to hearing more. How Cocoa is supposed to work: When a part of the view must be updated you mark it as dirty. You can also mark the entire view. At some point in the NS run loop the graphics context for the window is set up and drawing is clipped to the areas that were marked as dirty. Starting with the first opaque view drawRect is called on each view that intersects the dirty rectangles. drawRect redraws the contents of those rectangles. The dirty rectangles are reset and the process begins again. The application may not draw to the view outwith drawRect, the only exception being scrollRect, which appears to require being called outwith drawRect. Emacs 27: Redisplay thinks it’s drawing to the view as it runs, however on NS it just marks areas as dirty and calling scrollRect. Once redisplay is completed the run loop starts the process that calls drawRect. In the normal case the first opaque view is the NSWindow, which is blank. It’s just set to the background colour. This immediately clears anything that was in the dirty rectangles. Sometimes the NSWindow may be transparent as well in which case the first opaque view will be the root window. The end result is the same, the dirty rectangles are now ‘clear’. EmacsView’s drawRect is called. This calls expose_frame which draws the contents of the dirty rectangles for real this time. All is well. But not always. Sometimes when expose_frame is called the frame has been marked as garbaged, so expose_frame refuses to do any drawing. Since the dirty rectangles have already been cleared by the NSWindow we now have blank spaces displayed to the user. Even worse the dirty rectangles are now reset and Emacs has no idea that those areas are blank so it makes no further attempts to redraw them. (IIRC just forcing a display at the end of redisplay, before anything else has had a chance to garbage the frame, doesn’t work.) Scrolling is a problem too. scrollRect (which is deprecated and will be removed) copies the contents of the screen. Sometimes the parts of the screen it copies contain the cursor. Normally Emacs clears the cursor before copying parts of the screen, however Cocoa doesn’t let us draw to the screen outwith drawRect, so we can’t clear the cursor before calling scrollRect. The work‐around in use here is to copy the dirty rectangles with the part of the screen we’re copying. There’s a reasonable chance that we end up redrawing most of the area that was copied in an attempt to clear the cursor(s). Conclusion: Drawing to a bitmap is just much easier than trying to fix these issues, although they probably are fixable. We need a replacement for scrollRect. My hope is that we can save up the copy commands and replay them within drawRect, that way we can remove the cursor before copying. If we make the EmacsView opaque the dirty rectangles aren’t cleared, however we need to be much more careful about drawing to the whole view as blank areas aren’t magically cleared for us. And we can never have a transparent background, which I don’t see as much of a loss, but some might. IMO the best solution would be if expose_frame was able to always redraw the last matrix created by redisplay, however this isn’t possible, and I’ve never managed to understand enough of redisplay to know why. If expose_frame does nothing we could save the dirty rectangles and re‐mark them sometime after. Probably at the end of the next redisplay. I think there were some other problems that I’ve forgotten, but those were the main issues. I hope this helps explain the issues. -- Alan Third