GUIs are mirrored vertically (mac)

Apple tries to not break apps built with an older macOS SDK on newer macOS versions sometimes by providing them with the same environment as they were built. And in this case it looks like that DP was built with a version where NSViews were not using any CALayers by default. Later macOS added CALayers per default and one of these has the geometryFlipped property set to true. While the default is false. So in the case of DP if you add a layer, the content is not flipped. For any other host build with a later SDK adding a layer the content is flipped.

Later macOS added CALayers per default and one of these has the geometryFlipped property set to true

Thanks for bearing with me on this one. If you take a look at the debug dump from DP both CALayers have geometryFlipped set to NO, though. I guess you’re referring to the contentsAreFlipped implementation?
Anyway, making sure that the two layers added by VSTGUI have opposite geometryFlipped values seems to fix the issue. I still don’t get why it doesn’t mess up the appearance in all other cases.

The important part is that VSTGUI expects that contentsAreFlipped are YES for its own layer. It doesn’t matter what the other layers have.
In the case of DP, per default there’s no layer created by the system. VSTGUI now triggers NSView.wantsLayer = YES which indirectly creates a CALayer hierarchy for the NSView and adds one Layer. Now VSTGUI adds its render layer via [nsView.layer addSublayer:caLayer];. Both layers have their default state which is geometryFlipped == NO. Thus the render layer has contentsAreFlipped == NO.
In the case of hosts built with newer SDK versions, the NSView is already using layers and one of these layers has geometryFlipped == YES and thus all layers afterwards have contentsAreFlipped == YES.

Hope this makes it more clear.

Hi Arne,

Thanks for the elaboration, it’s starting to make sense now. I’ll patch in nsviewframe.mm caLayer.geometryFlipped = ![nsView.layer contentsAreFlipped]; for now. Given that it’s a one-liner I assume I shouldn’t do a PR for a fix?

Best,
Ray

I will take care of it,

Awesome, thank you!

Sorry to resurrect an old thread, but we recently had user reports of vertically flipped VSTGUIs under NI Maschine and Vienna Ensemble Pro that seemed to be caused by the fix mentioned here caLayer.geometryFlipped = ![nsView.layer contentsAreFlipped];

Changing it to caLayer.geometryFlipped = NO fixed it for those users.

Thanks, we already had a report about it, and it has been fixed on the develop branch on GitHub (fix upside-down view in QT based hosts ¡ steinbergmedia/vstgui@488bcd0 ¡ GitHub).

I did some testing and can confirm that, yes, caLayer.geometryFlipped = ![nsView.layer contentsAreFlipped] is definitely needed for Digital Performer 9 on macOS 10.13!

It’s not necessary for DP10, or DP9 on macOS 12. I don’t have the in-between macOS versions to check those.

Maschine 2 seems fine on 10.13 with or without caLayer.geometryFlipped = ![nsView.layer contentsAreFlipped].

1 Like

Unfortunately, the latest fix isn’t quite right.

We had a user report that the GUI is flipped on macOS 10.14 with Ableton Live 9, so I spent some time installing and testing with more OS versions.

My findings are that caLayer.geometryFlipped = ![nsView.layer contentsAreFlipped] is also needed on 10.14. Live 9 will not run on 10.15 and later, but DP9 does not require it there.


The AppKit release notes for 10.8 contain the following relevant information:

On 10.8, AppKit will control the following properties on a CALayer (both when “layer-hosted” or “layer-backed”): geometryFlipped, bounds, frame (implied), position, anchorPoint, transform, shadow*, hidden, filters, and compositingFilter. geometryFlipped is only changed for apps that link on 10.8 and higher. Use the appropriate NSView cover methods to change these properties.

So in applications linked against 10.8 or later, nsView.layer.geometryFlipped gets set automatically to match -[NSView isFlipped]. And the same appears to be the case on 10.15+ regardless of which SDK apps link against.

Ableton Live 9.7.7 is linked against 10.7.

Digital Performer 9.52 curiously has no LC_VERSION_MIN_MACOSX but appears to be treated as if linked prior to 10.8.


I was able to reproduce the upside-down GUI with NI Maschine 3 (which requires macOS 13+) when using caLayer.geometryFlipped = ![nsView.layer contentsAreFlipped] without an OS version check.

Examination of the binary confirms use of Qt, apparently version 6.7.1. I created a very simple test host with Qt 6.7.1 attaching our editor to a QMainWindow, but the GUI appeared the right way up so there must be more to the issue that simply using Qt.

Hi nick,

Given that you are able to reproduce the issue in different setups, can you try whether my suggestion from the initial posts of this thread helps?

…
[nsView.layer addSublayer:caLayer];
caLayer.isGeometryFlipped = ([nsView isFlipped] != [caLayer contentsAreFlipped]? YES:NO);
…

Best,
Ray

[nsView.layer addSublayer:caLayer];
caLayer.geometryFlipped = ([nsView isFlipped] != [caLayer contentsAreFlipped] ? YES : NO);

I have just tested this… it works fine in DP 9 & Live 9 on 10.13 but causes upside-down GUI in Maschine 3.

Thanks for the swift response. Okay then, seems like there’s more to it than I thought.