Changeset 217310 in webkit
- Timestamp:
- May 23, 2017, 5:01:44 PM (8 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r217298 r217310 1 2017-05-15 Matt Rajca <mrajca@apple.com> 2 3 Replace autoplay events that fire at navigation with a DidAutoplayMediaPastThreshold event. 4 https://bugs.webkit.org/show_bug.cgi?id=172138 5 6 Reviewed by Alex Christensen. 7 8 The current autoplay signals that are fired at navigation may not get delivered to the UIProcess if the WebPage is close()'ed around 9 this time. This patch simplifies this and just notifies clients if a media element has played past a threshold. 10 11 Updated API tests. 12 13 * html/HTMLMediaElement.cpp: 14 (WebCore::HTMLMediaElement::playbackProgressTimerFired): 15 (WebCore::HTMLMediaElement::mediaPlayerTimeChanged): 16 (WebCore::HTMLMediaElement::stopWithoutDestroyingMediaPlayer): 17 (WebCore::HTMLMediaElement::userDidInterfereWithAutoplay): 18 * page/AutoplayEvent.h: 19 1 20 2017-05-23 Dean Jackson <dino@apple.com> 2 21 -
trunk/Source/WebCore/html/HTMLMediaElement.cpp
r217223 r217310 166 166 static const Seconds ScanRepeatDelay { 1.5_s }; 167 167 static const double ScanMaximumRate = 8; 168 static const double AutoplayInterferenceTimeThreshold = 10; 168 169 169 170 static const Seconds hideMediaControlsAfterEndedDelay { 6_s }; … … 3574 3575 m_mediaSource->monitorSourceBuffers(); 3575 3576 #endif 3577 3578 if (!seeking() && m_playbackWithoutUserGesture == PlaybackWithoutUserGesture::Started && currentTime() - m_playbackWithoutUserGestureStartedTime->toDouble() > AutoplayInterferenceTimeThreshold) { 3579 handleAutoplayEvent(AutoplayEvent::DidAutoplayMediaPastThresholdWithoutUserInterference); 3580 setPlaybackWithoutUserGesture(PlaybackWithoutUserGesture::None); 3581 } 3576 3582 } 3577 3583 … … 4473 4479 addBehaviorRestrictionsOnEndIfNecessary(); 4474 4480 4475 if (m_playbackWithoutUserGesture == PlaybackWithoutUserGesture::Started)4476 handleAutoplayEvent(AutoplayEvent::DidEndMediaPlaybackWithoutUserInterference);4477 4478 4481 setPlaybackWithoutUserGesture(PlaybackWithoutUserGesture::None); 4479 4482 } … … 5234 5237 setPausedInternal(true); 5235 5238 m_mediaSession->clientWillPausePlayback(); 5236 5237 switch (m_playbackWithoutUserGesture) {5238 case PlaybackWithoutUserGesture::Started:5239 handleAutoplayEvent(AutoplayEvent::DidEndMediaPlaybackWithoutUserInterference);5240 break;5241 case PlaybackWithoutUserGesture::Prevented:5242 handleAutoplayEvent(AutoplayEvent::UserNeverPlayedMediaPreventedFromPlaying);5243 break;5244 case PlaybackWithoutUserGesture::None:5245 break;5246 }5247 5239 5248 5240 setPlaybackWithoutUserGesture(PlaybackWithoutUserGesture::None); … … 7209 7201 7210 7202 // Only consider interference in the first 10 seconds of automatic playback. 7211 if (currentTime() - m_playbackWithoutUserGestureStartedTime->toDouble() > 10)7203 if (currentTime() - m_playbackWithoutUserGestureStartedTime->toDouble() > AutoplayInterferenceTimeThreshold) 7212 7204 return; 7213 7205 -
trunk/Source/WebCore/page/AutoplayEvent.h
r215771 r217310 31 31 DidPreventMediaFromPlaying, 32 32 DidPlayMediaPreventedFromPlaying, 33 Did EndMediaPlaybackWithoutUserInterference,33 DidAutoplayMediaPastThresholdWithoutUserInterference, 34 34 UserDidInterfereWithPlayback, 35 UserNeverPlayedMediaPreventedFromPlaying,36 35 }; 37 36 -
trunk/Source/WebKit2/ChangeLog
r217307 r217310 1 2017-05-15 Matt Rajca <mrajca@apple.com> 2 3 Replace autoplay events that fire at navigation with a DidAutoplayMediaPastThreshold event. 4 https://bugs.webkit.org/show_bug.cgi?id=172138 5 6 Reviewed by Alex Christensen. 7 8 Updated auto-play event types. 9 10 * Shared/WebCoreArgumentCoders.h: 11 * UIProcess/API/C/WKPage.cpp: 12 (WKPageSetPageUIClient): 13 * UIProcess/API/C/WKPageUIClient.h: 14 1 15 2017-05-23 Chris Dumez <cdumez@apple.com> 2 16 -
trunk/Source/WebKit2/Shared/WebCoreArgumentCoders.h
r216967 r217310 703 703 WebCore::AutoplayEvent::DidPreventMediaFromPlaying, 704 704 WebCore::AutoplayEvent::DidPlayMediaPreventedFromPlaying, 705 WebCore::AutoplayEvent::DidEndMediaPlaybackWithoutUserInterference, 706 WebCore::AutoplayEvent::UserDidInterfereWithPlayback, 707 WebCore::AutoplayEvent::UserNeverPlayedMediaPreventedFromPlaying 705 WebCore::AutoplayEvent::DidAutoplayMediaPastThresholdWithoutUserInterference, 706 WebCore::AutoplayEvent::UserDidInterfereWithPlayback 708 707 >; 709 708 }; -
trunk/Source/WebKit2/UIProcess/API/C/WKPage.cpp
r217228 r217310 2266 2266 { 2267 2267 switch (event) { 2268 case WebCore::AutoplayEvent::Did EndMediaPlaybackWithoutUserInterference:2269 return kWKAutoplayEventDid EndMediaPlaybackWithoutUserInterference;2268 case WebCore::AutoplayEvent::DidAutoplayMediaPastThresholdWithoutUserInterference: 2269 return kWKAutoplayEventDidAutoplayMediaPastThresholdWithoutUserInterference; 2270 2270 case WebCore::AutoplayEvent::DidPlayMediaPreventedFromPlaying: 2271 2271 return kWKAutoplayEventDidPlayMediaPreventedFromAutoplaying; … … 2274 2274 case WebCore::AutoplayEvent::UserDidInterfereWithPlayback: 2275 2275 return kWKAutoplayEventUserDidInterfereWithPlayback; 2276 case WebCore::AutoplayEvent::UserNeverPlayedMediaPreventedFromPlaying:2277 return kWKAutoplayEventUserNeverPlayedMediaPreventedFromPlaying;2278 2276 } 2279 2277 -
trunk/Source/WebKit2/UIProcess/API/C/WKPageUIClient.h
r217101 r217310 52 52 kWKAutoplayEventDidPreventFromAutoplaying, 53 53 kWKAutoplayEventDidPlayMediaPreventedFromAutoplaying, 54 kWKAutoplayEventDid EndMediaPlaybackWithoutUserInterference,54 kWKAutoplayEventDidAutoplayMediaPastThresholdWithoutUserInterference, 55 55 kWKAutoplayEventUserDidInterfereWithPlayback, 56 kWKAutoplayEventUserNeverPlayedMediaPreventedFromPlaying,57 56 }; 58 57 typedef uint32_t WKAutoplayEvent; -
trunk/Tools/ChangeLog
r217303 r217310 1 2017-05-15 Matt Rajca <mrajca@apple.com> 2 3 Replace autoplay events that fire at navigation with a DidAutoplayMediaPastThreshold event. 4 https://bugs.webkit.org/show_bug.cgi?id=172138 5 6 Reviewed by Alex Christensen. 7 8 Added API tests. 9 10 * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj: 11 * TestWebKitAPI/Tests/WebKit2/js-autoplay-audio.html: Added. 12 * TestWebKitAPI/Tests/WebKit2Cocoa/WebsitePolicies.mm: 13 (TEST): 14 * TestWebKitAPI/Tests/WebKit2Cocoa/silence-long.m4a: Added. 15 1 16 2017-05-23 Simon Fraser <simon.fraser@apple.com> 2 17 -
trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj
r217296 r217310 572 572 C99BDF891E80980400C7170E /* autoplay-zero-volume-check.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = C99BDF881E8097E300C7170E /* autoplay-zero-volume-check.html */; }; 573 573 C9B1043E1ECF9848000520FA /* autoplay-inherits-gesture-from-document.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = C9B1043D1ECF9832000520FA /* autoplay-inherits-gesture-from-document.html */; }; 574 C9B4AD2A1ECA6EBE00F5FEA0 /* silence-long.m4a in Copy Resources */ = {isa = PBXBuildFile; fileRef = C9B4AD291ECA6EA500F5FEA0 /* silence-long.m4a */; }; 575 C9B4AD2C1ECA6F7F00F5FEA0 /* js-autoplay-audio.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = C9B4AD2B1ECA6F7600F5FEA0 /* js-autoplay-audio.html */; }; 574 576 C9BF06EF1E9C132500595E3E /* autoplay-muted-with-controls.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = C9BF06EE1E9C130400595E3E /* autoplay-muted-with-controls.html */; }; 575 577 C9C60E651E53A9DC006DA181 /* autoplay-check-frame.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = C9C60E631E53A9BA006DA181 /* autoplay-check-frame.html */; }; … … 696 698 C9B1043E1ECF9848000520FA /* autoplay-inherits-gesture-from-document.html in Copy Resources */, 697 699 3FCC4FE81EC4E8CA0076E37C /* PictureInPictureDelegate.html in Copy Resources */, 700 C9B4AD2C1ECA6F7F00F5FEA0 /* js-autoplay-audio.html in Copy Resources */, 701 C9B4AD2A1ECA6EBE00F5FEA0 /* silence-long.m4a in Copy Resources */, 698 702 55226A2F1EBA44B900C36AD0 /* large-red-square-image.html in Copy Resources */, 699 703 5797FE331EB15AB100B2F4A0 /* navigation-client-default-crypto.html in Copy Resources */, … … 1462 1466 C99BDF881E8097E300C7170E /* autoplay-zero-volume-check.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "autoplay-zero-volume-check.html"; sourceTree = "<group>"; }; 1463 1467 C9B1043D1ECF9832000520FA /* autoplay-inherits-gesture-from-document.html */ = {isa = PBXFileReference; lastKnownFileType = text.html; path = "autoplay-inherits-gesture-from-document.html"; sourceTree = "<group>"; }; 1468 C9B4AD291ECA6EA500F5FEA0 /* silence-long.m4a */ = {isa = PBXFileReference; lastKnownFileType = file; path = "silence-long.m4a"; sourceTree = "<group>"; }; 1469 C9B4AD2B1ECA6F7600F5FEA0 /* js-autoplay-audio.html */ = {isa = PBXFileReference; lastKnownFileType = text.html; path = "js-autoplay-audio.html"; sourceTree = "<group>"; }; 1464 1470 C9BF06EE1E9C130400595E3E /* autoplay-muted-with-controls.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "autoplay-muted-with-controls.html"; sourceTree = "<group>"; }; 1465 1471 C9C60E631E53A9BA006DA181 /* autoplay-check-frame.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "autoplay-check-frame.html"; sourceTree = "<group>"; }; … … 1984 1990 F415086C1DA040C10044BE9B /* play-audio-on-click.html */, 1985 1991 A12DDBFF1E8373C100CF6CAE /* rendered-image-excluding-overflow.html */, 1992 C9B4AD291ECA6EA500F5FEA0 /* silence-long.m4a */, 1986 1993 F4F405BB1D4C0CF8007A9707 /* skinny-autoplaying-video-with-audio.html */, 1987 1994 515BE16E1D4288FF00DD7C68 /* StoreBlobToBeDeleted.html */, … … 2284 2291 BCBD372E125ABBE600D2C29F /* icon.png */, 2285 2292 CE3524F51B142BBB0028A7C5 /* input-focus-blur.html */, 2293 C9B4AD2B1ECA6F7600F5FEA0 /* js-autoplay-audio.html */, 2286 2294 C99B675B1E3971FC00FC6C80 /* js-play-with-controls.html */, 2287 2295 8361F1771E610B2100759B25 /* link-with-download-attribute-with-slashes.html */, -
trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/WebsitePolicies.mm
r217152 r217310 388 388 389 389 receivedAutoplayEvent = std::nullopt; 390 NSURLRequest *jsPlayRequest = [NSURLRequest requestWithURL:[[NSBundle mainBundle] URLForResource:@"js- play-with-controls" withExtension:@"html" subdirectory:@"TestWebKitAPI.resources"]];390 NSURLRequest *jsPlayRequest = [NSURLRequest requestWithURL:[[NSBundle mainBundle] URLForResource:@"js-autoplay-audio" withExtension:@"html" subdirectory:@"TestWebKitAPI.resources"]]; 391 391 [webView loadRequest:jsPlayRequest]; 392 [webView waitForMessage:@"playing"]; 393 394 ASSERT_TRUE(receivedAutoplayEvent == std::nullopt); 395 396 [webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"about:blank"]]]; 397 runUntilReceivesAutoplayEvent(kWKAutoplayEventDidEndMediaPlaybackWithoutUserInterference); 398 ASSERT_TRUE(*receivedAutoplayEventFlags & kWKAutoplayEventFlagsHasAudio); 399 400 receivedAutoplayEvent = std::nullopt; 401 [webView loadRequest:jsPlayRequest]; 402 [webView waitForMessage:@"ended"]; 403 runUntilReceivesAutoplayEvent(kWKAutoplayEventDidEndMediaPlaybackWithoutUserInterference); 392 runUntilReceivesAutoplayEvent(kWKAutoplayEventDidAutoplayMediaPastThresholdWithoutUserInterference); 404 393 ASSERT_TRUE(*receivedAutoplayEventFlags & kWKAutoplayEventFlagsHasAudio); 405 394 } … … 457 446 } 458 447 459 TEST(WebKit2, WebsitePoliciesUserNeverPlayedMediaPreventedFromPlaying)460 {461 auto configuration = adoptNS([[WKWebViewConfiguration alloc] init]);462 auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:NSMakeRect(0, 0, 336, 276) configuration:configuration.get()]);463 464 auto delegate = adoptNS([[AutoplayPoliciesDelegate alloc] init]);465 [delegate setAutoplayPolicyForURL:^(NSURL *) {466 return _WKWebsiteAutoplayPolicyDeny;467 }];468 [webView setNavigationDelegate:delegate.get()];469 470 WKPageUIClientV9 uiClient;471 memset(&uiClient, 0, sizeof(uiClient));472 473 uiClient.base.version = 9;474 uiClient.handleAutoplayEvent = handleAutoplayEvent;475 476 WKPageSetPageUIClient([webView _pageForTesting], &uiClient.base);477 478 receivedAutoplayEvent = std::nullopt;479 NSURLRequest *jsPlayRequest = [NSURLRequest requestWithURL:[[NSBundle mainBundle] URLForResource:@"js-play-with-controls" withExtension:@"html" subdirectory:@"TestWebKitAPI.resources"]];480 [webView loadRequest:jsPlayRequest];481 [webView waitForMessage:@"loaded"];482 runUntilReceivesAutoplayEvent(kWKAutoplayEventDidPreventFromAutoplaying);483 484 [webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"about:blank"]]];485 runUntilReceivesAutoplayEvent(kWKAutoplayEventUserNeverPlayedMediaPreventedFromPlaying);486 ASSERT_TRUE(*receivedAutoplayEventFlags & kWKAutoplayEventFlagsHasAudio);487 }488 489 448 TEST(WebKit2, WebsitePoliciesAutoplayQuirks) 490 449 {
Note:
See TracChangeset
for help on using the changeset viewer.