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 5 times, most recently from 63a63d1 to 428b1f7 Compare September 12, 2025 07:50
@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.

@tsukasa-au
Copy link
Author

This change should be in a good state to review.

@samhed
Copy link
Member

samhed commented Oct 21, 2025

Works great! Tested on Android 15

I would suggest we put this option as ON by default.

@CendioOssman
Copy link
Member

I would suggest we put this option as ON by default.

What's your thinking here? I'd consider it very misbehaved for any other application to not respect my screen timeout. Applications that are passively used are normally the exception, not the rule.

@samhed
Copy link
Member

samhed commented Nov 5, 2025

I would suggest we put this option as ON by default.

What's your thinking here? I'd consider it very misbehaved for any other application to not respect my screen timeout. Applications that are passively used are normally the exception, not the rule.

I would personally expect a remote desktop client to keep my screen awake. But perhaps that isnt the case for everyone.

If we dont want to enable this by default, I would at least move it out of "advanced".

@CendioOssman
Copy link
Member

In what way do you think using remote applications differs from using local ones? Perhaps there is some room for automation here.

@samhed
Copy link
Member

samhed commented Nov 14, 2025

In what way do you think using remote applications differs from using local ones? Perhaps there is some room for automation here.

I use desktop applications and mobile applications differently. In my mind the norm is to have a significantly longer screen timeout, if any, on desktop. While a short timeout is probably quite common on mobile.

When connecting to a remote desktop via noVNC I'd like things to act more like a desktop. I'd be very annoyed if my desktop screen automatically locked after 30 seconds of inactivity.

@tsukasa-au tsukasa-au force-pushed the add-wakelock-support branch 2 times, most recently from 7ece518 to 1719d4b Compare November 17, 2025 05:36
@tsukasa-au
Copy link
Author

I would personally expect a remote desktop client to keep my screen awake. But perhaps that isnt the case for everyone.

If we dont want to enable this by default, I would at least move it out of "advanced".

For the moment, I will keep the default set to false as it is quite easy to override when deploying noVNC, and the setting is saves on the client.

As for moving it out of "advanced", I can if you want... I am just very hesitant to move it, given that most other settings are in "advanced" (like show_dot, or the path settings).

@samhed
Copy link
Member

samhed commented Dec 3, 2025

For the moment, I will keep the default set to false as it is quite easy to override when deploying noVNC, and the setting is saves on the client.

As for moving it out of "advanced", I can if you want... I am just very hesitant to move it, given that most other settings are in "advanced" (like show_dot, or the path settings).

I'm fine with that. I understand your reasoning for keeping it set to false by default. Having it under advanced or not isn't a big deal. Given that @CendioOssman is satisfied with the review comments, I think we are ready to merge!

Copy link
Member

@CendioOssman CendioOssman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are some minor details left. And the linter isn't happy.

Add a new configuration option `keep_device_awake` 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 145. 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 tsukasa-au force-pushed the add-wakelock-support branch from 1719d4b to 988e9da Compare December 6, 2025 08:07
@tsukasa-au
Copy link
Author

There are some minor details left.

Done.

And the linter isn't happy.

I believe I have fixed these now.

Copy link
Member

@CendioOssman CendioOssman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me!

Thanks for your work!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants