unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#42834: 28.0.50; macOS scroll and movement latency slows when display changes
@ 2020-08-12 18:48 Doug Davis
  2020-08-12 21:24 ` Alan Third
  0 siblings, 1 reply; 6+ messages in thread
From: Doug Davis @ 2020-08-12 18:48 UTC (permalink / raw)
  To: 42834

I'm observing this behavior on a MacBook Pro running macOS 10.15

initial condition: laptop is closed and plugged into an external display
over thunderbolt; I start and use Emacs with expected performance. After
unplugging the external display and opening the laptop to use by itself,
Emacs (which was already running) cursor movement and scrolling latency
shoots up (Emacs is just very "sluggish"). If I restart Emacs everything
goes back to normal. I'm observing the same behavior with 'emacs -Q'. I
don't see the same behavior from Emacs 27.1.

In GNU Emacs 28.0.50 (build 1, x86_64-apple-darwin19.6.0, NS appkit-1894.60 Version 10.15.6 (Build 19G73))
 of 2020-08-12 built on top.local
Repository revision: a5a0a9c9ca0f0485db2c324a30109f655522800d
Repository branch: master
Windowing system distributor 'Apple', version 10.3.1894
System Description:  Mac OS X 10.15.6

Recent messages:
‘epa-file’ already enabled
Waiting for git... [2 times]
[yas] Prepared just-in-time loading of snippets successfully.
Loading /Users/ddavis/.emacs.d/dot-emacs/email.el (source)...done
For information about GNU Emacs and the GNU system, type C-h C-a.

Configured using:
 'configure --with-ns --with-json --with-gnutls --with-xwidgets
 'CFLAGS=-mtune=native -march=native -O3''

Configured features:
JPEG TIFF GIF PNG NOTIFY KQUEUE ACL GNUTLS LIBXML2 ZLIB
TOOLKIT_SCROLL_BARS NS MODULES THREADS XWIDGETS JSON PDUMPER LCMS2

Important settings:
  value of $LANG: en_US.UTF-8
  locale-coding-system: utf-8-unix

Major mode: Lisp Interaction

Minor modes in effect:
  company-mode: t
  rainbow-delimiters-mode: t
  gcmh-mode: t
  which-key-mode: t
  yas-global-mode: t
  yas-minor-mode: t
  projectile-mode: t
  helm-mode: t
  helm-ff-cache-mode: t
  helm--remap-mouse-mode: t
  async-bytecomp-package-mode: t
  shell-dirtrack-mode: t
  show-paren-mode: t
  global-auto-revert-mode: t
  whitespace-mode: t
  override-global-mode: t
  global-display-line-numbers-mode: t
  display-line-numbers-mode: t
  global-eldoc-mode: t
  eldoc-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  prettify-symbols-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  column-number-mode: t
  line-number-mode: t
  transient-mark-mode: t

Load-path shadows:
None found.

Features:
(shadow sort flyspell ispell mail-extr emacsbug message rfc822 mml
mml-sec gnus-util rmail rmail-loaddefs text-property-search mm-decode
mm-bodies mm-encode mail-parse rfc2231 mailabbrev gmm-utils mailheader
sendmail rfc2047 rfc2045 ietf-drums mm-util mail-prsvr mail-utils winner
helm-command helm-elisp helm-eval edebug backtrace helm-info
company-oddmuse company-keywords company-etags etags fileloop generator
company-gtags company-dabbrev-code company-dabbrev company-files
company-clang company-cmake company-semantic company-template
company-bbdb company-capf company rainbow-delimiters w3m mailcap
doc-view jka-compr image-mode exif timezone w3m-hist w3m-fb bookmark-w3m
w3m-ems w3m-favicon w3m-image tab-line w3m-proc w3m-util gcmh
doom-gruvbox-theme doom-themes doom-themes-base which-key blacken pyvenv
eshell esh-cmd esh-ext esh-opt esh-proc esh-io esh-arg esh-module
esh-groups esh-util clang-format xml lsp-pyls lsp-mode lsp-protocol
yasnippet-snippets yasnippet xref url-util tree-widget wid-edit spinner
pcase network-stream puny nsm rmc markdown-mode color inline imenu ht f
ewoc bindat flycheck rx rg rg-info-hack rg-menu transient rg-ibuffer
rg-result wgrep-rg wgrep rg-history rg-header helm-projectile projectile
grep compile ibuf-ext ibuffer ibuffer-loaddefs helm-mode helm-files
helm-buffers helm-occur helm-tags helm-locate helm-grep helm-regexp
helm-utils helm-help helm-types helm-config helm async-bytecomp
helm-global-bindings helm-easymenu helm-source eieio-compat
helm-multi-match helm-lib async pretty-hydra s dash-functional hydra lv
visual-fill-column crux tramp tramp-loaddefs trampver tramp-integration
files-x tramp-compat shell parse-time iso8601 ls-lisp thingatpt
exec-path-from-shell auto-package-update finder-inf dash paren dired
dired-loaddefs vc vc-dispatcher epa-file epa derived epg epg-config
autorevert filenotify whitespace project edmacro kmacro org ob ob-tangle
ob-ref ob-lob ob-table ob-exp org-macro org-footnote org-src ob-comint
org-pcomplete pcomplete comint ansi-color ring org-list org-faces
org-entities time-date noutline outline org-version ob-emacs-lisp
ob-core ob-eval org-table ol org-keys org-compat advice org-macs
org-loaddefs format-spec find-func cal-menu calendar cal-loaddefs server
cl-extra help-mode use-package use-package-ensure use-package-delight
use-package-diminish use-package-bind-key bind-key easy-mmode
use-package-core display-line-numbers tex-site w3m-load info package
easymenu browse-url url-handlers url-parse auth-source cl-seq eieio
eieio-core cl-macs eieio-loaddefs password-cache json subr-x map
url-vars seq byte-opt gv bytecomp byte-compile cconv cl-loaddefs cl-lib
tooltip eldoc electric uniquify ediff-hook vc-hooks lisp-float-type
mwheel term/ns-win ns-win ucs-normalize mule-util term/common-win
tool-bar dnd fontset image regexp-opt fringe tabulated-list replace
newcomment text-mode elisp-mode lisp-mode prog-mode register page
tab-bar menu-bar rfn-eshadow isearch timer select scroll-bar mouse
jit-lock font-lock syntax facemenu font-core term/tty-colors frame
minibuffer cl-generic cham georgian utf-8-lang misc-lang vietnamese
tibetan thai tai-viet lao korean japanese eucjp-ms cp51932 hebrew greek
romanian slovak czech european ethiopic indian cyrillic chinese
composite charscript charprop case-table epa-hook jka-cmpr-hook help
simple abbrev obarray cl-preloaded nadvice loaddefs button faces
cus-face macroexp files text-properties overlay sha1 md5 base64 format
env code-pages mule custom widget hashtable-print-readable backquote
threads xwidget-internal kqueue cocoa ns lcms2 multi-tty
make-network-process emacs)

Memory information:
((conses 16 504153 435087)
 (symbols 48 40200 489)
 (strings 32 159414 63817)
 (string-bytes 1 4857806)
 (vectors 16 62970)
 (vector-slots 8 736507 420998)
 (floats 8 462 1264)
 (intervals 56 448 254)
 (buffers 992 12))





^ permalink raw reply	[flat|nested] 6+ messages in thread

* bug#42834: 28.0.50; macOS scroll and movement latency slows when display changes
  2020-08-12 18:48 bug#42834: 28.0.50; macOS scroll and movement latency slows when display changes Doug Davis
@ 2020-08-12 21:24 ` Alan Third
  2020-08-12 21:48   ` Doug Davis
  0 siblings, 1 reply; 6+ messages in thread
From: Alan Third @ 2020-08-12 21:24 UTC (permalink / raw)
  To: Doug Davis; +Cc: 42834

On Wed, Aug 12, 2020 at 02:48:08PM -0400, Doug Davis wrote:
> I'm observing this behavior on a MacBook Pro running macOS 10.15
> 
> initial condition: laptop is closed and plugged into an external display
> over thunderbolt; I start and use Emacs with expected performance. After
> unplugging the external display and opening the laptop to use by itself,
> Emacs (which was already running) cursor movement and scrolling latency
> shoots up (Emacs is just very "sluggish"). If I restart Emacs everything
> goes back to normal. I'm observing the same behavior with 'emacs -Q'. I
> don't see the same behavior from Emacs 27.1.

Hi, Thanks for your report, I haven't seen this myself.

Do you see the same thing going the other way? (laptop screen -> monitor)

Is your monitor a retina screen?

NS xwidgets were just added today, did you see this before? (or have
you just tried Emacs 28 for the first time today?)

Thanks!
-- 
Alan Third





^ permalink raw reply	[flat|nested] 6+ messages in thread

* bug#42834: 28.0.50; macOS scroll and movement latency slows when display changes
  2020-08-12 21:24 ` Alan Third
