[Webkit-unassigned] [Bug 255024] New: Playing Video with Intersection Observer results in "Unhandled Promise Rejection: AbortError: The operation was aborted."
bugzilla-daemon at webkit.org
bugzilla-daemon at webkit.org
Wed Apr 5 02:29:29 PDT 2023
https://bugs.webkit.org/show_bug.cgi?id=255024
Bug ID: 255024
Summary: Playing Video with Intersection Observer results in
"Unhandled Promise Rejection: AbortError: The
operation was aborted."
Product: WebKit
Version: Safari 16
Hardware: All
OS: iOS 16
Status: NEW
Severity: Critical
Priority: P2
Component: JavaScriptCore
Assignee: webkit-unassigned at lists.webkit.org
Reporter: contact at benfrain.com
This works without problem in Chrome and Firefox. Fails on Safari up to, and including Release 166 (Safari 16.4, WebKit 18616.1.6.11).
The error in the console is "Unhandled Promise Rejection: AbortError: The operation was aborted."
Test page: https://benfrain.com/playground/video-stop-start/index.html
What should happen is that the videos pause as they are scrolled past and play when they are scrolled into view. This mechanism is achieved with this code:
```
function playPauseVideo() {
let videos = document.querySelectorAll("video");
videos.forEach((video) => {
// We can only control playback without insteraction if video is mute
video.muted = true;
// Play is a promise so we need to check we have it
let playPromise = video.play();
if (playPromise !== undefined) {
playPromise.then((_) => {
let observer = new IntersectionObserver(
(entries) => {
entries.forEach((entry) => {
if (entry.intersectionRatio !== 1 && !video.paused) {
video.pause();
} else if (video.paused) {
video.play();
}
});
},
{ threshold: 0.2 }
);
observer.observe(video);
});
}
});
}
```
I am unsure if this is a bug or a missing piece of requisite (undocumented) code that only Safari needs?
--
You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-unassigned/attachments/20230405/82b3ba43/attachment-0001.htm>
More information about the webkit-unassigned
mailing list