--- a/dom/media/MediaDecoder.cpp
+++ b/dom/media/MediaDecoder.cpp
@@ -58,16 +58,18 @@ static const uint64_t ESTIMATED_DURATION
LazyLogModule gMediaDecoderLog("MediaDecoder");
#define DECODER_LOG(x, ...) \
MOZ_LOG(gMediaDecoderLog, LogLevel::Debug, ("Decoder=%p " x, this, ##__VA_ARGS__))
#define DUMP_LOG(x, ...) \
NS_DebugBreak(NS_DEBUG_WARNING, nsPrintfCString("Decoder=%p " x, this, ##__VA_ARGS__).get(), nullptr, nullptr, -1)
+#define NS_DispatchToMainThread(...) CompileError_UseAbstractMainThreadInstead
+
static const char*
ToPlayStateStr(MediaDecoder::PlayState aState)
{
switch (aState) {
case MediaDecoder::PLAY_STATE_START: return "START";
case MediaDecoder::PLAY_STATE_LOADING: return "LOADING";
case MediaDecoder::PLAY_STATE_PAUSED: return "PAUSED";
case MediaDecoder::PLAY_STATE_PLAYING: return "PLAYING";
@@ -149,16 +151,17 @@ MediaDecoder::ResourceCallback::Resource
}
void
MediaDecoder::ResourceCallback::Connect(MediaDecoder* aDecoder)
{
MOZ_ASSERT(NS_IsMainThread());
mDecoder = aDecoder;
mTimer = do_CreateInstance("@mozilla.org/timer;1");
+ mTimer->SetTarget(mAbstractMainThread->AsEventTarget());
}
void
MediaDecoder::ResourceCallback::Disconnect()
{
MOZ_ASSERT(NS_IsMainThread());
if (mDecoder) {
mDecoder = nullptr;
@@ -1650,18 +1653,18 @@ MediaMemoryTracker::CollectReports(nsIHa
// resources memory and finish the asynchronous memory report.
RefPtr<MediaDecoder::ResourceSizes> resourceSizes =
new MediaDecoder::ResourceSizes(MediaMemoryTracker::MallocSizeOf);
nsCOMPtr<nsIHandleReportCallback> handleReport = aHandleReport;
nsCOMPtr<nsISupports> data = aData;
resourceSizes->Promise()->Then(
- // Non-DocGroup version of AbstractThread::MainThread is fine for memory
- // report.
+ // Don't use SystemGroup::AbstractMainThreadFor() for
+ // handleReport->Callback() will run scripts.
AbstractThread::MainThread(),
__func__,
[handleReport, data] (size_t size) {
handleReport->Callback(
EmptyCString(), NS_LITERAL_CSTRING("explicit/media/resources"),
KIND_HEAP, UNITS_BYTES, size,
NS_LITERAL_CSTRING("Memory used by media resources including "
"streaming buffers, caches, etc."),
@@ -1810,17 +1813,17 @@ MediaDecoder::DumpDebugInfo()
if (!GetStateMachine()) {
DUMP_LOG("%s", str.get());
return;
}
RefPtr<MediaDecoder> self = this;
GetStateMachine()->RequestDebugInfo()->Then(
- AbstractThread::MainThread(), __func__,
+ SystemGroup::AbstractMainThreadFor(TaskCategory::Other), __func__,
[this, self, str] (const nsACString& aString) {
DUMP_LOG("%s", str.get());
DUMP_LOG("%s", aString.Data());
},
[this, self, str] () {
DUMP_LOG("%s", str.get());
});
}
@@ -1831,17 +1834,17 @@ MediaDecoder::RequestDebugInfo()
MOZ_DIAGNOSTIC_ASSERT(!IsShutdown());
auto str = GetDebugInfo();
if (!GetStateMachine()) {
return DebugInfoPromise::CreateAndResolve(str, __func__);
}
return GetStateMachine()->RequestDebugInfo()->Then(
- AbstractThread::MainThread(), __func__,
+ SystemGroup::AbstractMainThreadFor(TaskCategory::Other), __func__,
[str] (const nsACString& aString) {
nsCString result = str + nsCString("\n") + aString;
return DebugInfoPromise::CreateAndResolve(result, __func__);
},
[str] () {
return DebugInfoPromise::CreateAndResolve(str, __func__);
});
}
@@ -1867,8 +1870,9 @@ MediaMemoryTracker::~MediaMemoryTracker(
{
UnregisterWeakMemoryReporter(this);
}
} // namespace mozilla
// avoid redefined macro in unified build
#undef DECODER_LOG
+#undef NS_DispatchToMainThread