@ 2020-08-12 21:48   ` Doug Davis
  2020-08-13 15:00     ` Alan Third
  0 siblings, 1 reply; 6+ messages in thread
From: Doug Davis @ 2020-08-12 21:48 UTC (permalink / raw)
  To: Alan Third; +Cc: 42834

Hi Alan,

Alan Third writes:

> On Wed, Aug 12, 2020 at 02:48:08PM -0400, Doug Davis wrote:
>> I'm observing this behavior on a MacBook Pro running macOS 10.15
>>
>> initial condition: laptop is closed and plugged into an external display
>> over thunderbolt; I start and use Emacs with expected performance. After
>> unplugging the external display and opening the laptop to use by itself,
>> Emacs (which was already running) cursor movement and scrolling latency
>> shoots up (Emacs is just very "sluggish"). If I restart Emacs everything
>> goes back to normal. I'm observing the same behavior with 'emacs -Q'. I
>> don't see the same behavior from Emacs 27.1.
>
> Hi, Thanks for your report, I haven't seen this myself.
>
> Do you see the same thing going the other way? (laptop screen -> monitor)

Ah yes, forgot to mention that- seeing it both ways.

> Is your monitor a retina screen?

Yeah the MacBook is retina and the external display is 4k.

> NS xwidgets were just added today, did you see this before? (or have
> you just tried Emacs 28 for the first time today?)

