Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[visionOS] YouTube audio in background tab stops after looking away f…
…rom Safari for one minute https://bugs.webkit.org/show_bug.cgi?id=261050 rdar://113459873 Reviewed by Tim Horton. On visionOS, scenes are backgrounded after they are out of the user's field of view for one minute. This is similar to iPadOS, where the device is locked when looking away from the screen for two minutes (configurable via Settings). However, unlike iPadOS, visionOS has no device-level idle state, as the display is always on when the device is in use, and always off when it is not. The only way to prevent the aforementioned scene backgrounding is to disable the application-level idle timer. This timer is currently only disabled when the document containing a playing media element is visible. If the media element is playing and in a hidden document (as is the case in a background tab), a system sleep assertion is taken instead. This assertion has no meaning as there is no "user-idle" state while the device is in use. Consequently, the idle timer is active, the scene gets backgrounded after one minute, and playback is paused by WebKit as the notification is received. To fix, ensure the idle timer remains disabled when media is playing in a hidden document. * Source/WTF/wtf/PlatformHave.h: * Source/WebCore/html/HTMLMediaElement.cpp: (WebCore::HTMLMediaElement::shouldDisableSleep const): * Source/WebCore/html/HTMLMediaElement.h: Drive-by: Specify the smallest underlying type for the `SleepType` enum class. Canonical link: https://commits.webkit.org/267615@main
- Loading branch information