VirtualBox

Opened 11 years ago

Closed 8 years ago

#11111 closed defect (obsolete)

VirtualBox forces Mac laptops to use discrete GPU => Fixed in SVN

Reported by: cap10morgan Owned by:
Component: host support Version: VirtualBox 4.2.2
Keywords: Cc:
Guest type: all Host type: Mac OS X

Description

VirtualBox forces Mac laptops to activate their discrete GPUs, thus shortening battery life. I could understand this if there were a 3D accelerated guest OS running, but it also happens when a headless guest is running or even when no guests are running.

VirtualBox should not force the discrete GPU on when not running 3D accelerated guests.

Others have confirmed this issue in the forums here: https://forums.virtualbox.org/viewtopic.php?f=8&t=50574&p=234479&hilit=discrete#p234479

Attachments (3)

VBox.log (100.5 KB ) - added by Ringding 9 years ago.
VBox.2.log (104.4 KB ) - added by Ringding 9 years ago.
Now with 3D acceleration
VirtualBoxVM_2014-12-09_231741_OY3S.sample.txt (135.2 KB ) - added by Ringding 9 years ago.

Download all attachments as: .zip

Change History (49)

comment:1 by ratbag, 11 years ago

This issue remains. To replicate:

  1. Use a MacBook with multiple graphics card (confirmed on MacBook Pro Retina)
  2. Install gfxCardStatus
  3. Start a headless guest
  4. gfxCardStatus reports that the discrete NVIDIA GeForce GT650M is in use
  5. Watch battery life plummet
  6. Attempting to switch to integrated graphics leads to error "You can't switch to integrated only while the following item is running: VBoxSVC"

Using Mac OS 10.8.2, gfxCardStatus v2.3, VitrtualBox 4.2.6 r82870, driven by Vagrant 1.0.6

comment:2 by Bountin, 11 years ago

+1

comment:3 by newtonick, 11 years ago

+1

comment:4 by washley, 11 years ago

+1

comment:5 by enrise, 11 years ago

+1

comment:6 by ademuk, 11 years ago

+1

comment:7 by FiloSottile, 11 years ago

+1

comment:8 by vanten, 11 years ago

+111!1

comment:9 by Frank Mehnert, 11 years ago

Yes, understood. But so far we don't have an idea why VirtualBox triggers using the discrete CPU. Investigations plus patches are welcome.

comment:10 by dyname212, 11 years ago

+1

comment:12 by chakatodd, 11 years ago

+1

comment:13 by laird, 11 years ago

+1

comment:14 by kevinwallace, 11 years ago

+1

comment:15 by Lanchez, 11 years ago

+1

comment:16 by dyname212, 11 years ago

+1 with the newest VB 4.2.14 version, please fix this the bateriies on macbook retina last for less than 2.3 hours

comment:17 by phinze, 11 years ago

Just for fun I tried setting NSSupportsAutomaticGraphicsSwitching to true in VirtualBox's Info.plist as mentioned here:

http://developer.apple.com/library/mac/#qa/qa1734/_index.html

I managed to generate two nearly identical VBoxSVC crash reports by trying to use vagrant after setting that bit.

https://gist.github.com/phinze/da3b75a0219d6dec818e

Looks like a null pointer dereference somewhere in Appliance::Task. I'm way out of my league here, but conceptually it seems like we need to delay or avoid the creation of an OpenGL context in a headless environment. I'll see if I can get the chance to bomb around the VBoxSVC source this week and I'll post back here if I learn anything.

But anybody who actually knows what they're doing is more than welcome to chime in here. :)

comment:18 by phinze, 11 years ago

Correction: The crashes I reported above were actually coming from #11895 - I had just upgraded to 4.2.14 before fiddling with this and the VBoxSVC crashes were happening on OVF imports.

So after getting on 4.2.16, the behavior when adding that Info.plist key is actually no change at all. The rest of my comments still apply, most especially the ones about me not knowing what I'm doing. ;)

