Skip to content

Conversation

@iqnite
Copy link
Contributor

@iqnite iqnite commented Mar 22, 2023

Resolves #5836

Changes

Add an option to the pause addon to pause the project when the tab is not focused.

Reason for changes

Many users would like the project to be paused when they enter another window, e. g. to not lose progress in runner games.

Tests

It only pauses once when you change the addon's settings. Can anyone look at the code?

  • Basic addon functionality
  • Auto-pause (fixed thanks to @Samq64)
  • Auto-pause in the editor
  • Dynamic enable support
  • Dynamic disable support

Co-authored-by: Chiroyce <97374054+Chiroyce1@users.noreply.github.com>
@WorldLanguages
Copy link
Member

Should the project automatically unpause when the user comes back to the tab?

@Samq64
Copy link
Member

Samq64 commented Mar 24, 2023

Guys, this addon has bigger problems than the wrong name. It doesn't work in first place.

Try adding

if (addon.settings.get("auto-pause")) document.addEventListener("focusout", setPaused(true));

above the settings change event listener.

@WorldLanguages
Copy link
Member

@Samq64 You meant () => setPaused(true) instead of just setPaused(true)

@Samq64
Copy link
Member

Samq64 commented Mar 26, 2023

@Samq64 You meant () => setPaused(true) instead of just setPaused(true)

Yeah, thanks for catching that.

@iqnite
Copy link
Contributor Author

iqnite commented Mar 27, 2023

@Samq64 You meant () => setPaused(true) instead of just setPaused(true)

What's the difference?

@DNin01 DNin01 added type: enhancement New feature for the project scope: addon Related to one or multiple addons labels Apr 2, 2023
@iqnite iqnite marked this pull request as ready for review April 13, 2023 10:31
Copy link
Member

@Samq64 Samq64 left a comment

Choose a reason for hiding this comment

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

Should the project automatically resume when the setting is dynamically disabled?

@iqnite
Copy link
Contributor Author

iqnite commented Apr 13, 2023

Should the project automatically resume when the setting is dynamically disabled?

No. That would only add extra complication. And if the user manually pauses and then disables the setting, the project would resume, even if it shouldn't.

Co-authored-by: Samq64 <81489795+Samq64@users.noreply.github.com>
@Samq64 Samq64 added the status: needs review PR needs 1 more approval label May 1, 2023
@iqnite iqnite changed the title Auto pause on focus leave pause: AUtomatically pause project when the page is not focused Nov 9, 2023
@iqnite iqnite changed the title pause: AUtomatically pause project when the page is not focused pause: Automatically pause project when the page is not focused Nov 21, 2023
@Samq64 Samq64 added status: abandoned PR is no longer being actively worked on and removed status: needs review PR needs 1 more approval labels Mar 29, 2025
Copy link
Member

@DNin01 DNin01 left a comment

Choose a reason for hiding this comment

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

I should probably mention that pausing could affect Cloud multiplayer games.

By manually pausing you can often mess up projects with online multiplayer already (cause things like multiple players claiming the same cloud slot). However, now that we can automatically pause the project for the user, we can cause Cloud issues ourselves. If we do, that's on us and it could be a problem.

So, if we detect Cloud activity that follows certain patterns, we shouldn't pause those projects automatically.

If we can't do that, don't worry too much — connection issues can also trigger the same problems, perhaps more often than we would.

@iqnite
Copy link
Contributor Author

iqnite commented Jun 9, 2025

@DNin01 your review adds a new perspective I didn't think about. Maybe we should add an option to prevent pause for projects with cloud variables, maybe even mitigations for the addon itself (not just this option)?

@DNin01
Copy link
Member

DNin01 commented Jun 9, 2025

maybe even mitigations for the addon itself (not just this option)?

Indeed, we could consider entirely disabling the pause function on these types of projects.

@iqnite
Copy link
Contributor Author

iqnite commented Jun 10, 2025

Indeed, we could consider entirely disabling the pause function on these types of projects.

I wouldn't say disabling though. People with the knowledge could still bypass the restriction (via devtools). Maybe we should add a "Allow pausing on projects with cloud variables" setting and mark it as Dangerous?

@Samq64 Samq64 removed the status: abandoned PR is no longer being actively worked on label Jun 10, 2025
@DNin01
Copy link
Member

DNin01 commented Sep 8, 2025

Whaddya say we just don't auto-pause if cloud data activity (send/receive) occurred on the cloud WebSocket connection in the last 15 seconds? That should mitigate most of the issues potentially introduced by pausing those projects.

@iqnite
Copy link
Contributor Author

iqnite commented Sep 8, 2025

don't auto-pause if cloud data activity (send/receive) occurred on the cloud WebSocket connection in the last 15 seconds?

Sounds good, maybe also add a notice in the settings.

@DNin01
Copy link
Member

DNin01 commented Sep 13, 2025

Whaddya say we just don't auto-pause if cloud data activity (send/receive) occurred on the cloud WebSocket connection in the last 15 seconds? That should mitigate most of the issues potentially introduced by pausing those projects.

Done in #8555.

@iqnite iqnite closed this Sep 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

scope: addon Related to one or multiple addons type: enhancement New feature for the project

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Auto-pause on focus leave

6 participants