VirtualBox

Ticket #11111 (closed defect: obsolete)

Opened 5 years ago

Last modified 16 months ago

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

Reported by: cap10morgan Owned by:
Priority: major 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

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

Change History

comment:1 Changed 5 years ago by ratbag

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 Changed 5 years ago by Bountin

+1

comment:3 Changed 5 years ago by newtonick

+1

comment:4 Changed 5 years ago by washley

+1

comment:5 Changed 5 years ago by enrise

+1

comment:6 Changed 5 years ago by ademuk

+1

comment:7 Changed 5 years ago by FiloSottile

+1

comment:8 Changed 5 years ago by vanten

+111!1

comment:9 Changed 5 years ago by frank

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 Changed 5 years ago by dyname212

+1

comment:11 Changed 5 years ago by mhanor

comment:12 Changed 5 years ago by chakatodd

+1

comment:13 Changed 4 years ago by laird

+1

comment:14 Changed 4 years ago by kevinwallace

+1

comment:15 Changed 4 years ago by Lanchez

+1

comment:16 Changed 4 years ago by dyname212

+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 Changed 4 years ago by phinze

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 Changed 4 years ago by phinze

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 Changed 4 years ago by Diranged

+1

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

comment:20 Changed 4 years ago by frak

+1

comment:21 follow-up: ↓ 22 Changed 4 years ago by drayne

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

comment:22 in reply to: ↑ 21 Changed 4 years ago by dyname212

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 Changed 4 years ago by larstobi

+1

comment:24 Changed 4 years ago by aktau

+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 Changed 4 years ago by larstobi

+1

comment:26 Changed 4 years ago by larstobi

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 Changed 4 years ago by larryweya

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 Changed 4 years ago by klaus

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 Changed 4 years ago by Armada651

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 4 years ago by Armada651 (previous) (diff)

comment:30 Changed 3 years ago by frank

First part of a fix is part of VBox 4.3.16.

comment:31 Changed 3 years ago by frank

  • Summary changed from VirtualBox forces Mac laptops to use discrete GPU to VirtualBox 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 Changed 3 years ago by frank

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

comment:33 Changed 3 years ago by Ringding

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

comment:34 Changed 3 years ago by Ringding

Same with Yosemite.

comment:35 follow-up: ↓ 36 Changed 3 years ago by galitsyn

Ringding, could you please attach VBox.log?

comment:36 in reply to: ↑ 35 ; follow-up: ↓ 37 Changed 3 years ago by 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.

comment:37 in reply to: ↑ 36 Changed 3 years ago by galitsyn

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?

Changed 3 years ago by Ringding

comment:38 follow-up: ↓ 39 Changed 3 years ago by Ringding

Sure, but that does not switch the graphics card.

comment:39 in reply to: ↑ 38 ; follow-up: ↓ 40 Changed 3 years ago by 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.

Changed 3 years ago by Ringding

Now with 3D acceleration

comment:40 in reply to: ↑ 39 Changed 3 years ago by Ringding

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 follow-up: ↓ 42 Changed 3 years ago by 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?

comment:42 in reply to: ↑ 41 Changed 3 years ago by Ringding

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 Changed 3 years ago by galitsyn

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.

Changed 3 years ago by Ringding

comment:44 Changed 3 years ago by Ringding

You were right. It linked against the bundled version.

comment:45 Changed 3 years ago by Ringding

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 Changed 16 months ago by aeichner

  • Status changed from new to closed
  • Resolution set to obsolete

Please reopen if still relevant with a recent VirtualBox release.

Note: See TracTickets for help on using tickets.

www.oracle.com
ContactPrivacy policyTerms of Use