Skip to content

Sleep Guard#1109

Open
Tyr3al wants to merge 6 commits intorust-av:masterfrom
Tyr3al:feature/sleep-prevention
Open

Sleep Guard#1109
Tyr3al wants to merge 6 commits intorust-av:masterfrom
Tyr3al:feature/sleep-prevention

Conversation

@Tyr3al
Copy link
Copy Markdown
Contributor

@Tyr3al Tyr3al commented Aug 9, 2025

I had the problem, that av1an encodes would not run through overnight, as my system would simply go into sleep - even though an encoding job was already running. In my case that would be Arch Linux. It seems like other people have this issue as well, see #889.

This PR ads a sleep guard to av1an that should prevent sleeping while an encode is running. I first tried to use the suggested crate keepawake as suggested in the Issue, but it pulled far more dependencies as expected, which were also outdated.

I sat down to write implementations for linux, windows and macOS myself, that should prevent the system from going into sleep.

I have tested the linux and the windows implementations. The macOS implementation is untested, as I was not able to get av1an to start an encoding job there.

Screenshot Linux (KDE Plasma):
image

Screenshot Windows 10:
Unbenannt

@Tyr3al Tyr3al changed the title Sleep Guard Draft: Sleep Guard Aug 9, 2025
@emrakyz
Copy link
Copy Markdown
Collaborator

emrakyz commented Aug 9, 2025

Thanks for your PR!

This seems important but can't you handle it on the OS level instead with much less complexity?

And screen locking would be a needed functionality while it runs.

@emrakyz emrakyz added the enhancement New feature or request label Aug 9, 2025
@Tyr3al Tyr3al force-pushed the feature/sleep-prevention branch from eb72865 to e469619 Compare August 10, 2025 08:01
@codecov
Copy link
Copy Markdown

codecov Bot commented Aug 10, 2025

Codecov Report

❌ Patch coverage is 36.00000% with 16 lines in your changes missing coverage. Please review.
✅ Project coverage is 62.39%. Comparing base (f65e23e) to head (1c4f74d).
⚠️ Report is 69 commits behind head on master.

Files with missing lines Patch % Lines
av1an-core/src/sleep_guard.rs 36.00% 16 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1109      +/-   ##
==========================================
- Coverage   62.49%   62.39%   -0.11%     
==========================================
  Files          23       24       +1     
  Lines        6346     6371      +25     
==========================================
+ Hits         3966     3975       +9     
- Misses       2380     2396      +16     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@Tyr3al Tyr3al changed the title Draft: Sleep Guard Sleep Guard Aug 10, 2025
@Tyr3al
Copy link
Copy Markdown
Contributor Author

Tyr3al commented Aug 10, 2025

This seems important but can't you handle it on the OS level instead with much less complexity?

AFAIK, there are some things you can do outside of the application to prevent sleep. This PR is rather a convenience function, so that you do not have to call av1an from another wrapper. E.g. in linux:

systemd-inhibit --why="Prevent sleep during execution" --what=sleep ./av1an

And screen locking would be a needed functionality while it runs.

The screenshot may be misleading. The sleep inhibitors I'm creating only prevent sleep. The system is still able to turn off and lock the screens.

@Tyr3al Tyr3al force-pushed the feature/sleep-prevention branch from 01752bd to 1c4f74d Compare August 10, 2025 08:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants