MacBookPro 13" 2018 retina enabled, timing lag

My gamelan emulation app Midi Gender shows terrible timing lags if retina is on. Compiled with 2018r4 it gets a bit better, but is still far from good. On my MacBookPro 13" early 2015 I can’t see this behaviour, anything that can be done? Setting resolution to low can’t be the solution…

Show us some code how you do Retina drawing.

Otherwise, install the Instruments part of XCode and have some fun with the Time Profiler.

Maybe better put the code in a Thread to make it more independent from the UI Thread and work with the Priority.

Hi Beatrix, thanks for replying.
It is a custom control with a photo of the real instrument with bronze keys in background. When a keys are active, I draw corresponding rectangles with transparency to a Picture and in the Paint-event the complete picture gets drawn to the control and the Paint-event is triggered by me.Invalidate(theRect, false)

Draw Gender ()

[code]for i = 0 to 9

if gKeyChanged(i) then
if gKeyActive(i) then
pGender.Graphics.DrawPicture gKey(i), gRect(i,0), gRect(i,1)
pGender.Graphics.ClearRect(gRect(i,0) - 2, gRect(i,1) - 2, gRect(i,2) + 3, gRect(i,3) + 3)
end if
me.Invalidate(gRect(i,0), gRect(i,1), gRect(i,2)+4, gRect(i,3)+4, false)
end if


Paint ()

g.Transparency = 60 g.DrawPicture pGender, 0,0

I’ve done a lot of optimisations when retina came mandatory, and as I’ve stated, it’s working fine on my older MBP, just the new more powerful MBP 2018 seem not to like the picture drawing…

Hi Sascha, I’ve done a lot of versions with threads, custom timers a.s.o. None was really successful. And it does not really help to have the playing without timing issues, but have the graphical indication of the playing not on time, as this is a important part of the app. Maybe Xojo is not really the language to do realtime code and I’ll have to port it to obj C or Swift…

Addition to the code. The key pictures are drawn like this:

[code]for i = 0 to 4
gKey(i) = New Picture(gRect(i, 2), gRect(i, 3))
gKey(i+5) = New Picture(gRect(i + 5, 2), gRect(i + 5, 3))
gKey(i).Graphics.ForeColor = &cb0b0b0
gKey(i+5).Graphics.ForeColor = &cb0b0b0

gKeyChanged(i) = true
gKeyChanged(i+5) = true

As to see in attached profiler screenshots, the new MBP needs more than 3 x longer to render the gender control:

in your DrawGender routine what is “ME”? Incomplete code makes it difficult to understand you problem.
But depending on what ME is… that INVALIDATE may be causing recursive loops that waste time.

Based on another topic here recently. it seemed that HighSierra was forgiving about somethings, and when Mojave tightened things up, Xojo code that had previously worked now crashed… but it was becuase the code was using Invalidate in improper places.

Hi Dave, thanks for looking at. ME is the custom control, it’s Super is Canvas, so just triggers the paint event. As already stated, both of my MBPs run under 10.14.2, there was no change in performance on my older device, I can see it only on my new one. And as you can see from my screenshots, it effectively takes 3 times as long for the paints.

Sorry for confusion, had marked the screenshots wrong, fixed now…

It’s really hard to say where the problem might come from. The code doesn’t really scream “I’m slow”. How large are the images that you show? How many canvases do you have? What is causing your code to be called 1731 times? Could it be that you have refreshes in your code that cause repainting? Have you tried to make a more simple version of your window?

remember that a retina version of an image is in fact 4x larger than its non-retina counterpart

Did you try Profiling your code ?

@Beatrix Willius, it’s a music app, and 1731 times represent note on/off events needing highlight/unhighlight the keys, I don’t think there are any more than needed;-)
But my question is: why is it so much slower on the new MBP?

Emile… look at his posts towards the top

@Dave S, it’s no images, just rectangles with transparency, and yes they’re 4x as big when retina enabled, but why is it handled fine on my 2015 MBP?

The image size depends on app scaling, smallest is 310 x 155 but can easily scaled up to 620 x 310 and it’s two instruments, so this twice:
My app is here:
use the promo codes below:

I did the last code and will have a look at your app tomorrow. I have 2 computers one with Retina and one without.

detail the differences between the two machines?

Graphics GPU/Ram?

@Beatrix Willius, thanks! Just for the record, it’s running under retina fine since years, it’s just the new MBP that should actually be much faster has troubles. Best to test the performance, load the song “Sekar Sungsang Sukawati”. The Sukawati-Style has more polyphony, so more keys to render.