Bug 1344357 P1 - move the MediaDecoder::mSeekDOMPromise to HTMLMediaElement; r=jwwang
There was a cycle amoung a window object -> a HTMLMediaElement -> a MediaDecoder -> a Promise (-> back to the window object). And we have no way to break the cycle since the MediaDecoder does not participate into the collection. By moving the Promise form MediaDecoder to HTMLMediaElement, we will be able to break the cycle since the HTMLMediaElement is in the collection. We'll implement the cycle collection in the next patch. MozReview-Commit-ID: CyVXBl6IMI3
This commit is contained in:
@@ -2731,6 +2731,9 @@ HTMLMediaElement::Seek(double aTime,
|
||||
// We changed whether we're seeking so we need to AddRemoveSelfReference.
|
||||
AddRemoveSelfReference();
|
||||
|
||||
// Keep the DOM promise.
|
||||
mSeekDOMPromise = promise;
|
||||
|
||||
return promise.forget();
|
||||
}
|
||||
|
||||
@@ -7490,5 +7493,33 @@ bool HasDebuggerPrivilege(JSContext* aCx, JSObject* aObj)
|
||||
NS_LITERAL_STRING("debugger"));
|
||||
}
|
||||
|
||||
void
|
||||
HTMLMediaElement::AsyncResolveSeekDOMPromiseIfExists()
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
if (mSeekDOMPromise) {
|
||||
RefPtr<dom::Promise> promise = mSeekDOMPromise.forget();
|
||||
nsCOMPtr<nsIRunnable> r = NS_NewRunnableFunction([=] () {
|
||||
promise->MaybeResolveWithUndefined();
|
||||
});
|
||||
mAbstractMainThread->Dispatch(r.forget());
|
||||
mSeekDOMPromise = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
HTMLMediaElement::AsyncRejectSeekDOMPromiseIfExists()
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
if (mSeekDOMPromise) {
|
||||
RefPtr<dom::Promise> promise = mSeekDOMPromise.forget();
|
||||
nsCOMPtr<nsIRunnable> r = NS_NewRunnableFunction([=] () {
|
||||
promise->MaybeReject(NS_ERROR_DOM_ABORT_ERR);
|
||||
});
|
||||
mAbstractMainThread->Dispatch(r.forget());
|
||||
mSeekDOMPromise = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
||||
Reference in New Issue
Block a user