Bug 1959303 - Avoid calling MicroTaskRunnable::Suppressed if it can't return true, r=mccr8
Differential Revision: https://phabricator.services.mozilla.com/D244848
This commit is contained in:
@@ -17359,6 +17359,7 @@ nsAutoSyncOperation::nsAutoSyncOperation(Document* aDoc,
|
||||
if (CycleCollectedJSContext* ccjs = CycleCollectedJSContext::Get()) {
|
||||
mMicroTaskLevel = ccjs->MicroTaskLevel();
|
||||
ccjs->SetMicroTaskLevel(0);
|
||||
ccjs->EnterSyncOperation();
|
||||
}
|
||||
if (aDoc) {
|
||||
mBrowsingContext = aDoc->GetBrowsingContext();
|
||||
@@ -17398,6 +17399,7 @@ nsAutoSyncOperation::~nsAutoSyncOperation() {
|
||||
CycleCollectedJSContext* ccjs = CycleCollectedJSContext::Get();
|
||||
if (ccjs) {
|
||||
ccjs->SetMicroTaskLevel(mMicroTaskLevel);
|
||||
ccjs->LeaveSyncOperation();
|
||||
}
|
||||
if (mBrowsingContext &&
|
||||
mSyncBehavior == SyncOperationBehavior::eSuspendInput &&
|
||||
|
||||
@@ -59,6 +59,7 @@ CycleCollectedJSContext::CycleCollectedJSContext()
|
||||
mDoingStableStates(false),
|
||||
mTargetedMicroTaskRecursionDepth(0),
|
||||
mMicroTaskLevel(0),
|
||||
mSyncOperations(0),
|
||||
mSuppressionGeneration(0),
|
||||
mDebuggerRecursionDepth(0),
|
||||
mMicroTaskRecursionDepth(0),
|
||||
@@ -783,7 +784,10 @@ bool CycleCollectedJSContext::PerformMicroTaskCheckPoint(bool aForce) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (runnable->Suppressed()) {
|
||||
// No need to check Suppressed if there aren't ongoing sync operations nor
|
||||
// pending mSuppressedMicroTasks.
|
||||
if ((IsInSyncOperation() || mSuppressedMicroTasks) &&
|
||||
runnable->Suppressed()) {
|
||||
// Microtasks in worker shall never be suppressed.
|
||||
// Otherwise, mPendingMicroTaskRunnables will be replaced later with
|
||||
// all suppressed tasks in mDebuggerMicroTaskQueue unexpectedly.
|
||||
|
||||
@@ -246,6 +246,10 @@ class CycleCollectedJSContext : dom::PerThreadAtomCache, private JS::JobQueue {
|
||||
|
||||
void SetMicroTaskLevel(uint32_t aLevel) { mMicroTaskLevel = aLevel; }
|
||||
|
||||
void EnterSyncOperation() { ++mSyncOperations; }
|
||||
void LeaveSyncOperation() { --mSyncOperations; }
|
||||
bool IsInSyncOperation() const { return mSyncOperations > 0; }
|
||||
|
||||
MOZ_CAN_RUN_SCRIPT
|
||||
bool PerformMicroTaskCheckPoint(bool aForce = false);
|
||||
|
||||
@@ -339,6 +343,8 @@ class CycleCollectedJSContext : dom::PerThreadAtomCache, private JS::JobQueue {
|
||||
|
||||
uint32_t mMicroTaskLevel;
|
||||
|
||||
uint32_t mSyncOperations;
|
||||
|
||||
std::deque<RefPtr<MicroTaskRunnable>> mPendingMicroTaskRunnables;
|
||||
std::deque<RefPtr<MicroTaskRunnable>> mDebuggerMicroTaskQueue;
|
||||
RefPtr<SuppressedMicroTasks> mSuppressedMicroTasks;
|
||||
|
||||
Reference in New Issue
Block a user