BelledonneCommunications / linphone-desktop

Linphone is a free VoIP and video softphone based on the SIP protocol. Mirror of git://git.linphone.org/linphone-desktop.git
https://linphone.org/
GNU General Public License v3.0
409 stars 209 forks source link

discrete GPU triggered on use on macbook pro #472

Open dbquarrel opened 3 years ago

dbquarrel commented 3 years ago

Linphone activates the discrete GPU on launch.

This is a big problem on a laptop, as the GPU reduces battery life by 50%.

Linphone ideally needs to be running in order to answer phone calls, so it means losing half your battery life for no good reason. I don't see why it needs to activate the discrete GPU, if it needs to access anything the integrated GPU should be more than powerful enough.

Please consider the burn rate and give users an option at least to turn this off

Given the choice between using the app and keeping my battery charge, I will opt to keep the battery charge... it's really a major issue.

pandvan commented 3 years ago

I'm facing the same issue. It's very annoying as I need to work remotely with Linphone always on and this leads to an excessive battery drain. Turning on the discrete GPU makes laptop very warm in a short amount of time, not so comfortable to work with.

julonexus commented 3 years ago

Hi We don't activate it. I mean, we don't set any option to activate it. This is the default behaviour for all apps. I even didn't know that this feature existed ;) Just to be sure, can you test this version and give me a feedback about it? app Thanks

dbquarrel commented 3 years ago

I've never programmed with electron so I don't know too much for sure. But Chromium itself has settings to control whether or not the GPU will be activated with certain content, so there is probably some global flag to tell it to trigger the GPU or not. Chromium can be a pig (like this is big news to anyone) and it will go after the GPU by default for various types of content to accellerate web pages but it kills Macbooks once it does this. Fans go on and heat goes way up and the standard 5-6 hours you get in practice on an Intel Macbook can become 1 hour. I've had Linphone (due to Chromium/Electron) kill a full battery charge on my 16" 2019 Macbook Pro in 1 hour and 20 minutes doing nothing but running in the background because I forgot to shut it off when I unplugged from power. So whatever that default is you will need to locate it and turn it off.

https://www.geeksforgeeks.org/gpu-information-in-electronjs/

I can't test it now as between the time of my report and now, I've broken my Intel laptop and moved to the M1 which has no obvious way of knowing if the GPU is on.

Electron on M1 is not any better as it will run a couple of rendering processes in the background, other electron apps for instance when not handled right can be burning 50% of CPU resources again, doing nothing. Since so many people use Electron now you can have say, 4 electron apps and each one being a massive resource hog, a couple using the GPU without needing it and your brand new 2021 computer will run like a 286 and forget running on battery. So the choice to use Electron has to come with a lot of careful decisions about resource management and measurement as again... it's not just your app it will be a LOT of apps all with the same choices and misconfigurations of Electron as it's probably too complicated for anyone to know everything Chromium is going to do with resources under the hood.

So on top of your 4 Chromium/Electrons running all this rendering doing nothing, people often run a copy of Chrome on top... I just wish people would stop using electron entirely and making apps because everyone develops like their app is the only thing running on a computer.

By the way:

https://www.macupdate.com/app/mac/33905/gfxcardstatus

A tester can use this tool, only on an Intel mac, which will quickly show if the GPU has been activated and what application has done it:

It is free and has been around for many years. This may help you or someone isolate what is triggering the GPU on Intel Macbooks.

I'd consider this problem extremely high priority as killing off a laptop's charge for an unused feature is a pretty bad bug.

Good luck! And I don't blame you, Chromium/Electron is a sin on humanity and we all have to pay the price.

attermann commented 3 years ago

Linphone is not an Electron app, and it doesn't include Chromium either by default afaik. It is a Qt 5 app, and whatever triggers the discrete GPU is almost certainly inside of Qt. I will see what I can find in my own development.

attermann commented 3 years ago

@dbquarrel I have found a workaround to keep Linphone in integrated GPU mode in macOS. Find your Linphone.app bundle (should be in /Applications and edit the file ./Linphone.app/Contents/Info.plist adding the following to the end of <dict>:

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

I haven't figured out how to include this in the build process yet but will update this issue when I do.

julonexus commented 3 years ago

It's what I asked you to test in my previous link

attermann commented 3 years ago

@dbquarrel Adding the aforementioned key to ./linphone-app/cmake_builder/linphone_package/macos/Info.plist.in should do the trick for your own builds.

dbquarrel commented 3 years ago

Great news thank you!