Issue #2282 - Performance observer safety checks. Both fixes from later revisions, without the Dispatch API changes.

This commit is contained in:
Brian Smith 2023-09-07 15:31:26 -05:00 committed by roytam1
commit 470af6ba50

View file

@ -675,7 +675,8 @@ public:
NS_IMETHOD Run() override
{
MOZ_ASSERT(mPerformance);
mPerformance->NotifyObservers();
RefPtr<Performance> performance(mPerformance);
performance->NotifyObservers();
return NS_OK;
}
@ -699,7 +700,12 @@ Performance::RunNotificationObserversTask()
{
mPendingNotificationObserversTask = true;
nsCOMPtr<nsIRunnable> task = new NotifyObserversTask(this);
nsresult rv = NS_DispatchToCurrentThread(task);
nsresult rv;
if (NS_IsMainThread()) {
rv = NS_DispatchToCurrentThread(task);
} else {
rv = NS_DispatchToMainThread(task);
}
if (NS_WARN_IF(NS_FAILED(rv))) {
mPendingNotificationObserversTask = false;
}