comment:19 by Diranged, 11 years ago

+1

This is a huge issue... it would be fantastic to get support for switching graphics drivers!

comment:20 by frak, 11 years ago

+1

comment:21 by drayne, 11 years ago

+1 !! I, and my battery will thank you

in reply to:  21 comment:22 by dyname212, 11 years ago

Here is workaround that works for me. I get 5 hours with 3-4 instances running !!!!

I have the latest 4.2.16 VB installed. This works on both the lion and OS X 10.8.4 "mountain lion". Here is how can you get the virtual box work with integrated graphics. (YMMV)

  1. Make sure that all VB instances are in "Powered OFF" mode.
  2. Make sure that you don't have the "3d" or "2d" acceleration turned on under settings->Display
  3. start the gfxcardstatus utility (http://gfx.io)
  4. switch the card to "I" integrated mode "Integrated Only" using gfxcardstatus
  5. Start the VirtualBox
  6. Start one of the instances the graphic mode should stay on "I" integrated mode

I didn't try to start VB from the terminal window. I tested this with winxp, win7 win764 win2k8 and others. Let me know if it worked for you!

comment:23 by larstobi, 10 years ago

+1

comment:24 by aktau, 10 years ago

+1, it's the single biggest battery drain on my MBP and limits my mobility quite a bit, as I always work with (headless) VMs for development. Since the upgrade to OSX Mavericks is free, perhaps it's a good idea to just focus on that OS in the beginning.

comment:25 by larstobi, 10 years ago

+1

comment:26 by larstobi, 10 years ago

If you're sure none of your VMs are using any graphics accelleration (2D/3D), you can add a line to the Info.plist yourself to avoid switching to the discrete GPU. Add this line within the <dict> tag in /Applications/VirtualBox/Contents/Info.plist:

<key>NSSupportsAutomaticGraphicsSwitching</key> <true/>

That stops my Macbook Pro from switching to the discrete GPU.

comment:27 by larryweya, 10 years ago

I'm on a MBP early 2013 and recently upgraded to Mavericks and my headless VM's no longer switch to discrete graphics. Not sure about non-headless VMs though.

comment:28 by Klaus Espenlaub, 10 years ago

My guess is that this is caused by VBoxSVC running the 3D test (which is a separate executable), but I have no idea whatsoever why this permanently marks it as needing the "good" 3D.

Any OSX experts around who could give a hand? The number of "+1" posts can't speed up our work if we have no idea what's the root cause and how to change it.

comment:29 by Armada651, 10 years ago

I'm not a complete Mac OS X expert, but I've done a lot of research on the subject of graphics switching. Any call to an OpenGL function will cause Mac OS X to switch to the discrete GPU until the application is closed.

In my experience it only happens when either starting a guest with 3D acceleration enabled (which expected behavior) or when I open the settings menu (that needs to be fixed). With the settings menu the discrete GPU stays in use until both the settings menu and the main window are closed. It doesn't matter whether a guest running simultaneously as long as it does not use 3D acceleration.

This lead me to believe this separate executable for the 3D test is only exited when the main window of VirtualBox closes.

EDIT: It will also persist on the guest if the settings menu is opened through its menus, meaning the guest has to be closed completely to switch back to the integrated GPU.

Last edited 10 years ago by Armada651 (previous) (diff)

comment:30 by Frank Mehnert, 9 years ago

First part of a fix is part of VBox 4.3.16.

comment:31 by Frank Mehnert, 9 years ago

Summary: VirtualBox forces Mac laptops to use discrete GPUVirtualBox forces Mac laptops to use discrete GPU => Fixed in SVN

The 2nd part of the fix is part of the next maintenance release. Here is a test build.

comment:32 by Frank Mehnert, 9 years ago

Could you confirm that this problem is finally fixed with VBox 4.3.18?

comment:33 by Ringding, 9 years ago

Still happening for me when I open the machine settings dialog. OSX 10.9.4, MacBookPro6,2, VBox 4.3.18.

comment:34 by Ringding, 9 years ago

Same with Yosemite.

comment:35 by galitsyn, 9 years ago

Ringding, could you please attach VBox.log?

in reply to:  35 ; comment:36 by Ringding, 9 years ago

Replying to galitsyn:

Ringding, could you please attach VBox.log?

Unfortunately, I don't think VirtualBox writes log information for opening the settings dialog.

in reply to:  36 comment:37 by galitsyn, 9 years ago

Replying to Ringding:

Replying to galitsyn:

Ringding, could you please attach VBox.log?

Unfortunately, I don't think VirtualBox writes log information for opening the settings dialog.

Could you please run any VM on your Mac host and attach VBox.log which relates to it?

by Ringding, 9 years ago

Attachment: VBox.log added

comment:38 by Ringding, 9 years ago

Sure, but that does not switch the graphics card.

in reply to:  38 ; comment:39 by galitsyn, 9 years ago

Replying to Ringding:

Sure, but that does not switch the graphics card.

Seems your VM has no 3D acceleration enabled. May I ask you to enable it and re-take log? Most likely graphics card switching is caused by 2D and/or 3D test execution which we run once settings dialog is opened. We enable offline rendering for both 2D and 3D tests if we correctly determine that Mac host has more than one GPU installed. Enabling 3D for VM should show if we do it correctly for your host. Btw, if you would build VBox from source -- 2D test will cause graphics switching because we patch Qt (and ship it) in order to enable offline rendering.

by Ringding, 9 years ago

Attachment: VBox.2.log added

Now with 3D acceleration

in reply to:  39 comment:40 by Ringding, 9 years ago

Replying to galitsyn:

Replying to Ringding:

Sure, but that does not switch the graphics card.

Seems your VM has no 3D acceleration enabled. May I ask you to enable it and re-take log? Most likely graphics card switching is caused by 2D and/or 3D test execution which we run once settings dialog is opened. We enable offline rendering for both 2D and 3D tests if we correctly determine that Mac host has more than one GPU installed. Enabling 3D for VM should show if we do it correctly for your host. Btw, if you would build VBox from source -- 2D test will cause graphics switching because we patch Qt (and ship it) in order to enable offline rendering.

It's the official binary. Sure enough, with 3D acceleration enabled, display switching did indeed occur.

comment:41 by galitsyn, 9 years ago

Ok, thanks for the logs. VBox.log shows that we enable offline rendering and graphics card switching should not occur. Let me think about it tomorrow morning. Btw, you don't have any ext monitor attached to you MBP, right?

in reply to:  41 comment:42 by Ringding, 9 years ago

Replying to galitsyn:

Ok, thanks for the logs. VBox.log shows that we enable offline rendering and graphics card switching should not occur. Let me think about it tomorrow morning. Btw, you don't have any ext monitor attached to you MBP, right?

No. Integrated display, that’s all.

I have a version of Qt installed in /Library/Frameworks (4.8.5). Is it possible that there might be some interference coming from that?

comment:43 by galitsyn, 9 years ago

I think this is not likely. May I ask you to attach sample report for VM process (sudo sample <VBox VM PID>)? It will show all dylibs used by the process.

comment:44 by Ringding, 9 years ago

You were right. It linked against the bundled version.

comment:45 by Ringding, 9 years ago

To clarify this: graphics switching is triggered by running a VM with 3D acceleration enabled (expected), but not when running one without 3D acceleration (also expected). It also happens when opening the machine settings dialog, either from the main manager window or from the running VM window itself (both not expected), the latter especially annoying because it will stay in discrete mode for as long as the VM continues to run.

comment:46 by aeichner, 8 years ago

Resolution: obsolete
Status: newclosed

Please reopen if still relevant with a recent VirtualBox release.

Note: See TracTickets for help on using tickets.

© 2023 Oracle
ContactPrivacy policyTerms of Use