Request: Do not require discrete graphics on MacBook Pro with dual graphics?

195 views
Skip to first unread message

cmt

unread,
Jun 6, 2015, 10:46:48 AM6/6/15
to tunnelbli...@googlegroups.com
Hi,

First of all, thank you all for creating such an awesome VPN client! I really appreciate the effort you put into Tunnelblick!

Unfortunately, Tunnelblick requests the discrete graphics card on my MacBook Pro - is this intended and, more importantly, really required?

It would be great if Tunnelblick would work without requesting the discrete graphics card as this would save a lot of battery. As a developer, I think there should be an Apple API for that. From what I found it should be something in a *.plist file (NSSupportsAutomaticGraphicsSwitching)? (https://github.com/daveygm/brackets-shell/commit/c238da5b300edb075e9617a76daa5d288960102f)

However, as I am not familiar with your code base and don't want to break anything, I don't want to fix it myself.

Thank you!

jkbull...gmail.com

unread,
Jun 6, 2015, 12:24:36 PM6/6/15
to tunnelbli...@googlegroups.com, titze.c...@gmail.com, titze.c...@gmail.com
Tunnelblick doesn't do anything to "require" the discrete graphics card. My understanding is that OS X automatically switches to use it when the graphics load is "high" (whatever that means).

The link you provided confuses me, though, as do the other pages I found in a quick search (https://zacwe.st/blog/rdio-discrete-card, for example). It it titled "Added plist setting so integrated GPU is used on Macs with dual GPUs", but it seems to set a flag to allow switching to the discrete graphics card because it sets NSSupportsAutomaticGraphicsSwitching to TRUE. I would think that NOT allowing graphics switching would be what is wanted.

I don't have hardware I can use to test this. If you want, you could try the following command in Terminal:

sudo defaults write /Applications/Tunnelblick.app/Contents/Info.plist NSSupportsAutomaticGraphicsSwitching -bool YES

("sudo" is required because the Info.plist is protected. You'll have to enter your password.)

Doing this will invalidate Tunnelblick's digital signature, so you will get a warning about Tunnelblick having been tampered with; just ignore that.

If that forces Tunnelblick to use the integrated graphics, please reply here and I will consider adding it to Tunnelblick's Info.plist. I'm not sure I want to do that, though, because I'm not sure that's what most people would want. (I can't make it optional because it is in the Info.plist.)

---------
You can restore your original Info.plist (and the digital signature will then validate properly) with the following command in Terminal:

sudo defaults delete /Applications/Tunnelblick.app/Contents/Info.plist NSSupportsAutomaticGraphicsSwitching

titze.c...@gmail.com

unread,
Jun 6, 2015, 2:18:25 PM6/6/15
to tunnelbli...@googlegroups.com, titze.c...@gmail.com
Actually, the NSSupportsAutomaticGraphicsSwitching flag tells OS X to prefer the integrated graphics over the discrete graphics whenever possible - but you're right, at first I was confused as well. Apple's official documentation has the following to say: https://developer.apple.com/library/mac/qa/qa1734/_index.html

I now tried the flag but unfortunately it does not make any difference, neither with YES nor NO. Therefore, it seems that this issue is harder to resolve than first thought.
But what I noticed: Tunnelblick does not require the discrete graphics until I hover over its icon in the menubar and the black transparent status box pops up. I therefore assume it has something to do with the popup which apparently causes OS X to switch to the discrete graphics because it requires OpenGL.

There have been similar issues in other products as well:

So, if you have any idea how to prevent this behavior I could try it on my machine. Otherwise this topic can be regarded as a minor low-priority issue.

jkbull...gmail.com

unread,
Jun 6, 2015, 3:56:55 PM6/6/15
to tunnelbli...@googlegroups.com, titze.c...@gmail.com, titze.c...@gmail.com
Thanks for trying both YES and NO. I think that Tunnelblick must set it to YES and then do something programmatically, too, but I don't know what.

It doesn't solve the problem, but you could disable the black status window by setting it to "Never Show" in the "Appearances" panel.

The discrete card may also be started when try to you connect, because of the animation of the Tunnelblick icon. But it would be a start towards understanding the problem to know if that happens, too.

cmt

unread,
Jun 7, 2015, 12:01:35 PM6/7/15
to tunnelbli...@googlegroups.com, titze.c...@gmail.com
Just tested with status window set to "Never Show": Tunnelblick only requires the integrated graphics - the animated icon does not cause it to request the discrete graphics.

So now the question is if there is something you could do programatically to prevent the status window from "requesting" the discrete graphics (Maybe some sort of parameter in the window's constructor that tells OS X its graphics impact is "lightweight"?). This in combination with the flag we explored previously should finally fix the issue.

jkbull...gmail.com

unread,
Jun 7, 2015, 1:18:56 PM6/7/15
to tunnelbli...@googlegroups.com, titze.c...@gmail.com, titze.c...@gmail.com
Everything I've looked at talks about OpenGL, which is very low-level (way below the level of methods that Tunnelblick uses).
 http://www.cocoabuilder.com/archive/cocoa/328827-staying-on-integrated-gpu-while-using-nsopenglview.html talks about setting possible formats for pixels, for example; Tunnelblick doesn't do anything at that low a level.

One thing I did find there that sounded promising:

I was curious about this as well, and I noticed that, starting in 10.8.4, instantiating an IKImageBrowserView will not toggle the discrete GPU. So I tried to figure out what it was doing, and found it uses four pixel formats: NSOpenGLPFAAllowOfflineRenderers, NSOpenGLPFANoRecovery, NSOpenGLPFAAccelerated, and a mysterious pixel format identified as 1262.
The first three of the above are standard pixel formats, but the 1262 format doesn't appear to be documented anywhere. I found out that adding the undocumented pixel format in addition to the three above apparently prevents the discrete switch-over from happening. Since it's undocumented, the usual disclaimers apply: use it at your own risk, it may break in the future, and all that.

Unfortunately, I have no idea where or how to set this pixel format.

cmt

unread,
Jun 7, 2015, 2:37:29 PM6/7/15
to tunnelbli...@googlegroups.com, titze.c...@gmail.com
I'm not familiar with Objective-C and Cocoa, but can you somehow deactivate CoreAnimation in StatusWindow.nib? https://trac.adium.im/ticket/16001 mentions this as a possible solution.

But it definitely has to do with OpenGL: I just traced Tunnelblick with dtruss and after reading StatusWindow.nib the OpenGL framework gets loaded and the graphics switching occurs.

Apart from that, I think you should definitely add the NSSupportsAutomaticGraphicsSwitching flag to Info.plist in the next version because it seems to work on newer MBP models (https://trac.adium.im/ticket/16172#comment:10), just not on my 2010 MBP. Someone with a 2011 or newer MBP should definitely test this...

titze.c...@gmail.com

unread,
Oct 4, 2015, 8:15:42 AM10/4/15
to tunnelblick-discuss, titze.c...@gmail.com
Yay, seems to be fixed in El Capitan!---Either that or it has to do with the current version of Tunnelblick I'm running, 3.5.4 (build 4270.4395).

jkbull...gmail.com

unread,
Oct 4, 2015, 8:29:00 AM10/4/15
to tunnelblick-discuss, titze.c...@gmail.com
Thanks for your report about El Capitan.

Nothing has been done that would affect this in any released version of Tunnelblick, including 3.5.4, so I guess El Capitan defaults to use integrated graphics.

In an amazing coincidence, I added the NSSupportsAutomaticGraphicsSwitching flag to the source code of Tunnelblick's Info.plist only three days ago! So that entry will be in the next beta release.
Reply all
Reply to author
Forward
0 new messages