popupMenu very very slow in Mojave

  1. 7 months ago
    Edited 7 months ago

    Hello,
    after upgrading from Sierra to Mojave I noticed that an app of mine, created in Sierra, now takes about 10 secs before its opening process comes to an end.
    The cause of this delay is that at opening time the app loads several popupmenus, each with about 300 rows.

    So I created a new project with twelve popupmenus and the code below in a push button:
    to load 300 rows, it takes about 210 ticks.

    My MBP has got only 8G of memory, but in Sierra the delay was not as marked as now.
    Using Xojo 2018r4, aggressive
    Is there a way to speed up the process?

    Sub Action() Handles Action
      #pragma disableBackgroundTasks
      #pragma disableBoundsChecking
      
      dim tt as Double = Ticks
      dim s as String = "wisdom"
      for i as Integer = 0 to 300
        for k as Integer = 0 to 11
          PopupMenu1(k).AddRow s
          //dim n as Integer = PopupMenu1(k).ListCount-1
          //PopupMenu1(k).RowTag(n) = "some value"
        next
      next
      
      for i as Integer = 0 to 11
        PopupMenu1(i).ListIndex = 0
      next
      
      label1.text =  Format(Ticks-tt, "#")
    End Sub
  2. Beatrix W

    30 Dec 2018 Pre-Release Testers Europe (Germany)
    Edited 7 months ago

    Make us something for testing. I'm not seeing this problem:

    dim t1 as Integer = Ticks
    for i as Integer = 0 to 300
      me.AddRow(str(i))
      
    next
    
    dim t2 as Integer = Ticks

    in a popup menu open takes 16 ticks. Xojo 2018r3 in debugger on MacBook Air. Mojave latest beta.

  3. Have you tried loading an array of 12 popuopmenus?

  4. Jeff T

    30 Dec 2018 Pre-Release Testers Midlands of England, Europe

    Do you have code in the change event?
    If so, disable the control before filing it, and enable it when complete
    In the change event, wrap the code in

    if me.enabled then
    //do stuff
    end if
  5. No code anywhere. The 12 popupmenus do not have any event. The only code is in the push button populating the menus.
    Unfortunately I do not have anymore Sierra, just to test and see how many ticks it would take to execute the same code.

  6. Beatrix W

    30 Dec 2018 Pre-Release Testers Europe (Germany)

    200 ticks for an array of 12 popup menus.

    Do you know what lazy loading is?

  7. Dave S

    30 Dec 2018 San Diego, California USA

    personally... if I had the need for ONE popup with 300 items, I would want to rethink the GUI design. and with 12 such popups, that would be a definite rethink

  8. Emile S

    31 Dec 2018 Europe (France, Strasbourg)

    @Dave S personally... if I had the need for ONE popup with 300 items

    Even with alphabetically populated data *, 300 items is a bit “too” many.

    * Remember: click in the PopupMenu followed by a L display the first word that start with L.

    In a production software, and to avoid troubles (wrong dates), I have a PopupMenu with 100 (or was it 99 ?) entries (years since the current year): I am not happy with that at all, but it was the “best” I was thinking at (to avoid strange birth years…).

  9. Ulrich B

    31 Dec 2018 Pre-Release Testers, Xojo Pro Europe (Germany, Berlin) · xo...
    Edited 7 months ago

    Despite the fact that I agree with the previous posters about the usability of such Popupmenus (have you considered using ComboBoxes with autocomplete, disallowing custom input?), the time you report is way too long.
    Did you try to cache the current popup like

    for k as Integer = 0 to 11
       Dim CurrentPopup as PopupMenu = PopupMenu1(k)
        for i as Integer = 0 to 300
          CurrentPopup.AddRow s
        next
    CurrentPopup.ListIndex = 0
    next
  10. Richard D

    31 Dec 2018 Pre-Release Testers, Xojo Pro Europe (UK, London)

    @Emile S Even with alphabetically populated data *, 300 items is a bit “too” many

    what is the maximum number of items in the dropdown or a popupmenu??

    what to use instead of you have lots of items say over the maximum ??

  11. Ulrich B

    31 Dec 2018 Pre-Release Testers, Xojo Pro Europe (Germany, Berlin) · xo...
    Edited 7 months ago

    @Richard D what is the maximum number of items in the dropdown or a popupmenu??

    There are no problems loading 10,000s of rows, only the time it might take.
    This example loads over 10,800 rows and needs around 6 seconds on a 2015 macBook Pro, but mostly because it does a lot of introspection while doing so:
    -image-

    @Richard D what to use instead of you have lots of items say over the maximum ??

    There are not so many options, and you will have a hard time trying to reach the maximum row count. Anyway, all the options (PopupMenu, ComboBox, single-column ListBox) carry the necessity to create a DataSource (implicitly by addRow or similar methods), and the only means to speed this up are to either use native controls that have an open dataSource property (like Thomas’ example of NSTableView with MBS controls) or to implement a cache/slize mechanism like in the DataOnDemandListbox.

  12. Richard D

    31 Dec 2018 Pre-Release Testers, Xojo Pro Europe (UK, London)

    i should not have say maximum. for a listbox, it is probably ok to have thousand of rows.

    i should have say what is number of items most people use in this forum for a combobox or a popupmenu???

  13. Dave S

    31 Dec 2018 San Diego, California USA

    @Richard D i should not have say maximum. for a listbox, it is probably ok to have thousand of rows.

    i should have say what is number of items most people use in this forum for a combobox or a popupmenu???

    no more than a dozen or so.

  14. While I agree that a popupmenu is not the best choice for 300 rows, and in fact I'm since then rethinking the approach to the problem, I wanted to point out that in Mojave popups are ways slower that, for instance, in Sierra.
    Thank you for the advices and suggestions.

  15. James S

    2 Jan 2019 Pre-Release Testers, Xojo Pro

    I ran into this same problem recently. It’s actually faster for me to build my selection popup menus on a web app in a remote location with a slow internet connection then on a native app. I don’t have 300 items either, maybe half that. It’s perfectly reasonable in my mind to use popup menus for such a thing even with 300 or more items since you can type ahead to find the thing you’re looking for as long as they are added alphabetically.

    There is a HUGE difference in speed for adding rows to a popup menu on Mojave as opposed to everything that has gone before you’re absolutely correct. Any discussion about if this is the right thing to do or not is not helpful as there is a definite bug in either xojo or the OS regarding this.

    I have built myself a type ahead something like the combobox as I couldn’t get that to do what I wanted. But there is definitely something wrong with adding rows to popup menus in mojave, it’s orders of magnitude slower. The window I had with 5 popups with around 200 entries in them opens in an eyeblink on previous OS’s and takes upwards of 7 seconds on Mojave.

  16. I already refactored the interface of my app, getting rid of the popupmenus. But I agree with you that correctly or uncorrectly using popups is not the crux of the matter; the crux of the matter being that in Mojave they have become slow.

  17. Emile S

    3 Jan 2019 Europe (France, Strasbourg)

    @Carlo R the crux of the matter being that in Mojave they have become slow

    Yes.

  18. 7 days ago

    Etienne P

    Jul 13 Montreal, Canada

    Any clue how to fix this ?

  19. Markus W

    Jul 13 Pre-Release Testers #JeSuisHuman New Zealand, Auc...

    @Etienne P Any clue how to fix this ?

    See here: https://www.great-white-software.com/blog/2019/06/24/speed-tip-with-popupmenus/

or Sign Up to reply!