Changeset 206487 in webkit
- Timestamp:
- Sep 27, 2016 6:38:56 PM (8 years ago)
- Location:
- branches/safari-602.2.14.0-branch/Source/WebCore
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/safari-602.2.14.0-branch/Source/WebCore/ChangeLog
r206394 r206487 1 2016-09-27 Babak Shafiei <bshafiei@apple.com> 2 3 Merge r206399. rdar://problem/28457219 4 5 2016-09-26 Wenson Hsieh <wenson_hsieh@apple.com> 6 7 Seeking video doesn't update seek position 8 https://bugs.webkit.org/show_bug.cgi?id=162575 9 <rdar://problem/28457219> 10 11 Reviewed by Jer Noble. 12 13 On ToT, seeking in a video causes the playhead to stutter, and does not actually update media remote's seek 14 position. This is partly due to how we do not update media remote with new information when beginning to respond 15 to remote seek commands, so media remote continues to think that a playing video is still playing despite the 16 user attempting to seek through it. 17 18 To fix this, we introduce timer-based guards around remote seek commands, such that a seek "gesture" begins when 19 we receive the first seek command and ends when no seek command has been received in a set amount of time (this 20 is 0.5 seconds, which is approximately what other clients around the platform use). 21 22 Also, when responding to a remote seek, perform the seek with no tolerance. This prevents the playhead from 23 stuttering at the end of a seek from the final requested destination of the seek to the last actually seeked 24 time in the video. 25 26 When beginning to seek, we must pause the media. Through existing mechanisms, this causes the media session 27 manager to update its Now Playing information, which informs media remote that we are no longer playing and 28 prevents us from stuttering. However, when ending a seek, we must also trigger an additional update to again 29 refresh media remote's view of the current time. This prevents a flicker when playing media after seeking. 30 31 Unit tests to be added in a follow-up due to time constraints. 32 33 * html/HTMLMediaElement.cpp: 34 (WebCore::HTMLMediaElement::HTMLMediaElement): 35 (WebCore::HTMLMediaElement::handleSeekToPlaybackPosition): 36 (WebCore::HTMLMediaElement::seekToPlaybackPositionEndedTimerFired): 37 (WebCore::HTMLMediaElement::didReceiveRemoteControlCommand): 38 * html/HTMLMediaElement.h: 39 * platform/audio/PlatformMediaSessionManager.h: 40 (WebCore::PlatformMediaSessionManager::scheduleUpdateNowPlayingInfo): 41 (WebCore::PlatformMediaSessionManager::sessionDidEndRemoteScrubbing): 42 (WebCore::PlatformMediaSessionManager::sessions): Deleted. 43 * platform/audio/mac/MediaSessionManagerMac.h: 44 * platform/audio/mac/MediaSessionManagerMac.mm: 45 (WebCore::PlatformMediaSessionManager::updateNowPlayingInfoIfNecessary): 46 (WebCore::MediaSessionManagerMac::scheduleUpdateNowPlayingInfo): 47 (WebCore::MediaSessionManagerMac::sessionDidEndRemoteScrubbing): 48 (WebCore::MediaSessionManagerMac::updateNowPlayingInfo): 49 1 50 2016-09-26 Babak Shafiei <bshafiei@apple.com> 2 51 -
branches/safari-602.2.14.0-branch/Source/WebCore/html/HTMLMediaElement.cpp
r206368 r206487 406 406 , m_scanTimer(*this, &HTMLMediaElement::scanTimerFired) 407 407 , m_playbackControlsManagerBehaviorRestrictionsTimer(*this, &HTMLMediaElement::playbackControlsManagerBehaviorRestrictionsTimerFired) 408 , m_seekToPlaybackPositionEndedTimer(*this, &HTMLMediaElement::seekToPlaybackPositionEndedTimerFired) 408 409 , m_playedTimeRanges() 409 410 , m_asyncEventQueue(*this) … … 468 469 , m_haveSetUpCaptionContainer(false) 469 470 #endif 471 , m_isScrubbingRemotely(false) 470 472 #if ENABLE(VIDEO_TRACK) 471 473 , m_tracksAreReady(true) … … 4561 4563 } 4562 4564 4565 void HTMLMediaElement::handleSeekToPlaybackPosition(double position) 4566 { 4567 #if PLATFORM(MAC) 4568 // FIXME: This should ideally use faskSeek, but this causes MediaRemote's playhead to flicker upon release. 4569 // Please see <rdar://problem/28457219> for more details. 4570 seek(MediaTime::createWithDouble(position)); 4571 m_seekToPlaybackPositionEndedTimer.stop(); 4572 m_seekToPlaybackPositionEndedTimer.startOneShot(0.5); 4573 4574 if (!m_isScrubbingRemotely) { 4575 m_isScrubbingRemotely = true; 4576 if (!paused()) 4577 pauseInternal(); 4578 } 4579 #else 4580 fastSeek(position); 4581 #endif 4582 } 4583 4584 void HTMLMediaElement::seekToPlaybackPositionEndedTimerFired() 4585 { 4586 #if PLATFORM(MAC) 4587 if (!m_isScrubbingRemotely) 4588 return; 4589 4590 PlatformMediaSessionManager::sharedManager().sessionDidEndRemoteScrubbing(*m_mediaSession); 4591 m_isScrubbingRemotely = false; 4592 m_seekToPlaybackPositionEndedTimer.stop(); 4593 #endif 4594 } 4595 4563 4596 void HTMLMediaElement::mediaPlayerVolumeChanged(MediaPlayer*) 4564 4597 { … … 6993 7026 ASSERT(argument); 6994 7027 if (argument) 6995 fastSeek(argument->asDouble);7028 handleSeekToPlaybackPosition(argument->asDouble); 6996 7029 break; 6997 7030 default: -
branches/safari-602.2.14.0-branch/Source/WebCore/html/HTMLMediaElement.h
r206368 r206487 811 811 812 812 void addBehaviorRestrictionsOnEndIfNecessary(); 813 void handleSeekToPlaybackPosition(double); 814 void seekToPlaybackPositionEndedTimerFired(); 813 815 814 816 Timer m_pendingActionTimer; … … 817 819 Timer m_scanTimer; 818 820 Timer m_playbackControlsManagerBehaviorRestrictionsTimer; 821 Timer m_seekToPlaybackPositionEndedTimer; 819 822 GenericTaskQueue<Timer> m_seekTaskQueue; 820 823 GenericTaskQueue<Timer> m_resizeTaskQueue; … … 969 972 #endif 970 973 974 bool m_isScrubbingRemotely : 1; 975 971 976 #if ENABLE(VIDEO_TRACK) 972 977 bool m_tracksAreReady : 1; -
branches/safari-602.2.14.0-branch/Source/WebCore/platform/audio/PlatformMediaSessionManager.h
r206347 r206487 52 52 virtual ~PlatformMediaSessionManager() { } 53 53 54 virtual void scheduleUpdateNowPlayingInfo() { } 54 55 bool has(PlatformMediaSession::MediaType) const; 55 56 int count(PlatformMediaSession::MediaType) const; … … 86 87 virtual void sessionWillEndPlayback(PlatformMediaSession&); 87 88 virtual bool sessionCanLoadMedia(const PlatformMediaSession&) const; 89 virtual void sessionDidEndRemoteScrubbing(const PlatformMediaSession&) { }; 88 90 virtual void clientCharacteristicsChanged(PlatformMediaSession&) { } 89 91 -
branches/safari-602.2.14.0-branch/Source/WebCore/platform/audio/mac/MediaSessionManagerMac.h
r202642 r206487 28 28 #if PLATFORM(MAC) 29 29 30 #include "GenericTaskQueue.h" 30 31 #include "PlatformMediaSessionManager.h" 31 32 #include <wtf/RetainPtr.h> … … 42 43 MediaSessionManagerMac(); 43 44 45 void scheduleUpdateNowPlayingInfo() override; 44 46 void removeSession(PlatformMediaSession&) override; 45 47 46 48 bool sessionWillBeginPlayback(PlatformMediaSession&) override; 47 49 void sessionWillEndPlayback(PlatformMediaSession&) override; 50 void sessionDidEndRemoteScrubbing(const PlatformMediaSession&) override; 48 51 void clientCharacteristicsChanged(PlatformMediaSession&) override; 49 52 … … 52 55 PlatformMediaSession* nowPlayingEligibleSession(); 53 56 54 double m_reportedRate { 0 };55 double m_reportedDuration { 0 };56 String m_reportedTitle;57 57 bool m_nowPlayingActive { false }; 58 58 bool m_isInBackground { false }; 59 GenericTaskQueue<Timer> m_nowPlayingUpdateTaskQueue; 59 60 }; 60 61 -
branches/safari-602.2.14.0-branch/Source/WebCore/platform/audio/mac/MediaSessionManagerMac.mm
r206321 r206487 57 57 { 58 58 if (auto existingManager = (MediaSessionManagerMac *)PlatformMediaSessionManager::sharedManagerIfExists()) 59 existingManager-> updateNowPlayingInfo();59 existingManager->scheduleUpdateNowPlayingInfo(); 60 60 } 61 61 … … 70 70 } 71 71 72 void MediaSessionManagerMac::scheduleUpdateNowPlayingInfo() 73 { 74 if (!m_nowPlayingUpdateTaskQueue.hasPendingTasks()) 75 m_nowPlayingUpdateTaskQueue.enqueueTask(std::bind(&MediaSessionManagerMac::updateNowPlayingInfo, this)); 76 } 77 72 78 bool MediaSessionManagerMac::sessionWillBeginPlayback(PlatformMediaSession& session) 73 79 { … … 78 84 updateNowPlayingInfo(); 79 85 return true; 86 } 87 88 void MediaSessionManagerMac::sessionDidEndRemoteScrubbing(const PlatformMediaSession&) 89 { 90 scheduleUpdateNowPlayingInfo(); 80 91 } 81 92 … … 124 135 MRMediaRemoteSetNowPlayingInfo(nullptr); 125 136 m_nowPlayingActive = false; 126 m_reportedTitle = "";127 m_reportedRate = 0;128 m_reportedDuration = 0;129 137 MRMediaRemoteSetNowPlayingApplicationPlaybackStateForOrigin(MRMediaRemoteGetLocalOrigin(), kMRPlaybackStateStopped, dispatch_get_main_queue(), ^(MRMediaRemoteError error) { 130 138 #if LOG_DISABLED … … 147 155 double duration = currentSession->duration(); 148 156 double rate = currentSession->state() == PlatformMediaSession::Playing ? 1 : 0; 149 if (m_reportedTitle == title && m_reportedRate == rate && m_reportedDuration == duration) {150 m_nowPlayingActive = true;151 LOG(Media, "MediaSessionManagerMac::updateNowPlayingInfo - nothing new to show");152 return;153 }154 155 m_reportedRate = rate;156 m_reportedDuration = duration;157 m_reportedTitle = title;158 159 157 auto info = adoptCF(CFDictionaryCreateMutable(kCFAllocatorDefault, 4, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks)); 160 158
Note: See TracChangeset
for help on using the changeset viewer.