summaryrefslogtreecommitdiff
path: root/dom
diff options
context:
space:
mode:
authorBrian Smith <brian@dbsoft.org>2023-09-07 15:31:26 -0500
committerBrian Smith <brian@dbsoft.org>2023-09-07 15:31:26 -0500
commit01ee4539cb946c732ead407cbda3d5ec3caa7804 (patch)
tree452ae7f5a52513fb712dd1787c8007fc5aa02df3 /dom
parent47fbe9552a80507a2dee5b8c1c9b23e237fea9d8 (diff)
downloaduxp-01ee4539cb946c732ead407cbda3d5ec3caa7804.tar.gz
Issue #2282 - Performance observer safety checks.
Both fixes from later revisions, without the Dispatch API changes.
Diffstat (limited to 'dom')
-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;
}