From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Kai Ma Newsgroups: gmane.emacs.bugs Subject: bug#63187: 30.0.50; Tail of longer lines painted after end of nearby lines on macOS Date: Sat, 24 Jun 2023 12:17:56 +0800 Message-ID: <335C856F-41F7-48B8-AF42-B2406065C7A9@gmail.com> References: <50104E0C-A861-4762-8081-55F2CF2390AD@gmail.com> <76A3A6C3-CD32-4731-927C-349471F21801@gmail.com> <2A505E20-55E2-4788-A21C-B94068299E50@gmail.com> <29949E40-D5D5-4DE1-BD81-93D1BA3D4F51@gmail.com> Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3731.600.7\)) Content-Type: multipart/alternative; boundary="Apple-Mail=_6EE3F259-F8E6-4B5A-B0C4-E9CF0A04B7C5" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="10823"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Po Lu , Alan Third , Eli Zaretskii , 63187@debbugs.gnu.org To: Aaron Jensen Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Jun 24 06:19:26 2023 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 1qCukA-0002X3-5n for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 24 Jun 2023 06:19:26 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qCujp-0000RN-OK; Sat, 24 Jun 2023 00:19:05 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qCujo-0000RD-1F for bug-gnu-emacs@gnu.org; Sat, 24 Jun 2023 00:19:04 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qCujm-00010b-9Y for bug-gnu-emacs@gnu.org; Sat, 24 Jun 2023 00:19:03 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qCujl-0006MA-Ou for bug-gnu-emacs@gnu.org; Sat, 24 Jun 2023 00:19:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Kai Ma Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 24 Jun 2023 04:19:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 63187 X-GNU-PR-Package: emacs Original-Received: via spool by 63187-submit@debbugs.gnu.org id=B63187.168758030424391 (code B ref 63187); Sat, 24 Jun 2023 04:19:01 +0000 Original-Received: (at 63187) by debbugs.gnu.org; 24 Jun 2023 04:18:24 +0000 Original-Received: from localhost ([127.0.0.1]:39801 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qCuj9-0006LJ-Hg for submit@debbugs.gnu.org; Sat, 24 Jun 2023 00:18:24 -0400 Original-Received: from mail-pf1-f194.google.com ([209.85.210.194]:49207) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qCuj5-0006L1-Ih for 63187@debbugs.gnu.org; Sat, 24 Jun 2023 00:18:21 -0400 Original-Received: by mail-pf1-f194.google.com with SMTP id d2e1a72fcca58-66615629689so1008981b3a.2 for <63187@debbugs.gnu.org>; Fri, 23 Jun 2023 21:18:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1687580293; x=1690172293; h=references:to:cc:in-reply-to:date:subject:mime-version:message-id :from:from:to:cc:subject:date:message-id:reply-to; bh=79COcNVHEQzjdodIVeEPT2QPBt7VHVgizgCoCFABDwg=; b=hYrgRURgaTDvEH+NYlmL+AjI7CVxOGc6t2v2qHHsQq8W8HpUYTz8qHHmm4MUnTYFKR wX17rMelVL8WPk7aw9paGawFj/A7OTv3ObTit5A6pjR+OhGmLalfZm1LQ/W3/gdxeHbd jjvxchgFIna2bS3k93Fzpn2GOTSFpk6lLv1OeERcjk653QCapli42skEhuwlcntQpUYC xF1zevKqgrggkwH+geBHp+trDIe98D7CIP131DiY/bbik+Wc8b7YzP8qmeJMwHsxif7Y Y2YWLEiBRgHplKI+WLD9c0pWZGMdxVm/HvdryWYWDLkDmEDhudbCa1JJKwzSwrlnWHlT Ov3g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687580293; x=1690172293; h=references:to:cc:in-reply-to:date:subject:mime-version:message-id :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=79COcNVHEQzjdodIVeEPT2QPBt7VHVgizgCoCFABDwg=; b=Lj1MTnWaBbTlKOO44oTVbgCBD+CpApjNfgVEilNAYh29geNC+zCMd1h7rHvaajIIPn haI6JL6RU3ILZfxB6+QaUjiHb4CaoT9jTe2Qd7++3797b/a88T0bjH15TalSpBilbKU7 qAzG8uwHLS/4b8cySdqtF2IjK47/jsI8Fw43JqfMntWbpHFwUcx+IiNXizZuZ9JUN+wq cY86drX6jWQOeKVdKMgogHo2cPkvhS6BOoeReG+qL8Ifo/FFKfd1ya4S05Zca5y7hySm SLtaHGdRWH4gnUrYLQ7WO37IfUIDfCOwU+Z02Kdo/RoEasd9NF5oP/gZ2FtslEPM1sRp P2vQ== X-Gm-Message-State: AC+VfDwOYItGBBRXGlv5ta/rt9Fho28XT3nxUEfnqSIpLZYq3ZTdRz86 HqxUYJttLiEzLp/+8i2Wn/M= X-Google-Smtp-Source: ACHHUZ4Ttk4tGSjrZ9TYMpiNUHIpzCpJjyKuKUl1rjARTrZEmG9yxe39lf5JPel7eisRNFKQ9t122Q== X-Received: by 2002:a05:6a00:847:b0:66a:614c:5701 with SMTP id q7-20020a056a00084700b0066a614c5701mr7385764pfk.22.1687580293379; Fri, 23 Jun 2023 21:18:13 -0700 (PDT) Original-Received: from smtpclient.apple (42-2-66-168.static.netvigator.com. [42.2.66.168]) by smtp.gmail.com with ESMTPSA id b26-20020aa7811a000000b00666b3706be6sm270251pfi.107.2023.06.23.21.18.11 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 23 Jun 2023 21:18:12 -0700 (PDT) In-Reply-To: X-Mailer: Apple Mail (2.3731.600.7) 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-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:263974 Archived-At: --Apple-Mail=_6EE3F259-F8E6-4B5A-B0C4-E9CF0A04B7C5 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 > On Jun 19, 2023, at 23:46, Aaron Jensen wrote: >=20 > Kai, could you try this patch out. It's a total guess, but let me know > if it does any better for you. Thanks. I have been running this for several days. It does not fix the = problem completely, but it=E2=80=99s possible to set polling-period to a = very small value now. >=20 > diff --git a/src/nsterm.h b/src/nsterm.h > index b6e5a813a6d..4f6c6f7c28b 100644 > --- a/src/nsterm.h > +++ b/src/nsterm.h > @@ -1384,3 +1384,11 @@ #define NSButtonTypeMomentaryPushIn > NSMomentaryPushInButton > extern void mark_nsterm (void); >=20 > #endif /* HAVE_NS */ > + > +#define AJTRACE(...) \ > + do = \ > + { = \ > + fprintf (stderr, __VA_ARGS__); = \ > + putc ('\n', stderr); \ > + } = \ > + while(0) > diff --git a/src/nsterm.m b/src/nsterm.m > index 3e089cc1ff1..5a92f4cda0b 100644 > --- a/src/nsterm.m > +++ b/src/nsterm.m > @@ -2708,9 +2708,9 @@ Hide the window (X11 semantics) > EmacsView *view =3D FRAME_NS_VIEW (f); >=20 > [view copyRect:srcRect to:dest]; > -#ifdef NS_IMPL_COCOA > - [view setNeedsDisplayInRect:destRect]; > -#endif > +// #ifdef NS_IMPL_COCOA > +// [view setNeedsDisplayInRect:destRect]; > +// #endif > } >=20 > unblock_input (); > @@ -10636,9 +10636,9 @@ - (void) display >=20 > /* Schedule a run of getContext so that if Emacs is idle it will > perform the buffer copy, etc. */ > - [self performSelectorOnMainThread:@selector (getContext) > - withObject:nil > - waitUntilDone:NO]; > + // [self performSelectorOnMainThread:@selector (getContext) > + // withObject:nil > + // waitUntilDone:NO]; > } > } >=20 > @@ -10651,6 +10651,7 @@ - (void) copyContentsTo: (IOSurfaceRef) = destination > IOReturn lockStatus; > IOSurfaceRef source =3D (IOSurfaceRef)[self contents]; > void *sourceData, *destinationData; > + int seed1 =3D 0, seed2 =3D 1; > int numBytes =3D IOSurfaceGetAllocSize (destination); >=20 > NSTRACE_WHEN (NSTRACE_GROUP_FOCUS, "[EmacsLayer copyContentsTo:]"); > @@ -10662,14 +10663,31 @@ - (void) copyContentsTo: (IOSurfaceRef) = destination > if (lockStatus !=3D kIOReturnSuccess) > NSLog (@"Failed to lock source surface: %x", lockStatus); >=20 > + lockStatus =3D IOSurfaceLock (destination, kIOSurfaceLockAvoidSync, = nil); > + if (lockStatus !=3D kIOReturnSuccess) > + NSLog (@"Failed to lock destination surface: %x", lockStatus); > + > sourceData =3D IOSurfaceGetBaseAddress (source); > destinationData =3D IOSurfaceGetBaseAddress (destination); >=20 > - /* Since every IOSurface should have the exact same settings, a > - memcpy seems like the fastest way to copy the data from one to > - the other. */ > - memcpy (destinationData, sourceData, numBytes); > + while (seed1 !=3D seed2) > + { > + seed1 =3D IOSurfaceGetSeed (source); > + > + /* Since every IOSurface should have the exact same settings, a > + memcpy seems like the fastest way to copy the data from one = to > + the other. */ > + memcpy (destinationData, sourceData, numBytes); >=20 > + seed2 =3D IOSurfaceGetSeed (source); > + if (seed1 !=3D seed2) { > + AJTRACE ("SEED DO NOT MATCH"); I haven't seen this message so far. So probably it is removing = performSelectorOnMainThread that is effective. > + } > + } > + > + lockStatus =3D IOSurfaceUnlock (destination, = kIOSurfaceLockAvoidSync, nil); > + if (lockStatus !=3D kIOReturnSuccess) > + NSLog (@"Failed to unlock destination surface: %x", lockStatus); > lockStatus =3D IOSurfaceUnlock (source, kIOSurfaceLockReadOnly, = nil); > if (lockStatus !=3D kIOReturnSuccess) > NSLog (@"Failed to unlock source surface: %x", lockStatus); --Apple-Mail=_6EE3F259-F8E6-4B5A-B0C4-E9CF0A04B7C5 Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=utf-8

