diff --git a/dom/system/IOUtils.cpp b/dom/system/IOUtils.cpp index 5044278990ae..07a98705210b 100644 --- a/dom/system/IOUtils.cpp +++ b/dom/system/IOUtils.cpp @@ -1597,14 +1597,20 @@ template RefPtr> IOUtils::EventQueue::Dispatch(Fn aFunc) { MOZ_RELEASE_ASSERT(mBackgroundEventTarget); - return InvokeAsync( - mBackgroundEventTarget, __func__, [func = std::move(aFunc)]() { - Result result = func(); - if (result.isErr()) { - return IOPromise::CreateAndReject(result.unwrapErr(), __func__); - } - return IOPromise::CreateAndResolve(result.unwrap(), __func__); - }); + auto promise = + MakeRefPtr::Private>(__func__); + mBackgroundEventTarget->Dispatch( + NS_NewRunnableFunction("IOUtils::EventQueue::Dispatch", + [promise, func = std::move(aFunc)] { + Result result = func(); + if (result.isErr()) { + promise->Reject(result.unwrapErr(), __func__); + } else { + promise->Resolve(result.unwrap(), __func__); + } + }), + NS_DISPATCH_EVENT_MAY_BLOCK); + return promise; }; Result, nsresult> diff --git a/tools/profiler/tests/xpcshell/test_feature_fileioall.js b/tools/profiler/tests/xpcshell/test_feature_fileioall.js index 595fe4a3186e..0e236a90c71c 100644 --- a/tools/profiler/tests/xpcshell/test_feature_fileioall.js +++ b/tools/profiler/tests/xpcshell/test_feature_fileioall.js @@ -14,7 +14,7 @@ add_task(async () => { const filename = "test_marker_fileio"; const profile = await startProfilerAndTriggerFileIO({ features: ["fileioall"], - threadsFilter: ["GeckoMain", "BackgroundThreadPool"], + threadsFilter: ["GeckoMain", "BgIOThreadPool"], filename, }); @@ -25,7 +25,7 @@ add_task(async () => { let backgroundThreadFileIO; for (const thread of threads) { // Check for FileIO in any of the background threads. - if (thread.name.startsWith("BackgroundThreadPool")) { + if (thread.name.startsWith("BgIOThreadPool")) { const markers = getInflatedFileIOMarkers(thread, filename); if (markers.length > 0) { backgroundThread = thread;