Technology

How Picture-in-Picture Keeps Your Screen Awake (The Clever Trick Explained)

6 min read ยท January 2025 ยท By the KeepAwake team

If you look at how KeepAwake works under the hood, you'll notice it uses multiple techniques simultaneously โ€” and one of them is Picture-in-Picture (PiP) video. Why does a floating video window prevent your computer from sleeping? The answer is more interesting than it might seem.

What Is Picture-in-Picture in This Context?

Picture-in-Picture is a browser feature that lets you detach a video element from a web page into a floating overlay window that stays on top of other windows. You've probably seen it on YouTube โ€” the small video that follows you as you navigate away from the page.

KeepAwake generates a small, silent video element (a canvas-based animation rendered as a video stream) and places it in a PiP window. This 1ร—1 pixel window floats invisibly in a corner of your screen. To your operating system, an active PiP session signals that media is actively playing โ€” and that signal has a direct effect on sleep behavior.

Why Operating Systems Treat Active Media Differently

Operating systems have always needed to handle the "movie watching" use case โ€” a user sitting still, not touching keyboard or mouse, watching a two-hour film. Without special handling, the OS would sleep the screen halfway through every movie.

The solution operating systems implemented: applications that are playing media can register themselves as "active media sessions" with the OS. When an active media session is registered, the OS suppresses its display sleep and idle detection timers. Windows does this through the Windows Media Session API; macOS does it through AVFoundation and MediaRemote.

Browsers โ€” Chrome, Edge, Firefox, and Safari โ€” all participate in this system. When a browser has an active video element playing (even a silent, invisible one), it registers an active media session with the OS. The OS responds by keeping the display on and the system active, just as it would for Netflix or VLC.

Picture-in-Picture Is More Persistent Than a Regular Video Element

A regular video element playing in a browser tab works to suppress sleep, but it has a vulnerability: if the browser tab is backgrounded, throttled, or if Chrome's background tab optimization kicks in, the video element may be paused or throttled. When that happens, the media session registration lapses, and the OS may resume sleep behavior.

Picture-in-Picture bypasses this entirely. A PiP session is architecturally separate from the browser tab that created it โ€” it persists as an active window even when the originating tab is backgrounded, minimized, or throttled. The OS sees an active, playing PiP session and maintains the wake state regardless of what happens to the browser tab.

This is why PiP is a more reliable technique than simply playing a video in a background tab, and why KeepAwake uses it as one of its five simultaneous approaches.

Browser Support for PiP as a Keep-Awake Technique

The Picture-in-Picture API is supported in Chrome, Edge, Firefox, and Safari. However, the behavior around automatic PiP activation varies โ€” most browsers require a user gesture (a click) to initiate PiP for the first time. KeepAwake handles this by activating PiP when you click the Start button, satisfying the user gesture requirement.

Safari on iOS has restrictions on background PiP behavior that can affect reliability on mobile โ€” but for desktop use cases (keeping Teams active on a work laptop), Safari on macOS works well.

Why Five Techniques Are Better Than One

KeepAwake runs Wake Lock, Picture-in-Picture, Web Worker heartbeat, AudioContext, and Canvas animation simultaneously. Why all five?

Each technique has failure cases. Wake Lock requires Chrome or Edge for full reliability. PiP requires video support and a user gesture. AudioContext can be suspended by browsers in low-power mode. Canvas animation can be throttled in deeply backgrounded tabs. The Web Worker heartbeat can be throttled on older devices.

Running all five means that even if two or three fail in a specific environment โ€” an older browser, an aggressive corporate power management policy, a low-power laptop mode โ€” the remaining techniques continue to suppress OS sleep. The result is that KeepAwake works reliably across the full range of corporate and personal environments without needing configuration.

What You See vs What the OS Sees

From your perspective, when KeepAwake is running with PiP active, you might see a tiny floating window in a corner of your screen โ€” or you might not notice it at all if it's positioned off-screen or behind other windows. From the OS's perspective, there's an active media session, an active wake lock request, and ongoing browser activity โ€” all of which combine to suppress every sleep and idle trigger that Teams and Slack use to set your status to Away.

See it in action: KeepAwake activates PiP automatically when you click Start. The technique dashboard shows its status โ€” green means your OS is receiving the media session signal.