On Jun = 19, 2023, at 23:46, Aaron Jensen <aaronjensen@gmail.com> = wrote:

Kai, could you try this = patch out. It's a total guess, but let me know
if it does any better = for you.

Thanks. I have been = running this for several days.  It does not fix the problem = completely, but it=E2=80=99s possible to set polling-period to a very = small value now.


diff --git = a/src/nsterm.h b/src/nsterm.h
index = b6e5a813a6d..4f6c6f7c28b 100644
--- = a/src/nsterm.h
+++ = b/src/nsterm.h
@@ = -1384,3 +1384,11 @@ #define NSButtonTypeMomentaryPushIn
NSMomentaryPushInButton
extern = void mark_nsterm (void);

#endif = /* HAVE_NS */
+
+#define AJTRACE(...) =             &n= bsp;           &nbs= p;            =     \
+ =  do =             &n= bsp;           &nbs= p;            =             &n= bsp;           &nbs= p;       \
+ =    { =             &n= bsp;           &nbs= p;            =             &n= bsp;           &nbs= p;      \
+ =        fprintf (stderr, __VA_ARGS__); =             &n= bsp;           &nbs= p;          \
+ =        putc ('\n', stderr); =     \
+ =    } =             &n= bsp;           &nbs= p;            =             &n= bsp;           &nbs= p;      \
+ =  while(0)
diff = --git a/src/nsterm.m b/src/nsterm.m
index = 3e089cc1ff1..5a92f4cda0b 100644
--- = a/src/nsterm.m
+++ = b/src/nsterm.m
@@ = -2708,9 +2708,9 @@ Hide the window (X11 semantics)
    EmacsView *view =3D FRAME_NS_VIEW = (f);

    [view copyRect:srcRect = to:dest];
