diff --git a/xpcom/glue/nsThreadUtils.h b/xpcom/glue/nsThreadUtils.h index a6321a99ae0..0e2d1798d97 100644 --- a/xpcom/glue/nsThreadUtils.h +++ b/xpcom/glue/nsThreadUtils.h @@ -71,9 +71,15 @@ NS_NewNamedThread(const char (&name)[LEN], nsIRunnable *initialEvent = nullptr, uint32_t stackSize = nsIThreadManager::DEFAULT_STACK_SIZE) { - nsresult rv = NS_NewThread(result, initialEvent, stackSize); - NS_SetThreadName(*result, name); - return rv; + nsresult rv = NS_NewThread(result, nullptr, stackSize); + NS_ENSURE_SUCCESS(rv, rv); + NS_SetThreadName(*result, name); + if (initialEvent) { + rv = (*result)->Dispatch(initialEvent, NS_DISPATCH_NORMAL); + NS_WARN_IF_FALSE(NS_SUCCEEDED(rv), "Initial event dispatch failed"); + } + + return rv; } /**