Tyrrrz / LightBulb

Reduces eye strain by adjusting screen gamma based on the current time
MIT License
2.23k stars 141 forks source link

Unload UI when it's not in use, to reduce the performance impact even further #328

Open Tyrrrz opened 1 month ago

Tyrrrz commented 1 month ago

As a result of the discussion that took place in #273, it became apparent that the biggest culprit in LightBulb's passive CPU/RAM consumption is the GUI rendering loop, which is active even when the application is hidden to tray. To deal with that, we can try to detach the UI from the core gamma manipulation loop and only load the UI (and the associated resources) when needed.

Ideally, we should try to achieve this within a single process. Would need to investigate if Avalonia supports shutting down the application without exiting the process. If so, we may be able to shut down and re-start multiple application lifetimes within a single process lifetime, which should do the trick.

Worst case scenario, we would have to split the application into two separate processes (headless backend and on-demand frontend) and figure out a way to make them communicate with each other. This is possible, but significantly more difficult.

e-t-l commented 5 days ago

two separate processes (headless backend and on-demand frontend) and figure out a way to make them communicate with each other. This is possible, but significantly more difficult

Granted, I have zero familiarity with Avalonia, but I suspect that two separate processes will ultimately be much simpler, both to create and to maintain/update. There are tons of applications that have multiple processes, and Inter-Process Communications are not a new concept. I guarantee You may even want the frontend to be a child process of the backend, since the backend should be persistent anyway.