Changeset 271670 in webkit
- Timestamp:
- Jan 20, 2021 1:27:07 PM (18 months ago)
- Location:
- trunk
- Files:
-
- 1 added
- 6 edited
-
Source/WebCore/ChangeLog (modified) (1 diff)
-
Source/WebCore/platform/audio/PlatformMediaSession.cpp (modified) (1 diff)
-
Source/WebCore/platform/audio/PlatformMediaSessionManager.cpp (modified) (1 diff)
-
Tools/ChangeLog (modified) (1 diff)
-
Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj (modified) (4 diffs)
-
Tools/TestWebKitAPI/Tests/WebKit/GetUserMedia.mm (modified) (1 diff)
-
Tools/TestWebKitAPI/Tests/WebKit/getUserMedia2.html (added)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r271669 r271670 1 2021-01-20 Youenn Fablet <youenn@apple.com> 2 3 Two pages in the same process should not be able to play media stream backed video elements at the same time 4 https://bugs.webkit.org/show_bug.cgi?id=220504 5 6 Reviewed by Eric Carlson. 7 8 In case of ConcurrentPlaybackNotPermitted restrictions, we now make sure that media elements from different pages do not play concurrently. 9 We also make sure that a VideoAudio and Audio sessions can also pause each other so we update the check for same media session type accordingly. 10 11 Covered by API test. 12 13 * platform/audio/PlatformMediaSession.cpp: 14 (WebCore::isPlayingAudio): 15 (WebCore::PlatformMediaSession::canPlayConcurrently const): 16 * platform/audio/PlatformMediaSessionManager.cpp: 17 (WebCore::PlatformMediaSessionManager::sessionWillBeginPlayback): 18 1 19 2021-01-20 Alex Christensen <achristensen@webkit.org> 2 20 -
trunk/Source/WebCore/platform/audio/PlatformMediaSession.cpp
r267544 r271670 349 349 } 350 350 351 static inline bool isPlayingAudio(PlatformMediaSession::MediaType mediaType) 352 { 353 return mediaType == MediaElementSession::MediaType::VideoAudio || mediaType == MediaElementSession::MediaType::Audio; 354 } 355 351 356 bool PlatformMediaSession::canPlayConcurrently(const PlatformMediaSession& otherSession) const 352 357 { 358 auto mediaType = this->mediaType(); 359 auto otherMediaType = otherSession.mediaType(); 360 if (otherMediaType != mediaType && (!isPlayingAudio(mediaType) || !isPlayingAudio(otherMediaType))) 361 return true; 362 363 auto groupID = client().mediaSessionGroupIdentifier(); 364 auto otherGroupID = otherSession.client().mediaSessionGroupIdentifier(); 365 if (!groupID || !otherGroupID || groupID != otherGroupID) 366 return false; 367 353 368 return m_client.hasMediaStreamSource() && otherSession.m_client.hasMediaStreamSource(); 354 369 } -
trunk/Source/WebCore/platform/audio/PlatformMediaSessionManager.cpp
r271668 r271670 244 244 245 245 if (restrictions & ConcurrentPlaybackNotPermitted) { 246 forEachMatchingSession([&session , sessionType](auto& oneSession) {246 forEachMatchingSession([&session](auto& oneSession) { 247 247 return &oneSession != &session 248 && oneSession.mediaType() == sessionType249 248 && oneSession.state() == PlatformMediaSession::Playing 250 249 && !oneSession.canPlayConcurrently(session); -
trunk/Tools/ChangeLog
r271650 r271670 1 2021-01-20 Youenn Fablet <youenn@apple.com> 2 3 Two pages in the same process should not be able to play media stream backed video elements at the same time 4 https://bugs.webkit.org/show_bug.cgi?id=220504 5 6 Reviewed by Eric Carlson. 7 8 * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj: 9 * TestWebKitAPI/Tests/WebKit/GetUserMedia.mm: 10 (TestWebKitAPI::TEST): 11 * TestWebKitAPI/Tests/WebKit/getUserMedia2.html: Added. 12 1 13 2021-01-20 Kate Cheney <katherine_cheney@apple.com> 2 14 -
trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj
r271656 r271670 52 52 07492B3C1DF8B86600633DE1 /* enumerateMediaDevices.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 07492B391DF8ADA400633DE1 /* enumerateMediaDevices.html */; }; 53 53 074994421EA5034B000DA44E /* getUserMedia.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 4A410F4D19AF7BEF002EBAB5 /* getUserMedia.html */; }; 54 074994521EA5034B000DA44E /* getUserMedia2.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 41BAF4E225AC9DB800D82F32 /* getUserMedia2.html */; }; 54 55 074994421EA5034B000DA44F /* ondevicechange.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 4A410F4D19AF7BEF002EBAB6 /* ondevicechange.html */; }; 55 56 074994421EA5034B000DA45E /* getUserMediaAudioVideoCapture.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 4A410F4D19AF7BEF002EBAC5 /* getUserMediaAudioVideoCapture.html */; }; … … 1444 1445 41661C662355E85E00D33C27 /* getUserMedia-webaudio.html in Copy Resources */, 1445 1446 074994421EA5034B000DA44E /* getUserMedia.html in Copy Resources */, 1447 074994521EA5034B000DA44E /* getUserMedia2.html in Copy Resources */, 1446 1448 074994421EA5034B000DA45E /* getUserMediaAudioVideoCapture.html in Copy Resources */, 1447 1449 F46A095B1ED8A6E600D4AA55 /* gif-and-file-input.html in Copy Resources */, … … 1985 1987 41882F0221010A70002FF288 /* ProcessPreWarming.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ProcessPreWarming.mm; sourceTree = "<group>"; }; 1986 1988 41973B5C1AF22875006C7B36 /* SharedBuffer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SharedBuffer.cpp; sourceTree = "<group>"; }; 1989 41BAF4E225AC9DB800D82F32 /* getUserMedia2.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = getUserMedia2.html; sourceTree = "<group>"; }; 1987 1990 44077BB0231449D200179E2D /* DataDetectorsTestIOS.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = DataDetectorsTestIOS.mm; sourceTree = "<group>"; }; 1988 1991 442BBF681C91CAD90017087F /* RefLogger.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RefLogger.cpp; sourceTree = "<group>"; }; … … 4385 4388 41661C652355D98B00D33C27 /* getUserMedia-webaudio.html */, 4386 4389 4A410F4D19AF7BEF002EBAB5 /* getUserMedia.html */, 4390 41BAF4E225AC9DB800D82F32 /* getUserMedia2.html */, 4387 4391 4A410F4D19AF7BEF002EBAC5 /* getUserMediaAudioVideoCapture.html */, 4388 4392 BCBD372E125ABBE600D2C29F /* icon.png */, -
trunk/Tools/TestWebKitAPI/Tests/WebKit/GetUserMedia.mm
r271640 r271670 302 302 } 303 303 304 TEST(WebKit, InterruptionBetweenSameProcessPages) 305 { 306 auto configuration = adoptNS([[WKWebViewConfiguration alloc] init]); 307 308 #if PLATFORM(IOS_FAMILY) 309 [configuration setAllowsInlineMediaPlayback:YES]; 310 #endif 311 312 auto preferences = [configuration preferences]; 313 preferences._mediaCaptureRequiresSecureConnection = NO; 314 configuration.get()._mediaCaptureEnabled = YES; 315 preferences._mockCaptureDevicesEnabled = YES; 316 317 auto messageHandler = adoptNS([[GUMMessageHandler alloc] init]); 318 [[configuration userContentController] addScriptMessageHandler:messageHandler.get() name:@"gum"]; 319 320 done = false; 321 auto webView1 = adoptNS([[TestWKWebView alloc] initWithFrame:NSMakeRect(0, 0, 300, 300) configuration:configuration.get() addToWindow:YES]); 322 auto delegate = adoptNS([[GetUserMediaCaptureUIDelegate alloc] init]); 323 webView1.get().UIDelegate = delegate.get(); 324 [webView1 loadTestPageNamed:@"getUserMedia2"]; 325 TestWebKitAPI::Util::run(&done); 326 327 configuration.get()._relatedWebView = webView1.get(); 328 329 done = false; 330 auto webView2 = adoptNS([[TestWKWebView alloc] initWithFrame:NSMakeRect(0, 0, 300, 300) configuration:configuration.get() addToWindow:YES]); 331 webView2.get().UIDelegate = delegate.get(); 332 [webView2 loadTestPageNamed:@"getUserMedia2"]; 333 TestWebKitAPI::Util::run(&done); 334 335 done = false; 336 #if PLATFORM(IOS) 337 [webView1 stringByEvaluatingJavaScript:@"checkIsNotPlaying()"]; 338 #else 339 [webView1 stringByEvaluatingJavaScript:@"checkIsPlaying()"]; 340 #endif 341 TestWebKitAPI::Util::run(&done); 342 } 343 304 344 #if WK_HAVE_C_SPI 305 345 TEST(WebKit, WebAudioAndGetUserMedia)
Note: See TracChangeset
for help on using the changeset viewer.