summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrian Smith <brian@dbsoft.org>2023-09-07 15:31:26 -0500
committerMoonchild <moonchild@palemoon.org>2023-09-20 03:33:14 +0200
commit6efb7a190478074710d087a3f95a5412d64125aa (patch)
tree835dde4a971e1d1db8b2dcbb4b92b8ddf9a29280
parentfa0b03a10f34178d4a5f98532c6f714bdc25ec25 (diff)
downloaduxp-6efb7a190478074710d087a3f95a5412d64125aa.tar.gz
Issue #2282 - Performance observer safety checks.
Both fixes from later revisions, without the Dispatch API changes.
-rwxr-xr-xdom/performance/Performance.cpp10
1 files changed, 8 insertions, 2 deletions
diff --git a/dom/performance/Performance.cpp b/dom/performance/Performance.cpp
index e8a46409ef..daaa72486a 100755
--- a/dom/performance/Performance.cpp
+++ b/dom/performance/Performance.cpp
@@ -676,7 +676,8 @@ public:
NS_IMETHOD Run() override
{
MOZ_ASSERT(mPerformance);
- mPerformance->NotifyObservers();
+ RefPtr<Performance> performance(mPerformance);
+ performance->NotifyObservers();
return NS_OK;
}
@@ -700,7 +701,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;
}