Bug 1172394 - Hinge UpdateReadyStateInternal off watchables instead of direct updates. r=bryce

Differential Revision: https://phabricator.services.mozilla.com/D52047

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Andreas Pehrson 2019-11-13 08:56:44 +00:00
Родитель 8343246e20
Коммит af96d72e5f
2 изменённых файлов: 24 добавлений и 15 удалений

Просмотреть файл

@ -3775,7 +3775,6 @@ HTMLMediaElement::HTMLMediaElement(
OwnerDoc()->AbstractMainThreadFor(TaskCategory::Other)),
mShutdownObserver(new ShutdownObserver),
mPlayed(new TimeRanges(ToSupports(OwnerDoc()))),
mPaused(true, "HTMLMediaElement::mPaused"),
mTracksCaptured(nullptr, "HTMLMediaElement::mTracksCaptured"),
mErrorSink(new ErrorSink(this)),
mAudioChannelWrapper(new AudioChannelAgentCallback(this)),
@ -3808,6 +3807,13 @@ void HTMLMediaElement::Init() {
&HTMLMediaElement::UpdateOutputTrackSources);
mWatchManager.Watch(mReadyState, &HTMLMediaElement::UpdateOutputTrackSources);
mWatchManager.Watch(mDownloadSuspendedByCache,
&HTMLMediaElement::UpdateReadyStateInternal);
mWatchManager.Watch(mFirstFrameLoaded,
&HTMLMediaElement::UpdateReadyStateInternal);
mWatchManager.Watch(mSrcStreamPlaybackEnded,
&HTMLMediaElement::UpdateReadyStateInternal);
ErrorResult rv;
double defaultVolume = Preferences::GetFloat("media.default_volume", 1.0);
@ -4902,7 +4908,6 @@ class HTMLMediaElement::MediaStreamTrackListener
mElement->mSrcStream.get()));
mElement->PlaybackEnded();
mElement->UpdateReadyStateInternal();
}
void NotifyInactive() override {
@ -5160,8 +5165,8 @@ void HTMLMediaElement::NotifyMediaStreamTrackAdded(
}
}
UpdateReadyStateInternal();
// The set of enabled AudioTracks and selected video track might have changed.
mWatchManager.ManualNotify(&HTMLMediaElement::UpdateReadyStateInternal);
mAbstractMainThread->TailDispatcher().AddDirectTask(
NewRunnableMethod("HTMLMediaElement::FirstFrameLoaded", this,
&HTMLMediaElement::FirstFrameLoaded));
@ -5266,19 +5271,18 @@ void HTMLMediaElement::MetadataLoaded(const MediaInfo* aInfo,
mDefaultPlaybackStartPosition = 0.0;
}
UpdateReadyStateInternal();
mWatchManager.ManualNotify(&HTMLMediaElement::UpdateReadyStateInternal);
}
void HTMLMediaElement::FirstFrameLoaded() {
LOG(LogLevel::Debug,
("%p, FirstFrameLoaded() mFirstFrameLoaded=%d mWaitingForKey=%d", this,
mFirstFrameLoaded, mWaitingForKey));
mFirstFrameLoaded.Ref(), mWaitingForKey));
NS_ASSERTION(!mSuspendedAfterFirstFrame, "Should not have already suspended");
if (!mFirstFrameLoaded) {
mFirstFrameLoaded = true;
UpdateReadyStateInternal();
}
ChangeDelayLoadStatus(false);
@ -5431,7 +5435,6 @@ void HTMLMediaElement::SeekAborted() {
void HTMLMediaElement::NotifySuspendedByCache(bool aSuspendedByCache) {
mDownloadSuspendedByCache = aSuspendedByCache;
UpdateReadyStateInternal();
}
void HTMLMediaElement::DownloadSuspended() {
@ -5486,7 +5489,7 @@ void HTMLMediaElement::CheckProgress(bool aHaveNewProgress) {
}
// Download statistics may have been updated, force a recheck of the
// readyState.
UpdateReadyStateInternal();
mWatchManager.ManualNotify(&HTMLMediaElement::UpdateReadyStateInternal);
}
if (now - mDataTime >= TimeDuration::FromMilliseconds(STALL_MS)) {
@ -6220,7 +6223,7 @@ void HTMLMediaElement::UpdateMediaSize(const nsIntSize& aSize) {
}
mMediaInfo.mVideo.mDisplay = aSize;
UpdateReadyStateInternal();
mWatchManager.ManualNotify(&HTMLMediaElement::UpdateReadyStateInternal);
if (mFirstFrameListener) {
mSelectedVideoStreamTrack->RemoveVideoOutput(mFirstFrameListener);
@ -6963,7 +6966,9 @@ void HTMLMediaElement::NotifyWaitingForKey() {
// Note: algorithm continues in UpdateReadyStateInternal() when all decoded
// data enqueued in the MDSM is consumed.
mWaitingForKey = WAITING_FOR_KEY;
UpdateReadyStateInternal();
// mWaitingForKey changed outside of UpdateReadyStateInternal. This may
// affect mReadyState.
mWatchManager.ManualNotify(&HTMLMediaElement::UpdateReadyStateInternal);
}
}

Просмотреть файл

@ -271,7 +271,9 @@ class HTMLMediaElement : public nsGenericHTMLElement,
void DispatchAsyncEvent(const nsAString& aName) final;
// Triggers a recomputation of readyState.
void UpdateReadyState() override { UpdateReadyStateInternal(); }
void UpdateReadyState() override {
mWatchManager.ManualNotify(&HTMLMediaElement::UpdateReadyStateInternal);
}
// Dispatch events that were raised while in the bfcache
nsresult DispatchPendingMediaEvents();
@ -1561,7 +1563,7 @@ class HTMLMediaElement : public nsGenericHTMLElement,
// Playback of the video is paused either due to calling the
// 'Pause' method, or playback not yet having started.
Watchable<bool> mPaused;
Watchable<bool> mPaused = {true, "HTMLMediaElement::mPaused"};
// The following two fields are here for the private storage of the builtin
// video controls, and control 'casting' of the video to external devices
@ -1680,7 +1682,8 @@ class HTMLMediaElement : public nsGenericHTMLElement,
EncryptionInfo mPendingEncryptedInitData;
// True if the media's channel's download has been suspended.
bool mDownloadSuspendedByCache = false;
Watchable<bool> mDownloadSuspendedByCache = {
false, "HTMLMediaElement::mDownloadSuspendedByCache"};
// Disable the video playback by track selection. This flag might not be
// enough if we ever expand the ability of supporting multi-tracks video
@ -1818,7 +1821,8 @@ class HTMLMediaElement : public nsGenericHTMLElement,
bool mIsBlessed = false;
// True if the first frame has been successfully loaded.
bool mFirstFrameLoaded = false;
Watchable<bool> mFirstFrameLoaded = {false,
"HTMLMediaElement::mFirstFrameLoaded"};
// Media elements also have a default playback start position, which must
// initially be set to zero seconds. This time is used to allow the element to