terhechte / postsack

Visually cluster your emails by sender, domain, and more to identify waste
MIT License
412 stars 14 forks source link

Discontinue use of the dedicated GPU on Intel MacBook Pros #32

Open ideologysec opened 2 years ago

ideologysec commented 2 years ago

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!

terhechte commented 2 years ago

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.

ideologysec commented 2 years ago

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.

terhechte commented 2 years ago

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:

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.

ideologysec commented 2 years ago

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.

terhechte commented 2 years ago

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 commented 2 years ago

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