PopUp Menu Changes with Compilation Setting

This is something I’ve never seen before. Is it perhaps a bug in Xojo 2021r3? Not sure but let me explain/

First of all, I am seeing this on Mac OS. I have a listbox which contains a number of pop-up menus positioned in one of the columns. I have a method that sets the size of the list box to the NSSmall size that someone here provided:

Public Sub setControlSize(Extends c as RectControl, inSize as NSControlSize)
  #If TargetCocoa Then
    Declare Function NSClassFromString Lib "Cocoa" (className As CFStringRef) As Ptr
    declare sub setSize lib "Cocoa" selector "setControlSize:" _
    ( ObjectHandle as Integer, inSize as NSControlSize )
    Declare function getCell lib "Cocoa" selector "cell" ( handle as integer ) as Integer
    if c isa progressBar or c isa ProgressWheel then
      setSize( c.handle, inSize )
      setSize( getCell( c.handle ), inSize )
      // - Now we also update the text font to match
      Dim fontSize as Double
      select case inSize
      case NSControlSize.NSRegularControlSize
        declare function systemFontSize lib "Cocoa" selector "systemFontSize" _
        ( classRef as Ptr ) as Double
        fontSize = systemFontSize( NSClassFromString( "NSFont" ) )
        // + (CGFloat)smallSystemFontSize
        declare function smallSystemFontSize lib "Cocoa" selector "smallSystemFontSize" _
        ( classRef as Ptr ) as Double
        fontSize = smallSystemFontSize( NSClassFromString( "NSFont" ) )
      end select
      // + (NSFont *)systemFontOfSize:(CGFloat)fontSize
      declare function systemFontOfSize lib "Cocoa" selector "systemFontOfSize:" _
      ( classRef as Ptr, inSize as Double ) as Ptr
      Dim ref as Ptr = systemFontOfSize( NSClassFromString( "NSFont" ), fontSize )
      if ref <> nil then
        // - (void)setFont:(NSFont *)fontObject
        declare sub setFont lib "Cocoa" selector "setFont:" _
        ( NSControlHandle as integer, font as Ptr )
        setFont( c.handle, ref )
      end if
    end if
    #pragma undefined
End Sub

When I run in debug mode - things are fine. When I compile using default optimization, my pop-up menus look correct like this:

and Monitoring

nd Monitoring

But when I compile with Aggressive optimization, I get this:

Connected Source

and Monitoring

I have NEVER seen this before. I always use the Aggressive optimization setting when compiling my releases. I probably don’t need to and at this point, I’m not going to. But I think this might be a bug in 2021r3 as nothing in these have changed from previously.

Thoughts anyone?


maybe it optimizes the code away?
Try changing the #if targetCocoa to #if TargetMacos and see if that helps?

Setting to aggressive may change loops to lines etc depending on how you coded it.
It may aloso modify or alter your code much more intensively so it could be something that changed too much.

Aggressive really pumps up the size of the app. Have you tried Moderate? What does that do?

Really? My app seems about the same size with either - around 126 MB. I figured aggressive optimization would result in a smaller and faster app. Maybe I am wrong?

I’m trying TargetMacOS now.

It’s weird because it has worked since 64 bit compilation was released until now…

Interesting. Lessee now. Compiling for macOS:

Default:     28.2 Mbytes
Moderate:    26.8 Mbytes
Aggressive:  88.4 Mbytes

Aggressive takes a lot longer than the other two, also. I should obviously switch to Moderate.

This is normal for aggressive to be larger in size as i’ve noted it may convert for example a loop to multiple (longer) code lines (equivalent) but more optimized for speed.

It optimizes for “speed” not “small size”

say you do something like:

For i As Integer = 0 To 100
// Do something
system.debuglog "ok"
Next i

aggressive may convert to

system.debuglog "ok"

But it could also become the equivalent of 100 of those lines without the loop.

You are correct. I never noticed it before. My aggressive file size. is 255 MB. And yes it takes a LONG time. Maybe not worth it…

That didn’t fix it. Still the same issue… It seems like that method runs fine - the pop-up menus are smaller. The font size is just wrong or something else…

So moderate optimization doesn’t work either! Only default shows the text in the pop-up menus. This is definitely a change from the past.