Changeset 206487 in webkit


Ignore:
Timestamp:
Sep 27, 2016 6:38:56 PM (8 years ago)
Author:
bshafiei@apple.com
Message:

Merge r206399. rdar://problem/28457219

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  
     12016-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
    1502016-09-26  Babak Shafiei  <bshafiei@apple.com>
    251
  • branches/safari-602.2.14.0-branch/Source/WebCore/html/HTMLMediaElement.cpp

    r206368 r206487  
    406406    , m_scanTimer(*this, &HTMLMediaElement::scanTimerFired)
    407407    , m_playbackControlsManagerBehaviorRestrictionsTimer(*this, &HTMLMediaElement::playbackControlsManagerBehaviorRestrictionsTimerFired)
     408    , m_seekToPlaybackPositionEndedTimer(*this, &HTMLMediaElement::seekToPlaybackPositionEndedTimerFired)
    408409    , m_playedTimeRanges()
    409410    , m_asyncEventQueue(*this)
     
    468469    , m_haveSetUpCaptionContainer(false)
    469470#endif
     471    , m_isScrubbingRemotely(false)
    470472#if ENABLE(VIDEO_TRACK)
    471473    , m_tracksAreReady(true)
     
    45614563}
    45624564
     4565void 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
     4584void 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
    45634596void HTMLMediaElement::mediaPlayerVolumeChanged(MediaPlayer*)
    45644597{
     
    69937026        ASSERT(argument);
    69947027        if (argument)
    6995             fastSeek(argument->asDouble);
     7028            handleSeekToPlaybackPosition(argument->asDouble);
    69967029        break;
    69977030    default:
  • branches/safari-602.2.14.0-branch/Source/WebCore/html/HTMLMediaElement.h

    r206368 r206487  
    811811
    812812    void addBehaviorRestrictionsOnEndIfNecessary();
     813    void handleSeekToPlaybackPosition(double);
     814    void seekToPlaybackPositionEndedTimerFired();
    813815
    814816    Timer m_pendingActionTimer;
     
    817819    Timer m_scanTimer;
    818820    Timer m_playbackControlsManagerBehaviorRestrictionsTimer;
     821    Timer m_seekToPlaybackPositionEndedTimer;
    819822    GenericTaskQueue<Timer> m_seekTaskQueue;
    820823    GenericTaskQueue<Timer> m_resizeTaskQueue;
     
    969972#endif
    970973
     974    bool m_isScrubbingRemotely : 1;
     975
    971976#if ENABLE(VIDEO_TRACK)
    972977    bool m_tracksAreReady : 1;
  • branches/safari-602.2.14.0-branch/Source/WebCore/platform/audio/PlatformMediaSessionManager.h

    r206347 r206487  
    5252    virtual ~PlatformMediaSessionManager() { }
    5353
     54    virtual void scheduleUpdateNowPlayingInfo() { }
    5455    bool has(PlatformMediaSession::MediaType) const;
    5556    int count(PlatformMediaSession::MediaType) const;
     
    8687    virtual void sessionWillEndPlayback(PlatformMediaSession&);
    8788    virtual bool sessionCanLoadMedia(const PlatformMediaSession&) const;
     89    virtual void sessionDidEndRemoteScrubbing(const PlatformMediaSession&) { };
    8890    virtual void clientCharacteristicsChanged(PlatformMediaSession&) { }
    8991
  • branches/safari-602.2.14.0-branch/Source/WebCore/platform/audio/mac/MediaSessionManagerMac.h

    r202642 r206487  
    2828#if PLATFORM(MAC)
    2929
     30#include "GenericTaskQueue.h"
    3031#include "PlatformMediaSessionManager.h"
    3132#include <wtf/RetainPtr.h>
     
    4243    MediaSessionManagerMac();
    4344
     45    void scheduleUpdateNowPlayingInfo() override;
    4446    void removeSession(PlatformMediaSession&) override;
    4547
    4648    bool sessionWillBeginPlayback(PlatformMediaSession&) override;
    4749    void sessionWillEndPlayback(PlatformMediaSession&) override;
     50    void sessionDidEndRemoteScrubbing(const PlatformMediaSession&) override;
    4851    void clientCharacteristicsChanged(PlatformMediaSession&) override;
    4952
     
    5255    PlatformMediaSession* nowPlayingEligibleSession();
    5356
    54     double m_reportedRate { 0 };
    55     double m_reportedDuration { 0 };
    56     String m_reportedTitle;
    5757    bool m_nowPlayingActive { false };
    5858    bool m_isInBackground { false };
     59    GenericTaskQueue<Timer> m_nowPlayingUpdateTaskQueue;
    5960};
    6061
  • branches/safari-602.2.14.0-branch/Source/WebCore/platform/audio/mac/MediaSessionManagerMac.mm

    r206321 r206487  
    5757{
    5858    if (auto existingManager = (MediaSessionManagerMac *)PlatformMediaSessionManager::sharedManagerIfExists())
    59         existingManager->updateNowPlayingInfo();
     59        existingManager->scheduleUpdateNowPlayingInfo();
    6060}
    6161
     
    7070}
    7171
     72void MediaSessionManagerMac::scheduleUpdateNowPlayingInfo()
     73{
     74    if (!m_nowPlayingUpdateTaskQueue.hasPendingTasks())
     75        m_nowPlayingUpdateTaskQueue.enqueueTask(std::bind(&MediaSessionManagerMac::updateNowPlayingInfo, this));
     76}
     77
    7278bool MediaSessionManagerMac::sessionWillBeginPlayback(PlatformMediaSession& session)
    7379{
     
    7884    updateNowPlayingInfo();
    7985    return true;
     86}
     87
     88void MediaSessionManagerMac::sessionDidEndRemoteScrubbing(const PlatformMediaSession&)
     89{
     90    scheduleUpdateNowPlayingInfo();
    8091}
    8192
     
    124135            MRMediaRemoteSetNowPlayingInfo(nullptr);
    125136            m_nowPlayingActive = false;
    126             m_reportedTitle = "";
    127             m_reportedRate = 0;
    128             m_reportedDuration = 0;
    129137            MRMediaRemoteSetNowPlayingApplicationPlaybackStateForOrigin(MRMediaRemoteGetLocalOrigin(), kMRPlaybackStateStopped, dispatch_get_main_queue(), ^(MRMediaRemoteError error) {
    130138#if LOG_DISABLED
     
    147155    double duration = currentSession->duration();
    148156    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 
    159157    auto info = adoptCF(CFDictionaryCreateMutable(kCFAllocatorDefault, 4, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks));
    160158
Note: See TracChangeset for help on using the changeset viewer.