-#ifdef = NS_IMPL_COCOA
- =    [view setNeedsDisplayInRect:destRect];
-#endif
+// #ifdef = NS_IMPL_COCOA
+// =     [view setNeedsDisplayInRect:destRect];
+// = #endif
  }

  unblock_input ();
@@ = -10636,9 +10636,9 @@ - (void) display

      /* Schedule a run of = getContext so that if Emacs is idle it will
         perform= the buffer copy, etc.  */
- =      [self = performSelectorOnMainThread:@selector (getContext)
- =             &n= bsp;           &nbs= p;   withObject:nil
- =             &n= bsp;           &nbs= p;waitUntilDone:NO];
+ =      // [self = performSelectorOnMainThread:@selector (getContext)
+ =      // =             &n= bsp;          withObject= :nil
+ =      // =             &n= bsp;       waitUntilDone:NO];
    }
}

@@ = -10651,6 +10651,7 @@ - (void) copyContentsTo: (IOSurfaceRef) = destination
  IOReturn = lockStatus;
  IOSurfaceRef = source =3D (IOSurfaceRef)[self contents];
  void *sourceData, *destinationData;
+  int seed1 =3D 0, = seed2 =3D 1;
  int numBytes = =3D IOSurfaceGetAllocSize (destination);

  NSTRACE_WHEN (NSTRACE_GROUP_FOCUS, "[EmacsLayer = copyContentsTo:]");
