From bb6429d366f0195848b0b71fbe89b0f77ce4db75 Mon Sep 17 00:00:00 2001 From: JW Wang Date: Tue, 19 Dec 2017 17:38:40 +0800 Subject: [PATCH] Bug 1426578. P5 - offload Init() to another thread. r=bechen,gerald MozReview-Commit-ID: Fv7eq39GNsk --HG-- extra : rebase_source : 483cd70c65a4f724b40aaa11eece60b6a2a85e25 extra : source : db2632bf1828721b94bda877bf23bc59d189206e --- dom/media/MediaCache.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/dom/media/MediaCache.cpp b/dom/media/MediaCache.cpp index e82ba40d6e65..0c533a3e98d6 100644 --- a/dom/media/MediaCache.cpp +++ b/dom/media/MediaCache.cpp @@ -2868,8 +2868,13 @@ MediaCacheStream::Init(int64_t aContentLength) return NS_ERROR_FAILURE; } - AutoLock lock(mMediaCache->Monitor()); - mMediaCache->OpenStream(lock, this); + OwnerThread()->Dispatch(NS_NewRunnableFunction( + "MediaCacheStream::Init", + [ this, res = RefPtr(mClient) ]() { + AutoLock lock(mMediaCache->Monitor()); + mMediaCache->OpenStream(lock, this); + })); + return NS_OK; }