After seeing the new xwidgets patches that went in today I recompiled
the master branch to experiment a bit, but I first hit this issue a
couple of months ago when I first experimented with Emacs 28- I should
have reported the bug earlier, sorry about that (xwidgets actually
brought me back to playing with 28 after staying with 27 recently).

Cheers,
Doug





^ permalink raw reply	[flat|nested] 6+ messages in thread

* bug#42834: 28.0.50; macOS scroll and movement latency slows when display changes
  2020-08-12 21:48   ` Doug Davis
@ 2020-08-13 15:00     ` Alan Third
  2020-08-13 15:42       ` Doug Davis
  0 siblings, 1 reply; 6+ messages in thread
From: Alan Third @ 2020-08-13 15:00 UTC (permalink / raw)
  To: Doug Davis; +Cc: 42834

On Wed, Aug 12, 2020 at 05:48:47PM -0400, Doug Davis wrote:
> > Do you see the same thing going the other way? (laptop screen -> monitor)
> 
> Ah yes, forgot to mention that- seeing it both ways.

Excellent!

> > Is your monitor a retina screen?
> 
> Yeah the MacBook is retina and the external display is 4k.

I think I know what's going on. If you don't use the exact same
settings for the drawing buffer as for the screen then some very slow
conversion processes kick in every time you flush the buffer to the
screen.

Odds are that the monitor and laptop screen have something slightly
different, probably a colorspace or something, so when switching from
one to the other the drawing buffer retains the settings for the old
screen.

Can you try the following change in nsterm.m?

@@ -8431,18 +8431,10 @@ - (void)windowDidChangeBackingProperties:(NSNotification *)notification
   if (! [self wantsUpdateLayer])
     return;
 
-  CGFloat old = [[[notification userInfo]
-                    objectForKey:@"NSBackingPropertyOldScaleFactorKey"]
-                  doubleValue];
-  CGFloat new = [[self window] backingScaleFactor];
-
-  if (old != new)
-    {
-      NSRect frame = [self frame];
-      [self createDrawingBuffer];
-      ns_clear_frame (emacsframe);
-      expose_frame (emacsframe, 0, 0, NSWidth (frame), NSHeight (frame));
-    }
+  NSRect frame = [self frame];
+  [self createDrawingBuffer];
+  ns_clear_frame (emacsframe);
+  expose_frame (emacsframe, 0, 0, NSWidth (frame), NSHeight (frame));
 }
 #endif /* NS_DRAW_TO_BUFFER */

-- 
Alan Third





^ permalink raw reply	[flat|nested] 6+ messages in thread

* bug#42834: 28.0.50; macOS scroll and movement latency slows when display changes
  2020-08-13 15:00     ` Alan Third