@@ = -10662,14 +10663,31 @@ - (void) copyContentsTo: (IOSurfaceRef) = destination
  if = (lockStatus !=3D kIOReturnSuccess)
    NSLog (@"Failed to lock source = surface: %x", lockStatus);

+ =  lockStatus =3D IOSurfaceLock (destination, = kIOSurfaceLockAvoidSync, nil);
+ =  if (lockStatus !=3D kIOReturnSuccess)
+ =    NSLog (@"Failed to lock destination surface: %x", = lockStatus);
+
  sourceData =3D= IOSurfaceGetBaseAddress (source);
  destinationData =3D IOSurfaceGetBaseAddress = (destination);

- =  /* Since every IOSurface should have the exact same settings, = a
- =     memcpy seems like the fastest way to copy the = data from one to
- =     the other.  */
-  memcpy = (destinationData, sourceData, numBytes);
+ =  while (seed1 !=3D seed2)
+ =    {
+ =      seed1 =3D IOSurfaceGetSeed = (source);
+
+ =      /* Since every IOSurface should have the = exact same settings, a
+ =        memcpy seems like the fastest = way to copy the data from one to
+ =        the other.  */
+ =      memcpy (destinationData, sourceData, = numBytes);

+ =      seed2 =3D IOSurfaceGetSeed = (source);
+ =      if (seed1 !=3D seed2) {
+ =        AJTRACE ("SEED DO NOT = MATCH");

I haven't seen this = message so far. So probably it is removing performSelectorOnMainThread that = is effective.

+ =      }
+ =    }
+
+ =  lockStatus =3D IOSurfaceUnlock (destination, = kIOSurfaceLockAvoidSync, nil);
+ =  if (lockStatus !=3D kIOReturnSuccess)
+ =    NSLog (@"Failed to unlock destination surface: %x", = lockStatus);
  lockStatus =3D= IOSurfaceUnlock (source, kIOSurfaceLockReadOnly, nil);
  if = (lockStatus !=3D kIOReturnSuccess)
    NSLog (@"Failed to unlock source = surface: %x", = lockStatus);

= --Apple-Mail=_6EE3F259-F8E6-4B5A-B0C4-E9CF0A04B7C5--