Skip to content

Conversation

tsukasa-au
Copy link

Add a new configuration option use_wakelock to allow noVNC to stop the local display from going to sleep. This is especially useful with view-only sessions.

We only hold the view lock while connected to a server. We will also attempt to reacquire the wakelock if we lost it due to a visibility change (the tab becoming inactive, or during the transition into/from fullscreen).

All existing unittests have been run (with #1983 manually patched into my working directory), and the change has been manually tested in Firefox 142.

@CendioZeijlon
Copy link
Contributor

There could absolutely be cases where this can be useful, but we can't assume that all users want to prevent their screen from locking when they are connected to a session.

It should probably be an opt-in feature.

@tsukasa-au
Copy link
Author

It should probably be an opt-in feature.

100% agree.

This feature is controlled by the newly added use_wakelock option. The default value of this option is false.

If you want, I can try to plumb this configuration option into the (advanced) settings in the UI. This would also require me to add support for toggling the configuration at runtime.

@CendioZeijlon
Copy link
Contributor

If you want, I can try to plumb this configuration option into the (advanced) settings in the UI. This would also require me to add support for toggling the configuration at runtime.

That sounds great! 😃

@CendioZeijlon
Copy link
Contributor

How are you progressing on this? 🙂

@tsukasa-au
Copy link
Author

tsukasa-au commented Sep 12, 2025

Thanks for checking up on this.

I have rewritten this, but am currently working on tests. I am at a conference this/next week, but will try to get the tests finished after that.

I have pushed my new changes to this PR, but I want to clean them up a little:

  • add documentation for the new WakeLockManager class.
  • add a couple more tests
  • moving the test-related code into the test commit (the event related code, that allows the tests to track the state machine transitions).
  • move the list of valid state transitions into the test.

@tsukasa-au tsukasa-au force-pushed the add-wakelock-support branch 3 times, most recently from dff09ce to 87c7227 Compare September 12, 2025 06:02
Greg Darke added 3 commits September 12, 2025 16:05
Add a new configuration option `request_wakelock` to allow noVNC to stop
the local display from going to sleep. This is especially useful with
view-only sessions.

This new option has been added to the configuration UI, making it easier
for users to configure. When this option is changed at runtime, we will
request/release the wake lock.

We only hold the view lock while connected to a server. We will also
attempt to reacquire the wakelock if we lost it due to a visibility
change (the tab becoming inactive, or during the transition into/from
fullscreen).

All existing unittests have been run, and the change has been manually
tested in Firefox 142. Additional tests will be added later.
Add an error state to the WakeLockManager state machine. This adds a
transition that can be detected from tests (it otherwise serves no
purpose, and the system immediatly transitions back into the released
state).
Dispatch an event on each state transition inside the WakeLockManager.
This gives the unit tests something to synchronise on, allowing us to
write fast, flake-free tests.
Add tests to for both the `rfb` side (calling into the new wakelock
code), and the new wakelock class (which tracks the desired state and
how to get there).
@tsukasa-au
Copy link
Author

Actually... I ended up finding some time to hack on the last few things I wanted with this. I have updated this PR.

Not sure if you would like me to squash these down commits.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants