← Back to team overview

kicad-developers team mailing list archive

Re: Mac HighDPI performance

 

It turns out the fonts aren’t really the problem.

It starts with this gem in wxWidgets:

void wxWidgetCocoaImpl::ScrollRect( const wxRect *rect, int dx, int dy )
{
#if 1
    SetNeedsDisplay() ;
#else
    // We should do something like this, but it wasn't working in 10.4.
    if (GetNeedsDisplay() )
    {
        SetNeedsDisplay() ;
    }
    NSRect r = wxToNSRect( [m_osxView superview], *rect );
    NSSize offset = NSMakeSize((float)dx, (float)dy);
    [m_osxView scrollRect:r by:offset];
#endif
}

SetNeedsDisplay() with no rectangle argument invalidates the entire window.

Even if you fix that (to scroll most of the window and only invalidate the newly-exposed parts), you run into this:

void wxWidgetCocoaImpl::drawRect(void* rect, WXWidget slf, void *WXUNUSED(_cmd))
{
    // preparing the update region
    
    wxRegion updateRgn;

    // since adding many rects to a region is a costly process, by default use the bounding rect
#if 0
    const NSRect *rects;
    NSInteger count;
    [slf getRectsBeingDrawn:&rects count:&count];
    for ( int i = 0 ; i < count ; ++i )
    {
        updateRgn.Union(wxFromNSRect(slf, rects[i]));
    }
#else
    updateRgn.Union(wxFromNSRect(slf,*(NSRect*)rect));
#endif

…which will also cause the whole window to be repainted if there’s both an invalidated horizontal strip and a vertical one.

And the latter turns out to be pretty much guaranteed by this one, which batches repaints:

void wxNonOwnedWindow::Update()
{
    if ( clock() - s_lastFlush > CLOCKS_PER_SEC / 30 )
    {
        s_lastFlush = clock();
        m_nowpeer->Update();
    }
}

But even Kicad isn’t blameless.  Once you fix all those there’s still no checking in SCH_SCREEN::Draw() to see if the individual draw items intersect the update region.  (Sure, the actually drawing is clipped in the end, but you still go through a lot of code to get there.)

All of these are fixable, and we’ve already crossed the Rubicon of having our own OSX wxWidgets branch.  

But it’s still a reasonable amount of work, with a non-trivial risk profile.  Should I continue?

Cheers,
Jeff.



> On 4 Mar 2018, at 01:30, Bernhard Stegmaier <stegmaier@xxxxxxxxxxxxx> wrote:
> 
> No.
> 
>> On 4. Mar 2018, at 01:51, Andrey Kuznetsov <kandrey89@xxxxxxxxx <mailto:kandrey89@xxxxxxxxx>> wrote:
>> 
>> Would it be an easy fix to change the text/font such that it does not affect performance so significantly on MacOS?
>> 
>> On Sat, Mar 3, 2018 at 5:20 AM, Wayne Stambaugh <stambaughw@xxxxxxxxx <mailto:stambaughw@xxxxxxxxx>> wrote:
>> On 03/03/2018 07:33 AM, Jeff Young wrote:
>> Hi Andrey,
>> 
>> I did some profiling and I’d guess that the difference in eeschema and pcbnew-legacy performance is down to there being more text in the schema.  Since we use a stroke font, there’s a lot of stroke segments in each letter.
>> 
>> @Devs,
>> 
>> I understand why we use a stroke font on the PCB, but there’s not much reason in eeschema, is there?
>> 
>> This is possibly one of the things that I plan on changing after the new schematic file format is written.  The new file format will support font definitions so replacing the stroke font in Eeschema should be doable. Whether or not I have time to make this change remains to be seen.
>> 
>> Wayne
>> 
>> 
>> Cheers,
>> Jeff.
>> 
>> 
>> On 3 Mar 2018, at 08:18, Andrey Kuznetsov <kandrey89@xxxxxxxxx <mailto:kandrey89@xxxxxxxxx> <mailto:kandrey89@xxxxxxxxx <mailto:kandrey89@xxxxxxxxx>>> wrote:
>> 
>> The motherboard project is not very complex, I would say that performance should be tolerable UP to that size complexity, if we set the bar any lower, usability will suffer and people won't like KiCad because it's sluggish and interface lag is the worst kind of lag.
>> My project isn't finished and Chris' project is available now, is just the right complexity and has layout that can be used for testing as well as a schematic.
>> 
>> *LG 5K 27" display running 3200x1800 (the highest resolution without making text blurry, using this for work every day, so it's extravagant, it's practical)*
>> 
>> *Actions:* pan with middle mouse, zoom back and forth.
>> 
>> *eeschema:*
>> Low Res - at least 2 times slower than would be considered normal, I would have to guess ~400ms lag
>> Normal - 4-5x slower compared to low res mode ~1700ms lag
>> Even in low res mode, and removing 75% of the items from Chris' schematic, the lag is still ~200-300ms, that's just not right. Additionally, I filed https://bugs.launchpad.net/kicad/+bug/1753054 <https://bugs.launchpad.net/kicad/+bug/1753054> because the mouse zoom is screwed up in eeschema, coupled with the lag, it's unusable. Maybe the pan lag is related to the zoom, maybe there are multiple steps being rendered when it should just jump to where the mouse ended up at, I don't know.
>> 
>> *pcbnew - **Normal Resolution:*
>> Accelerated: No-AA, <50ms
>> Fallback: 500-1000ms for panning, 300-600ms for zoom
>> Legacy: 1300-1700ms for panning, 600ms for zoom
>> Low Res mode: did not notice speed increase, except maybe Fallback was ~400ms faster.
>> 
>> I'm not saying halt the horses, certain modes are obviously limited, ie Legacy and Fallback by the nature of the task presented, but eeschema is barely displaying 10% of the content pcbnew is but lagging so much worse!
>> 
>> Just thought I'd include rendering of the Accelerated Graphics (top to bottom: Supersampling 4x, Subpixel AA (Ultra Quality), No AA)
>> All 3 modes are responsive, probably <50-100ms lag, I'd consider this performance great, considering the amount of elements on screen.
>> <image.png>
>> 
>> How long should it take to delete this many selected elements in pcbnew?
>> Answer: about 50x too long! I think it was like 3mins, perhaps ESC key should be available to press anytime to undo the delete action and restore to pre-delete screen when accidental actions are triggered that take forever to complete?
>> <image.png>
>> 
>> On Fri, Mar 2, 2018 at 9:53 AM, Bernhard Stegmaier <stegmaier@xxxxxxxxxxxxx <mailto:stegmaier@xxxxxxxxxxxxx> <mailto:stegmaier@xxxxxxxxxxxxx <mailto:stegmaier@xxxxxxxxxxxxx>>> wrote:
>> 
>>     Hi,
>> 
>>     to be honest, I don’t really know what this is about.
>> 
>>     @Andrey:
>>     You looked for a very complex (foreign) project (Chris mainboard?)
>>     to prove that eeschema is slow on Mac?
>>     Well, we know that and we told you already some weeks/months ago
>>     why it is like it is (if memory serves me right).
>> 
>>     Or, do you have an own project that is so ridiculously slow, that
>>     you can’t work with it?
>>     If so, please provide it so that we can analyse why this specific
>>     project behaves like that.
>>     If you can’t or don’t want to provide it we could tell you how to
>>     do some performance measurements so that we might see something.
>> 
>>     Obviously, there are a number of Mac users here and also over at
>>     the KiCad forum who might also be happy to get some more
>>     performance here and there, but who are in general reasonably able
>>     to work on their projects (including myself, on a 2012 Retina
>>     MacBook with only an i5).
>> 
>> 
>>     Regards,
>>     Bernhard
>> 
>>     > On 2. Mar 2018, at 17:59, Andy Peters <devel@xxxxxxxxx <mailto:devel@xxxxxxxxx>
>>     <mailto:devel@xxxxxxxxx <mailto:devel@xxxxxxxxx>>> wrote:
>>     >
>>     >
>>     >
>>     >> On Mar 1, 2018, at 8:53 PM, Seth Hillbrand
>>     <seth.hillbrand@xxxxxxxxx <mailto:seth.hillbrand@xxxxxxxxx> <mailto:seth.hillbrand@xxxxxxxxx <mailto:seth.hillbrand@xxxxxxxxx>>> wrote:
>>     >>
>>     >> Andrey-
>>     >>
>>     >> I'm moving this to a new thread so that we don't conflate the
>>     OpenMP discussion with this.
>>     >>
>>     >> Can you test running Kicad with the "Open in Low Resolution"
>>     mode enabled?  You can activate this by choosing "Get Info" on the
>>     main KiCad application and checking the option that says "Open in
>>     Low Resolution".  You may need to do the same for the other
>>     applications (Eeschema, pcbnew, etc) as well.
>>     >
>>     > testing on my 2017” touch-bar MBP …
>>     >
>>     > Good g-d, low-res mode looks fuzzy and weird!
>>     >
>>     > I don’t notice any specific differences in EESchema performance.
>>     Maybe my schematic isn’t busy enough? I’m a fan of using more
>>     smaller sheets with less info on each than one big sheet with
>>     everything.
>>     >
>>     > I know, anecdote is not evidence.
>>     >
>>     > -a
>>     >
>>     >
>>     >>
>>     >> -Seth
>>     >>
>>     >> ​​2018-03-01 18:09 GMT-08:00 Andrey Kuznetsov
>>     <kandrey89@xxxxxxxxx <mailto:kandrey89@xxxxxxxxx> <mailto:kandrey89@xxxxxxxxx <mailto:kandrey89@xxxxxxxxx>>>:
>>     >> Hi,
>>     >>
>>     >> So for now I've had a chance to test the motherboard project on
>>     my Retina macbook display.
>>     >> eeschema: horrible zoom, feels like elastic band zoom and I
>>     have all scroll wheel accelerations and similar disabled, zoom
>>     response is super laggy, cannot work like this, will need to make
>>     schematics on windows.
>>     >> pcbnew by order of slowness:
>>     >> legacy - pretty slow, zoom lag is major, boo boo
>>     >> modern (fallback) - decent, but the lag can be felt, zoom lag
>>     is minor
>>     >> modern (accelerated) - almost cannot feel the lag, very nice,
>>     nice zoom responsiveness
>>     >>
>>     >> I'll report tomorrow on 5K LG display.
>>     >> ​
>>     >
>>     >
>>     > _______________________________________________
>>     > Mailing list: https://launchpad.net/~kicad-developers <https://launchpad.net/~kicad-developers>
>>     <https://launchpad.net/~kicad-developers <https://launchpad.net/~kicad-developers>>
>>     > Post to     : kicad-developers@xxxxxxxxxxxxxxxxxxx <mailto:kicad-developers@xxxxxxxxxxxxxxxxxxx>
>>     <mailto:kicad-developers@xxxxxxxxxxxxxxxxxxx <mailto:kicad-developers@xxxxxxxxxxxxxxxxxxx>>
>>     > Unsubscribe : https://launchpad.net/~kicad-developers <https://launchpad.net/~kicad-developers>
>>     <https://launchpad.net/~kicad-developers <https://launchpad.net/~kicad-developers>>
>>     > More help   : https://help.launchpad.net/ListHelp <https://help.launchpad.net/ListHelp>
>>     <https://help.launchpad.net/ListHelp <https://help.launchpad.net/ListHelp>>
>> 
>> 
>>     _______________________________________________
>>     Mailing list: https://launchpad.net/~kicad-developers <https://launchpad.net/~kicad-developers>
>>     <https://launchpad.net/~kicad-developers <https://launchpad.net/~kicad-developers>>
>>     Post to     : kicad-developers@xxxxxxxxxxxxxxxxxxx <mailto:kicad-developers@xxxxxxxxxxxxxxxxxxx>
>>     <mailto:kicad-developers@xxxxxxxxxxxxxxxxxxx <mailto:kicad-developers@xxxxxxxxxxxxxxxxxxx>>
>>     Unsubscribe : https://launchpad.net/~kicad-developers <https://launchpad.net/~kicad-developers>
>>     <https://launchpad.net/~kicad-developers <https://launchpad.net/~kicad-developers>>
>>     More help   : https://help.launchpad.net/ListHelp <https://help.launchpad.net/ListHelp>
>>     <https://help.launchpad.net/ListHelp <https://help.launchpad.net/ListHelp>>
>> 
>> 
>> 
>> 
>> -- 
>> Remember The Past, Live The Present, Change The Future
>> Those who look only to the past or the present are certain to miss the future [JFK]
>> 
>> kandrey89@xxxxxxxxx <mailto:kandrey89@xxxxxxxxx> <mailto:kandrey89@xxxxxxxxx <mailto:kandrey89@xxxxxxxxx>>
>> Live Long and Prosper,
>> Andrey
>> _______________________________________________
>> Mailing list: https://launchpad.net/~kicad-developers <https://launchpad.net/~kicad-developers>
>> Post to     : kicad-developers@xxxxxxxxxxxxxxxxxxx <mailto:kicad-developers@xxxxxxxxxxxxxxxxxxx> <mailto:kicad-developers@xxxxxxxxxxxxxxxxxxx <mailto:kicad-developers@xxxxxxxxxxxxxxxxxxx>>
>> Unsubscribe : https://launchpad.net/~kicad-developers <https://launchpad.net/~kicad-developers>
>> More help   : https://help.launchpad.net/ListHelp <https://help.launchpad.net/ListHelp>
>> 
>> 
>> 
>> _______________________________________________
>> Mailing list: https://launchpad.net/~kicad-developers <https://launchpad.net/~kicad-developers>
>> Post to     : kicad-developers@xxxxxxxxxxxxxxxxxxx <mailto:kicad-developers@xxxxxxxxxxxxxxxxxxx>
>> Unsubscribe : https://launchpad.net/~kicad-developers <https://launchpad.net/~kicad-developers>
>> More help   : https://help.launchpad.net/ListHelp <https://help.launchpad.net/ListHelp>
>> 
>> 
>> _______________________________________________
>> Mailing list: https://launchpad.net/~kicad-developers <https://launchpad.net/~kicad-developers>
>> Post to     : kicad-developers@xxxxxxxxxxxxxxxxxxx <mailto:kicad-developers@xxxxxxxxxxxxxxxxxxx>
>> Unsubscribe : https://launchpad.net/~kicad-developers <https://launchpad.net/~kicad-developers>
>> More help   : https://help.launchpad.net/ListHelp <https://help.launchpad.net/ListHelp>
>> 
>> 
>> 
>> -- 
>> Remember The Past, Live The Present, Change The Future
>> Those who look only to the past or the present are certain to miss the future [JFK]
>> 
>> kandrey89@xxxxxxxxx <mailto:kandrey89@xxxxxxxxx>
>> Live Long and Prosper,
>> Andrey
>> _______________________________________________
>> Mailing list: https://launchpad.net/~kicad-developers <https://launchpad.net/~kicad-developers>
>> Post to     : kicad-developers@xxxxxxxxxxxxxxxxxxx <mailto:kicad-developers@xxxxxxxxxxxxxxxxxxx>
>> Unsubscribe : https://launchpad.net/~kicad-developers <https://launchpad.net/~kicad-developers>
>> More help   : https://help.launchpad.net/ListHelp <https://help.launchpad.net/ListHelp>
> 
> _______________________________________________
> Mailing list: https://launchpad.net/~kicad-developers
> Post to     : kicad-developers@xxxxxxxxxxxxxxxxxxx
> Unsubscribe : https://launchpad.net/~kicad-developers
> More help   : https://help.launchpad.net/ListHelp


Follow ups

References