@ 2020-08-13 15:42       ` Doug Davis
  2020-08-13 18:12         ` Alan Third
  0 siblings, 1 reply; 6+ messages in thread
From: Doug Davis @ 2020-08-13 15:42 UTC (permalink / raw)
  To: Alan Third; +Cc: 42834

Alan Third writes:

> On Wed, Aug 12, 2020 at 05:48:47PM -0400, Doug Davis wrote:
>> > Do you see the same thing going the other way? (laptop screen -> monitor)
>>
>> Ah yes, forgot to mention that- seeing it both ways.
>
> Excellent!
>
>> > Is your monitor a retina screen?
>>
>> Yeah the MacBook is retina and the external display is 4k.
>
> I think I know what's going on. If you don't use the exact same
> settings for the drawing buffer as for the screen then some very slow
> conversion processes kick in every time you flush the buffer to the
> screen.
>
> Odds are that the monitor and laptop screen have something slightly
> different, probably a colorspace or something, so when switching from
> one to the other the drawing buffer retains the settings for the old
> screen.
>
> Can you try the following change in nsterm.m?
>
> @@ -8431,18 +8431,10 @@ - (void)windowDidChangeBackingProperties:(NSNotification *)notification
>    if (! [self wantsUpdateLayer])
>      return;
>
> -  CGFloat old = [[[notification userInfo]
> -                    objectForKey:@"NSBackingPropertyOldScaleFactorKey"]
> -                  doubleValue];
> -  CGFloat new = [[self window] backingScaleFactor];
> -
> -  if (old != new)
> -    {
> -      NSRect frame = [self frame];
> -      [self createDrawingBuffer];
> -      ns_clear_frame (emacsframe);
> -      expose_frame (emacsframe, 0, 0, NSWidth (frame), NSHeight (frame));
> -    }
> +  NSRect frame = [self frame];
> +  [self createDrawingBuffer];
> +  ns_clear_frame (emacsframe);
> +  expose_frame (emacsframe, 0, 0, NSWidth (frame), NSHeight (frame));
>  }
>  #endif /* NS_DRAW_TO_BUFFER */

That patch does indeed appear to be the solution-- tested the exact same
situation and now without the sluggishness issue.

Thanks!





^ permalink raw reply	[flat|nested] 6+ messages in thread

* bug#42834: 28.0.50; macOS scroll and movement latency slows when display changes
  2020-08-13 15:42       ` Doug Davis
@ 2020-08-13 18:12         ` Alan Third
  0 siblings, 0 replies; 6+ messages in thread
From: Alan Third @ 2020-08-13 18:12 UTC (permalink / raw)
  To: Doug Davis; +Cc: 42834-done

On Thu, Aug 13, 2020 at 11:42:21AM -0400, Doug Davis wrote:
> 
> That patch does indeed appear to be the solution-- tested the exact same
> situation and now without the sluggishness issue.

I've pushed it to master.

Thanks!
-- 
Alan Third





^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2020-08-13 18:12 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-12 18:48 bug#42834: 28.0.50; macOS scroll and movement latency slows when display changes Doug Davis
2020-08-12 21:24 ` Alan Third
2020-08-12 21:48   ` Doug Davis
2020-08-13 15:00     ` Alan Third
2020-08-13 15:42       ` Doug Davis
2020-08-13 18:12         ` Alan Third

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).