Changeset 291759 in webkit
- Timestamp:
- Mar 23, 2022, 12:21:33 PM (5 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 16 edited
-
LayoutTests/ChangeLog (modified) (1 diff)
-
LayoutTests/media/audio-session-category-at-most-recent-playback-expected.txt (added)
-
LayoutTests/media/audio-session-category-at-most-recent-playback.html (added)
-
LayoutTests/media/audio-session-category-expected.txt (modified) (1 diff)
-
LayoutTests/media/audio-session-category.html (modified) (2 diffs)
-
LayoutTests/platform/glib/TestExpectations (modified) (1 diff)
-
LayoutTests/platform/mac-wk1/TestExpectations (modified) (1 diff)
-
Source/WebCore/ChangeLog (modified) (1 diff)
-
Source/WebCore/html/HTMLMediaElement.cpp (modified) (3 diffs)
-
Source/WebCore/html/HTMLMediaElement.h (modified) (2 diffs)
-
Source/WebCore/platform/audio/AudioSession.h (modified) (2 diffs)
-
Source/WebCore/platform/audio/PlatformMediaSessionManager.cpp (modified) (1 diff)
-
Source/WebCore/platform/audio/PlatformMediaSessionManager.h (modified) (1 diff)
-
Source/WebCore/platform/audio/cocoa/MediaSessionManagerCocoa.h (modified) (1 diff)
-
Source/WebCore/platform/audio/cocoa/MediaSessionManagerCocoa.mm (modified) (1 diff)
-
Source/WebCore/testing/Internals.cpp (modified) (2 diffs)
-
Source/WebCore/testing/Internals.h (modified) (2 diffs)
-
Source/WebCore/testing/Internals.idl (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r291753 r291759 1 2022-03-23 Jer Noble <jer.noble@apple.com> 2 3 [iOS] WebKit app is sometimes not "Now Playing" during initial playback 4 https://bugs.webkit.org/show_bug.cgi?id=236993 5 <rdar://88827167> 6 7 Reviewed by Eric Carlson. 8 9 Fix the audio-session-category test. Creating the oscilator actually does change the 10 AudioSession category to "Ambient", but (previously) only in the next run loop, so a 11 synchronous test that the AudioSession category is "None" succeeds. Now that starting 12 playback (as happens when creating an audio node) changes the AudioSession synchronously, 13 the test begins failing. 14 15 * media/audio-session-category-at-most-recent-playback-expected.txt: Added. 16 * media/audio-session-category-at-most-recent-playback.html: Added. 17 * media/audio-session-category-expected.txt: 18 * media/audio-session-category.html: 19 1 20 2022-03-23 Matteo Flores <matteo_flores@apple.com> 2 21 -
trunk/LayoutTests/media/audio-session-category-expected.txt
r288466 r291759 35 35 EXPECTED (internals.audioSessionCategory() == 'None') OK 36 36 37 ** Check category after oscillator graph has been connected but not started.37 ** Check category after AudioContext has been created but not started. 38 38 EXPECTED (internals.audioSessionCategory() == 'None') OK 39 39 -
trunk/LayoutTests/media/audio-session-category.html
r288466 r291759 59 59 await waitForCategory('None', 10, '<br>** Check category before creating AudioContext.'); 60 60 61 consoleWrite('<br>** Check category after oscillator graph has been connected but not started.');61 consoleWrite('<br>** Check category after AudioContext has been created but not started.'); 62 62 let context = new AudioContext(); 63 testExpected('internals.audioSessionCategory()', 'None'); 64 63 65 let oscillator = null; 64 66 let gainNode = context.createGain(); 65 66 67 oscillator = context.createOscillator(); 67 68 oscillator.type = 'square'; … … 71 72 gainNode.connect(context.destination); 72 73 gainNode.gain.value = 0.1 73 testExpected('internals.audioSessionCategory()', 'None');74 74 75 75 consoleWrite('<br>** Check category after starting oscillator.'); 76 context.resume(); 76 77 oscillator.start(0); 77 78 await sleepFor(500); -
trunk/LayoutTests/platform/glib/TestExpectations
r291747 r291759 1877 1877 # Tests behavior specific to MediaSessionManagerCocoa 1878 1878 media/audio-session-category.html [ Skip ] 1879 media/audio-session-category-at-most-recent-playback.html [ Skip ] 1879 1880 1880 1881 # This test assumes we cannot play RTSP, but we can. -
trunk/LayoutTests/platform/mac-wk1/TestExpectations
r291737 r291759 66 66 http/tests/navigation/page-cache-mediastream.html [ Skip ] 67 67 media/audio-session-category.html [ Skip ] 68 media/audio-session-category-at-most-recent-playback.html [ Skip ] 68 69 69 70 # Shared workers are only implemented for WebKit2. -
trunk/Source/WebCore/ChangeLog
r291754 r291759 1 2022-03-23 Jer Noble <jer.noble@apple.com> 2 3 [iOS] WebKit app is sometimes not "Now Playing" during initial playback 4 https://bugs.webkit.org/show_bug.cgi?id=236993 5 <rdar://88827167> 6 7 Reviewed by Eric Carlson. 8 9 Test: media/audio-session-category-at-most-recent-playback.html 10 11 Recently, we have added the concept of "preparingToPlay" to PlatformMediaSession to allow 12 the correct category to be set if updateSessionState() is called after playback is allowed 13 by the MediaSessionManager, but before playback is actually started by the media element. 14 However, this depends on updateSessionState() being called synchronously during playback. 15 We disabled this synchronous update in r269077 due to the large runtime cost when a large 16 number of media elements are created (but not used) at once. 17 18 Relax this asynchronous update in the case where the state is moving to "Playing", which 19 ensures that the correct AudioSessionCategory is set before playback starts, rather than 20 immediately afterward. 21 22 To support testing that the category was correctly set before playback started, add an 23 ivar to HTMLMediaElement that is set to the current AudioSessionCategory immediately before 24 the media element instructs the MediaPlayer to start playback. Expose this ivar to Internals. 25 26 Drive-by fixes: AudioSession::CategoryType cannot be forward declared, as it is a public 27 member of a class. Allow the enum to be forward declared by moving the declaration outside 28 the class, but allow current uses of the enum to continue by typedefing it inside the class 29 to the original enum name. Add an IDL enumeration matching the AudioSession one in Interals.idl 30 and convert the existing audioSessionCategory() call to use the new enumeration. 31 32 (Unforunately in the case where USE_AUDIO_SESSION is not set, the enumeration must be re- 33 declared. This can be removed and the entire implementation wrapped in a USE() check, once 34 the bindings generator is extended to allow "Conditional="-style attributes for USE checks.) 35 36 The added test is flakey due to a previous change which would keep the MediaSession category 37 in "MediaPlayback" for up to 2s after playback ends. To counteract this flakiness, reset the 38 state of the PlatformMediaSessionManager between tests. 39 40 * html/HTMLMediaElement.cpp: 41 (WebCore::m_categoryAtMostRecentPlayback): 42 (WebCore::HTMLMediaElement::playPlayer): 43 (WebCore::m_logIdentifier): Deleted. 44 * html/HTMLMediaElement.h: 45 (WebCore::HTMLMediaElement::categoryAtMostRecentPlayback const): 46 * platform/audio/AudioSession.h: 47 * platform/audio/PlatformMediaSessionManager.cpp: 48 (WebCore::PlatformMediaSessionManager::sessionStateChanged): 49 * platform/audio/PlatformMediaSessionManager.h: 50 (WebCore::PlatformMediaSessionManager::resetSessionState): 51 * platform/audio/cocoa/MediaSessionManagerCocoa.h: 52 * platform/audio/cocoa/MediaSessionManagerCocoa.mm: 53 (WebCore::MediaSessionManagerCocoa::resetSessionState): 54 * testing/Internals.cpp: 55 (WebCore::Internals::resetToConsistentState): 56 * testing/Internals.cpp: 57 (WebCore::Internals::audioSessionCategory const): 58 (WebCore::Internals::categoryAtMostRecentPlayback const): 59 * testing/Internals.h: 60 * testing/Internals.idl: 61 1 62 2022-03-22 Brandon Stewart <brandonstewart@apple.com> 2 63 -
trunk/Source/WebCore/html/HTMLMediaElement.cpp
r291296 r291759 131 131 #include <wtf/text/CString.h> 132 132 133 #if USE(AUDIO_SESSION) 134 #include "AudioSession.h" 135 #endif 136 133 137 #if ENABLE(WEB_AUDIO) 134 138 #include "AudioSourceProvider.h" … … 459 463 , m_logIdentifier(uniqueLogIdentifier()) 460 464 #endif 465 #if USE(AUDIO_SESSION) 466 , m_categoryAtMostRecentPlayback(AudioSessionCategory::None) 467 #endif 461 468 { 462 469 allMediaElements().add(this); … … 5695 5702 return; 5696 5703 5704 #if USE(AUDIO_SESSION) 5705 m_categoryAtMostRecentPlayback = AudioSession::sharedSession().category(); 5706 #endif 5707 5697 5708 #if ENABLE(MEDIA_SESSION) && ENABLE(MEDIA_SESSION_COORDINATOR) 5698 5709 do { -
trunk/Source/WebCore/html/HTMLMediaElement.h
r291296 r291759 606 606 WEBCORE_EXPORT bool mediaPlayerRenderingCanBeAccelerated() final; 607 607 608 #if USE(AUDIO_SESSION) 609 WEBCORE_EXPORT AudioSessionCategory categoryAtMostRecentPlayback() const { return m_categoryAtMostRecentPlayback; } 610 #endif 611 608 612 protected: 609 613 HTMLMediaElement(const QualifiedName&, Document&, bool createdByParser); … … 1240 1244 #endif 1241 1245 String m_id; 1246 1247 #if USE(AUDIO_SESSION) 1248 AudioSessionCategory m_categoryAtMostRecentPlayback; 1249 #endif 1242 1250 }; 1243 1251 -
trunk/Source/WebCore/platform/audio/AudioSession.h
r291268 r291759 47 47 }; 48 48 49 enum class AudioSessionCategory : uint8_t { 50 None, 51 AmbientSound, 52 SoloAmbientSound, 53 MediaPlayback, 54 RecordAudio, 55 PlayAndRecord, 56 AudioProcessing, 57 }; 58 49 59 class AudioSessionRoutingArbitrationClient; 50 60 … … 64 74 virtual ~AudioSession(); 65 75 66 enum class CategoryType : uint8_t { 67 None, 68 AmbientSound, 69 SoloAmbientSound, 70 MediaPlayback, 71 RecordAudio, 72 PlayAndRecord, 73 AudioProcessing, 74 }; 76 using CategoryType = AudioSessionCategory; 75 77 virtual void setCategory(CategoryType, RouteSharingPolicy); 76 78 virtual CategoryType category() const; -
trunk/Source/WebCore/platform/audio/PlatformMediaSessionManager.cpp
r284093 r291759 291 291 } 292 292 293 void PlatformMediaSessionManager::sessionStateChanged(PlatformMediaSession&) 294 { 295 scheduleUpdateSessionState(); 293 void PlatformMediaSessionManager::sessionStateChanged(PlatformMediaSession& session) 294 { 295 // Call updateSessionState() synchronously if the new state is Playing to ensure 296 // the audio session is active and has the correct category before playback starts. 297 if (session.state() == PlatformMediaSession::Playing) 298 updateSessionState(); 299 else 300 scheduleUpdateSessionState(); 296 301 } 297 302 -
trunk/Source/WebCore/platform/audio/PlatformMediaSessionManager.h
r291390 r291759 169 169 170 170 virtual void resetHaveEverRegisteredAsNowPlayingApplicationForTesting() { }; 171 virtual void resetSessionState() { }; 171 172 172 173 bool isApplicationInBackground() const { return m_isApplicationInBackground; } -
trunk/Source/WebCore/platform/audio/cocoa/MediaSessionManagerCocoa.h
r290621 r291759 100 100 101 101 void resetHaveEverRegisteredAsNowPlayingApplicationForTesting() final { m_haveEverRegisteredAsNowPlayingApplication = false; }; 102 void resetSessionState() final; 102 103 103 104 private: -
trunk/Source/WebCore/platform/audio/cocoa/MediaSessionManagerCocoa.mm
r290621 r291759 205 205 } 206 206 207 void MediaSessionManagerCocoa::resetSessionState() 208 { 209 ALWAYS_LOG(LOGIDENTIFIER); 210 m_delayCategoryChangeTimer.stop(); 211 m_previousCategory = AudioSession::CategoryType::None; 212 m_previousHadAudibleAudioOrVideoMediaType = false; 213 } 214 207 215 void MediaSessionManagerCocoa::beginInterruption(PlatformMediaSession::InterruptionType type) 208 216 { -
trunk/Source/WebCore/testing/Internals.cpp
r291611 r291759 555 555 PlatformMediaSessionManager::sharedManager().resetHaveEverRegisteredAsNowPlayingApplicationForTesting(); 556 556 PlatformMediaSessionManager::sharedManager().resetRestrictions(); 557 PlatformMediaSessionManager::sharedManager().resetSessionState(); 557 558 PlatformMediaSessionManager::sharedManager().setWillIgnoreSystemInterruptions(true); 558 559 #endif … … 5659 5660 } 5660 5661 5661 String Internals::audioSessionCategory() const 5662 auto Internals::audioSessionCategory() const -> AudioSessionCategory 5662 5663 { 5663 5664 #if USE(AUDIO_SESSION) 5664 switch (AudioSession::sharedSession().category()) { 5665 case AudioSession::CategoryType::AmbientSound: 5666 return "AmbientSound"_s; 5667 case AudioSession::CategoryType::SoloAmbientSound: 5668 return "SoloAmbientSound"_s; 5669 case AudioSession::CategoryType::MediaPlayback: 5670 return "MediaPlayback"_s; 5671 case AudioSession::CategoryType::RecordAudio: 5672 return "RecordAudio"_s; 5673 case AudioSession::CategoryType::PlayAndRecord: 5674 return "PlayAndRecord"_s; 5675 case AudioSession::CategoryType::AudioProcessing: 5676 return "AudioProcessing"_s; 5677 case AudioSession::CategoryType::None: 5678 return "None"_s; 5679 } 5680 #endif 5681 return emptyString(); 5682 } 5665 return AudioSession::sharedSession().category(); 5666 #else 5667 return AudioSessionCategory::None; 5668 #endif 5669 } 5670 5671 #if ENABLE(VIDEO) 5672 auto Internals::categoryAtMostRecentPlayback(HTMLMediaElement& element) const -> AudioSessionCategory 5673 { 5674 #if USE(AUDIO_SESSION) 5675 return element.categoryAtMostRecentPlayback(); 5676 #else 5677 return AudioSessionCategory::None; 5678 #endif 5679 } 5680 #endif 5683 5681 5684 5682 double Internals::preferredAudioBufferSize() const -
trunk/Source/WebCore/testing/Internals.h
r291611 r291759 46 46 #include "MediaElementSession.h" 47 47 #include "MediaUniqueIdentifier.h" 48 #endif 49 50 #if USE(AUDIO_SESSION) 51 #include "AudioSession.h" 48 52 #endif 49 53 … … 890 894 #endif 891 895 896 897 #if USE(AUDIO_SESSION) 898 using AudioSessionCategory = WebCore::AudioSessionCategory; 899 #else 900 enum class AudioSessionCategory : uint8_t { 901 None, 902 AmbientSound, 903 SoloAmbientSound, 904 MediaPlayback, 905 RecordAudio, 906 PlayAndRecord, 907 AudioProcessing, 908 }; 909 #endif 910 892 911 bool supportsAudioSession() const; 893 String audioSessionCategory() const; 912 AudioSessionCategory audioSessionCategory() const; 913 #if ENABLE(VIDEO) 914 AudioSessionCategory categoryAtMostRecentPlayback(HTMLMediaElement&) const; 915 #endif 894 916 double preferredAudioBufferSize() const; 895 917 double currentAudioBufferSize() const; -
trunk/Source/WebCore/testing/Internals.idl
r291517 r291759 104 104 "GPUStatusFailure", 105 105 "Timeout" 106 }; 107 108 enum AudioSessionCategory { 109 "None", 110 "AmbientSound", 111 "SoloAmbientSound", 112 "MediaPlayback", 113 "RecordAudio", 114 "PlayAndRecord", 115 "AudioProcessing" 106 116 }; 107 117 … … 967 977 968 978 readonly attribute boolean supportsAudioSession; 969 DOMString audioSessionCategory(); 979 AudioSessionCategory audioSessionCategory(); 980 [Conditional=VIDEO] AudioSessionCategory categoryAtMostRecentPlayback(HTMLMediaElement element); 981 970 982 double preferredAudioBufferSize(); 971 983 double currentAudioBufferSize();
Note:
See TracChangeset
for help on using the changeset viewer.