postsack icon indicating copy to clipboard operation
postsack copied to clipboard

Discontinue use of the dedicated GPU on Intel MacBook Pros

Open ideologysec opened this issue 3 years ago • 6 comments

Postsack causes MacBook Pros with two GPUs to switch to the dedicated GPU, causing increased battery drain.

There's no reason I can see why it would need to do that; I presume it's a consequence of the Egui library usage.

Please investigate and fix, so battery life usage can decrease. Thanks!

ideologysec avatar Jan 09 '22 02:01 ideologysec

Hey, thanks for the comment. I'll investigate why that is happening. You're right, I suppose that's egui. I don't own a Macbook with a dedicated internal GPU, so I might ping you back for testing if I think I have a solution.

terhechte avatar Jan 09 '22 12:01 terhechte

Happy to test; also happy to dive into the code a bit more when I have a chance to see if I can isolate why it's happening.

ideologysec avatar Jan 09 '22 18:01 ideologysec

Hey, I did some research and it seems two things are required:

First: Adding this entry to the Info.plist:

<key>NSSupportsAutomaticGraphicsSwitching</key>
<string>YES</string>

https://developer.apple.com/library/archive/qa/qa1734/_index.html

Second: egui-glium needs a PR to disable requiring the dedicated GPU. The problematic line is here.

This context builder needs an additional .with_hardware_acceleration(Some(false)). See this discussion:

  • https://github.com/rust-windowing/glutin/issues/980
  • https://supermegaultragroovy.com/2016/12/10/auto-graphics-switching/

I'll look into creating a PR for this. I you want, you could create a lokal egui-glium fork, add that one line of code, add the plist entry, and check if this fixes it for you.

terhechte avatar Jan 10 '22 06:01 terhechte

So, the info.plist key is

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

which by itself only causes the app to crash.

Working on the recompilation step; will attempt to repro and report back.

ideologysec avatar Jan 11 '22 02:01 ideologysec

which by itself only causes the app to crash.

Did you try to edit the Info.plist in the app downloaded from Github or did you build it yourself? The downloaded one is Gatekeeper Notarised, so editing any of the contents (e.g. the Info.plist) will invalidate the hash and thus the notarisation. When I build it with the info plist key, it doesn't crash - at least on my M1 system.

terhechte avatar Jan 11 '22 10:01 terhechte

I've created an egui issue to see if the project is interested in implementing a fix

terhechte avatar Jan 11 '22 10:01 terhechte