Subject: Re: bug#32932: 27.0.50; render bugs on macOS Mojave

From: Alan Third <[email-masked]>
Date: Sat, 1 Feb 2020 14:22:42 +0000

On Fri, Jan 31, 2020 at 05:26:21PM -0800, Aaron Jensen wrote:
> On Fri, Jan 31, 2020 at 12:26 PM Aaron Jensen <[email-masked]> wrote:
> >
> > On Fri, Jan 31, 2020 at 12:23 PM Alan Third <[email-masked]> wrote:
> > >
> > > I’m thinking of time spent in functions during, perhaps the scroll
> > > benchark, or just general use. I know it can be done through xcode and
> > > I think gperftools perhaps works on macOS.
> > >
> > > Alternatively I may be able to do it. Is it just a matter of grabbing
> > > the spacemacs config and using it, or do I need to do anything
> > > further?
> >
> > I don't actually use spacemacs anymore, I have my own config, but I
> > believe the slowness is reproducible in `emacs -Q` on my 4k monitor. I
> > don't have that machine here, but I can verify it when I get home. If
> > it is specific to my config, I can share it with you.
> 
> Hi Alan,
> 
> I just confirmed that it happens with emacs -Q. It's directly
> proportional to the size of the window. The default window size is
> pretty fast, but even a nearly blank buffer that's full screen lags
> when the point moves.

Thanks. I finally got my xcode install working again and tried just
profiling various actions and I think I know what’s going on.

NSBitmapImageRep is mutable, however it’s built on a CGImage or
something that isn’t, so every time you want to edit an
NSBitmapImageRep it has to copy the entire thing. This is why this
little bit of code to grab the bitmap’s graphics context

    [NSGraphicsContext
      graphicsContextWithBitmapImageRep:drawingBuffer]

is so damn slow and it gets slower as the screensize increases.

I’m now stumped because I can’t actually find any image type in the
documentation that isn’t immutable. I’m sure there must be something.
The Mac port appears to be using IOSurfaces, but as far as I can tell
they can be changed underneath you so aren’t much use for just
updating little bits of the Emacs frame at a time. I must be
misunderstanding something.

-- 
Alan Third