Browser Mechanics

Tab Throttling: How Chrome’s Background Throttling Affects Idle Canvas Games

A deep dive into browser lifecycle states, requestAnimationFrame suspension, CPU wake-up budgets, and techniques to prevent physics glitches when tabs are restored.

👤 By Sanket Sharma
📅 Published: May 26, 2026
⏱️ Reading Time: 11 min
Status: Browser Internals Fact-Checked

Introduction: The Hidden Pause Button

Modern web browsers are marvels of software engineering. Rather than simply displaying static documents, they function as robust, multi-process operating systems in miniature. A single browser window can run dozens of isolated tabs, each running complex, highly dynamic applications. However, this capabilities comes at a cost: **system resources**. Left unmanaged, multiple open tabs running JavaScript loops, physics engines, and graphics rendering will quickly drain your laptop’s battery, saturate your system's RAM, and cause your CPU to run hot.

To protect system stability and maximize battery life, browser engines (like Chrome's Blink, Safari's WebKit, and Firefox's Gecko) implement strict policies called Background Tab Throttling. The moment you switch away from a game tab to check your email or open a work document, the browser silently puts your game to sleep. While this resource preservation is excellent for battery life, it is a major headache for browser games, especially **idle or incremental games** that rely on continuous progress. This article explores the mechanics of background throttling and provides the architectural solutions needed to build robust games that handle background states gracefully.

The Mechanics of Throttling: What Happens When a Tab Goes Dark

When a tab loses focus (meaning it is no longer the active window and is hidden behind another tab), the browser moves it through a series of lifecycle states defined by the **Page Lifecycle API**. During this transition, several rendering and scheduling changes occur:

1. Complete Suspension of requestAnimationFrame

The most immediate and severe throttling measure is the complete suspension of the requestAnimationFrame loop. Because the browser knows the user cannot see the canvas, it shuts down the repaint cycle entirely, dropping the update rate of rAF to 0Hz. Your main game loop stops running. For visual-centric games like Sliding Puzzle or Memory Match, this is completely appropriate — there is no reason to waste GPU cycles rendering frames that will never be displayed.

2. Timer Interval Clamping

If developers try to bypass rAF by using legacy timers like setInterval or setTimeout to run background calculations, they run into a second barrier. Modern browsers clamp the minimum firing interval of all background timers. Instead of firing every 16ms, background timers are throttled to a minimum interval of **1,000 milliseconds (1Hz)**. In Chrome, if a tab has been inactive for several minutes and is not playing audio, it may be throttled even further, limited to a CPU wake-up budget of just **once every 60 seconds (0.016Hz)**.

3. Audio Context Suspension

To prevent annoying background noise, browser engines automatically freeze the **Web Audio API** state when a page is hidden. While this prevents unexpected noise, it can desynchronize your game's audio playback from its physics engine if the two systems are not linked to a unified clock source.

Browser Tab State rAF Execution Rate Timer Accuracy (setTimeout) Web Worker Performance Web Audio Status
Active & Visible Synchronized to V-Sync (60Hz - 144Hz) Millisecond precision (4ms floor) Full CPU priority Fully Active
Hidden / Background Suspended (0Hz) Clamped to 1,000ms (1Hz) Slightly throttled, but runs continuously Muted & Suspended
Background (with Audio Playing) Suspended (0Hz) Clamped to 1,000ms (1Hz) Standard Priority Active (Allows music playlists to continue)
Discarded / Sleeping Suspended (0Hz) Frozen (0Hz) Suspended Suspended

How Tab Throttling Breaks Game Physics: The Massive Delta Time Trap

Beyond freezing progress, tab throttling can introduce game-breaking bugs when a player returns to the game tab. This is caused by how games calculate time steps using **Delta Timing**.

As discussed in our article on requestAnimationFrame game loops, developers use the elapsed time between frames ($\Delta t$) to scale game physics. Under active play, $\Delta t$ is a steady 16.67ms. However, if a player switches tabs for 10 minutes and then returns, the next requestAnimationFrame callback receives a timestamp that is **600,000 milliseconds** greater than the previous frame.

⚠️ The Physics Explosion:

If your physics engine calculates character movement using a simple linear equation:

Position_new = Position_old + (Velocity * dt)

A massive dt value of 600,000ms will multiply the character's velocity by an enormous factor. When the page is reactivated, the character instantly teleports thousands of pixels across the screen, passing clean through solid walls and flying off the game board. This physics glitch ruins the game session.

Engineering Workarounds: Building Robust Background Support

To build a game that handles background throttling gracefully, developers utilize two primary architectural patterns:

1. Web Workers: Running Off the Main Thread

The most elegant way to bypass background throttling is to run your game's calculation logic inside a **Web Worker**. Web Workers are separate JavaScript execution threads that run independently of the browser's main window thread.

Because Web Workers do not have access to the Document Object Model (DOM) or user interface elements, the browser does not throttle them nearly as aggressively. While rAF is suspended on the main thread, a Web Worker can continue executing game state loops, calculations, and math at high frequencies in the background, communicating updates back to the main thread via message passing (postMessage()) whenever the player refocuses the tab.

2. Epoch Time Synchronization (Offline Curation)

For incremental, tycoon, or idle games, running a continuous background loop is often unnecessary and wasteful. Instead, developers can use a technique called **Offline Curation** via system timestamps:

  1. Detect Tab Visibility Changes: Listen to the visibilitychange event on the document.

    document.addEventListener('visibilitychange', handleVisibilityChange);

  2. Record Exit Time: When the page visibility state changes to hidden, save the exact epoch time in milliseconds using Date.now() or performance.now().
  3. Calculate Elapsed Duration: When the visibility state returns to visible, subtract the saved exit time from the current time to find the exact number of seconds the player was away.
  4. Fast-Forward Game State: Instead of running a real-time loop for those 10 minutes, pass that elapsed duration to a specialized calculation function that instantly computes the resources, scores, or states the player earned while away. Reset your delta time clock to zero to prevent the physics engine from exploding.
💻 Elegant Visibility Event Handling Template

let exitTimestamp = 0;

function handleVisibilityChange() {
    if (document.hidden) {
        // Page went background; store timestamp
        exitTimestamp = Date.now();
        pauseGameAudio();
    } else {
        // Page returned to active view
        const timeElapsed = Date.now() - exitTimestamp;
        // Process offline progress or clamp delta times
        syncOfflineProgress(timeElapsed);
        // Force-reset the delta timing clock
        lastTime = performance.now();
        resumeGameAudio();
    }
}

Conclusion: Designing for the Real Web

Background tab throttling is a browser reality designed to protect user experience and hardware health. Rather than fighting this throttling, web game developers should design their game architectures to work with it. By utilizing system time synchronization and clamping physics delta calculations, you ensure your games are robust, stable, and highly professional. Explore how our curated games handle window refocusing by opening our grid-based Sliding Puzzle or testing your mental quickness in Pattern Recognition, and watch how smoothly they pause and resume your play sessions.

💻
Sanket Sharma
Principal Web Systems Engineer

Sanket Sharma is an expert in browser architecture, web performance, and HTML5 rendering technologies. He spends his days analyzing paint cycles, frame budgets, and optimizing low-level WebGL and Canvas implementations.