web: Add background tick mode to keep player running in hidden tabs#23395
Merged
Conversation
Member
|
Note that we still support Firefox 94 and Safari 14.1 which do not support locks. We can either drop support for older versions or handle the missing API. |
kjarosh
reviewed
Apr 5, 2026
Member
|
It would be really nice to have that covered by tests, it's a pretty important piece of code. |
kjarosh
reviewed
Apr 10, 2026
kjarosh
reviewed
Apr 13, 2026
| if (mode === BackgroundExecutionMode.MainThread) { | ||
| this.instance.enable_background_tick_mode(); | ||
| if (this.lastActivePlayingState) { | ||
| this.startBackgroundTick(); |
Member
There was a problem hiding this comment.
It's probably worth handling the situation where we fail to create a worker here and fall back to pausing the movie.
kjarosh
reviewed
Apr 13, 2026
kjarosh
reviewed
Apr 13, 2026
kjarosh
reviewed
Apr 14, 2026
kjarosh
approved these changes
Apr 14, 2026
Member
kjarosh
left a comment
There was a problem hiding this comment.
LGTM, I'll do some tests and I think we'll be ready to merge this
|
Tested this on Habbo Flash Client , which normally disconnects after around 50 seconds when minimised or in the background. It doesn't disconnect and continues pinging websockify, no disconnections even after several hours |
Refactor tab visibility handling to support background tick mode.
Removed lastActivePlayingState variable and related logic.
Removed redundant information about pausing behavior when tab visibility changes.
Add BackgroundExecutionMode enum to define tab behavior.
Added comments to clarify the purpose of the backgroundWorker and intervalMs.
Co-authored-by: Kamil Jarosz <kjarosh256@gmail.com>
Clarify comments regarding intervalMs and code injection risk.
e29224e to
007d9b2
Compare
Member
|
Thank you! |
Hancock33
added a commit
to Hancock33/batocera.piboy
that referenced
this pull request
Apr 26, 2026
------------------------------------------------------------------------------------- azahar.mk b3ee2d8ac5a69e3bf310a67e716606dd98c4c14c # Version: Commits on Apr 21, 2026 ------------------------------------------------------------------------------------- tools/README.md: Re-updated release checklist Knew I'd forgotten something (:, ---------------------------------------------------- clk.mk 2026-04-21 # Version: Commits on Apr 21, 2026 ---------------------------------------------------- On the Thomson machines: * there is now some support for LEP and SAP files; * Memo5 images with the extension ROM are now recognised and appropriately routed; and * an attempt at emulation of the MO6 and Prodest 128 is now present, though I don't yet trust it enough for it to be a trusted target for software. You'll have to select it yourself. On the Master System: * save RAM is now present, though unretained; and * a substantial issue in the display of fixed right-hand columns has been corrected. Together these fix all issues with the recent [Road Fighter](https://www.smspower.org/Homebrew/RoadFighter-SMS) release., ------------------------------------------------------------------------------------------ duckstation.mk e3f6b48225b27acb0888cf28df4f2a48d9e8c287 # Version: Commits on Apr 21, 2026 ------------------------------------------------------------------------------------------ GameDB: Sol Divide does not support analog (#3716), ----------------------------------------------------------------------------------- eden.mk a0bb6324c0a11bf6578fe7d6951d08968fc16e12 # Version: Commits on Apr 21, 2026 ----------------------------------------------------------------------------------- [dist, android] Update translations from Transifex for Apr 21 (#3871) ---------------------------------------------------- pcsx2.mk v2.7.280 # Version: Commits on Apr 21, 2026 ---------------------------------------------------- - [GS/DX11: Clean up srv binding, srv conflict unbinding, and read only dsv clear.](PCSX2/pcsx2#14339) ------------------------------------------------------------------------------------ rpcs3.mk 1ca8ab393aacae3e5cd736427b6aea1e57d73ee2 # Version: Commits on Apr 21, 2026 ------------------------------------------------------------------------------------ sys_fs: Fix O_CREATE and O_TRUNC for BDVD, --------------------------------------------------------------------------------------- touchhle.mk 1f1b63accfa2dce85a4dc99c43cbcd5b011ffbd0 # Version: Commits on Apr 20, 2026 --------------------------------------------------------------------------------------- Remove RET_FLAG check for zero stack on dyld call workaround Games can use stubs for linked functions that are either 4, 12 or 16 bytes. The current version only runs with 12 and 16 byte stubs. Removing the RET_FLAG check ensures the workaround is applied regardless of the stub size. Change-Id: I54dbb036079b34ed2d5103593c0497d461f2e66e, ------------------------------------------------------------------------------------- ikemen.mk dece45c0e1d67586810f2f11cb40e15460e1a22b # Version: Commits on Apr 21, 2026 ------------------------------------------------------------------------------------- Merge pull request #3532 from ikemen-engine/fix3 fix: desync not ending netplay session, --------------------------------------------------------------- ruffle.mk nightly-2026-04-21 # Version: Commits on Apr 21, 2026 --------------------------------------------------------------- ## What's Changed * web: Add background tick mode to keep player running in hidden tabs by @robinmiau in ruffle-rs/ruffle#23395 * avm1: Add Value::from_usize_lossy and Value::from_u64_lossy by @kjarosh in ruffle-rs/ruffle#23476 **Full Changelog**: ruffle-rs/ruffle@nightly-2026-04-20...nightly-2026-04-21, ---------------------------------------------------------------------------------------------------- gamenetworkingsockets.mk 37f28a7971054fe762b8a4392942c7437db6da6d # Version: Commits on May 08, 2025 ---------------------------------------------------------------------------------------------------- USE_STEAMWEBRTC=ON now actually uses WebRTC instead of the native ICE client, ------------------------------------------------------------------------------------ cdogs.mk 84aa57c71381bf77aef452599641b72543822ae5 # Version: Commits on Apr 21, 2026 ------------------------------------------------------------------------------------ Poison bubble #681, ------------------------------------------------------------------------------------------ devilutionx.mk 54cb21603c84572d4a6d657aaf64b87062115071 # Version: Commits on Apr 21, 2026 ------------------------------------------------------------------------------------------ Add CPACK to build instructions for MinGW, ------------------------------------------------------------------------------------------ fallout2-ce.mk 3849b4ea17164f0059610d88ad76f7922180845a # Version: Commits on Apr 21, 2026 ------------------------------------------------------------------------------------------ Add AI agent related files to git ignore (#395) * Add AI agent related files to git ignore * Add gemini.md, -------------------------------------------------------------------------------------- omf2097.mk 34b942f1c62c9a17689c3bf45f15268764333e17 # Version: Commits on Apr 21, 2026 -------------------------------------------------------------------------------------- Allow Airborne Stasis'd Enemy to be hit (#1383) * Add rectest * Add exception to rehit mode check for stasis hits, ---------------------------------------------------------------------------------------- retroarch.mk f121e827c8e30363a0344e27a5430054bcac9f0b # Version: Commits on Apr 21, 2026 ---------------------------------------------------------------------------------------- (RWEBP) The loop filter is essentially disabled for this image (seg_lf=[4,0,0,0] with seg_abs=1 means only seg=0 MBs get a very mild filter, while seg=1/2/3 MBs have zero filtering). This means the loop filter is NOT the cause of the remaining pixel differences. The ~105 mean diff comes from the cascading effect of a small prediction/IDCT rounding difference that starts at sub-block (0,2) and compounds through all 805 macroblocks. The decoder is structurally complete with all 18 bugs fixed and a simple loop filter implementation added. The output file is ready for testing., --------------------------------------------------------------------------------------- vpinball.mk 0cdf78f35e7fe42047e65bd57044b0e848a3d167 # Version: Commits on Apr 21, 2026 --------------------------------------------------------------------------------------- iOS: fix crash when upgrading from App Store ver 10.8.1.2612, ------------------------- spirv-cross.mk NULL-NULL ------------------------- No commit found for SHA: vulkan-tmp-1.4.349, ---------------------------------------------------------------------------------------- doomretro.mk 22b90db46ee69425071a451c32e3fb5868d41204 # Version: Commits on Apr 21, 2026 ---------------------------------------------------------------------------------------- Update releasenotes.md, ------------------------------------------------------------------------------------------ xash3d-fwgs.mk e2d5bea327990ec1fe291d9a481d93ad8db33af4 # Version: Commits on Apr 21, 2026 ------------------------------------------------------------------------------------------ ref: cleanup unused functions, --------------------------------------------------------------------------------------------- libretro-citra.mk b3ee2d8ac5a69e3bf310a67e716606dd98c4c14c # Version: Commits on Apr 21, 2026 --------------------------------------------------------------------------------------------- tools/README.md: Re-updated release checklist Knew I'd forgotten something (:, --------------------------------------------------------------------------------------------- libretro-fbneo.mk 5f5c33b1b0ccf3ff623d6836a84cd032b4a876d4 # Version: Commits on Apr 21, 2026 --------------------------------------------------------------------------------------------- Make \RETRO_ERROR_MESSAGES_12\ be used correctly (#1119), -------------------------------------------------------------------------------------------------- libretro-gearsystem.mk 3df5ab5847795bdbd3f7df7495341609d4652f7d # Version: Commits on Apr 21, 2026 -------------------------------------------------------------------------------------------------- Fix BIOS loading and buffer padding, -------------------------------------------------------------------------------------------- libretro-pc98.mk 1edeb9319165a429c05bb666b925c212fee4cfec # Version: Commits on Apr 21, 2026 -------------------------------------------------------------------------------------------- 20260421, --------------------------------------------------------------------------------------------- libretro-vba-m.mk 5d9cd29130c0b60239d2ca69af7826b3ff2eee66 # Version: Commits on Apr 21, 2026 --------------------------------------------------------------------------------------------- ci: fix dangling reference warning Fix CI fail from a dangling reference warning. Signed-off-by: Rafael Kitover <rkitover@gmail.com>, ------------------------------------------------------------------------------------------- glsl-shaders.mk f374397e384b80d768ee578ac09018efc6fdeced # Version: Commits on Apr 21, 2026 ------------------------------------------------------------------------------------------- Changes to zfast-crt-composite (#558) * Update ultra-potato.glsl * Update zfast_crt_composite.glsl * Update zfast-composite.glslp, -------------------------------------------------------------------------------------------- slang-shaders.mk 6edb8f0c6c40b334f9098b2bbe94e0c67b18289e # Version: Commits on Apr 21, 2026 -------------------------------------------------------------------------------------------- some last minute fixes (#902) * Tune 2 presets, sorry * fix early exit condition,
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Related to #7289
Related to #10527
Previously, when a tab was hidden, the
requestAnimationFrameloop would stop, halting game logic and audio. This adds a background tick mode that replaces the RAF loop with a Web Worker-based tick loop when the tab becomes hidden, keeping the player running.When the tab becomes visible again, the background worker is terminated, the normal RAF loop is restarted, and the
AudioContextis explicitly resumed since browsers may auto-suspend it in background tabs.New configuration option
A new
backgroundExecutionModeconfig option controls background playback behavior:"mainThread""none"Example usage:
Notes
visibilitychangelistener no longer passes an explicitfalseas the third argument, since that is the default and every other listener in the file omits it.