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()) {
|
if (CycleCollectedJSContext* ccjs = CycleCollectedJSContext::Get()) {
|
||||||
mMicroTaskLevel = ccjs->MicroTaskLevel();
|
mMicroTaskLevel = ccjs->MicroTaskLevel();
|
||||||
ccjs->SetMicroTaskLevel(0);
|
ccjs->SetMicroTaskLevel(0);
|
||||||
|
ccjs->EnterSyncOperation();
|
||||||
}
|
}
|
||||||
if (aDoc) {
|
if (aDoc) {
|
||||||
mBrowsingContext = aDoc->GetBrowsingContext();
|
mBrowsingContext = aDoc->GetBrowsingContext();
|
||||||
@@ -17398,6 +17399,7 @@ nsAutoSyncOperation::~nsAutoSyncOperation() {
|
|||||||
CycleCollectedJSContext* ccjs = CycleCollectedJSContext::Get();
|
CycleCollectedJSContext* ccjs = CycleCollectedJSContext::Get();
|
||||||
if (ccjs) {
|
if (ccjs) {
|
||||||
ccjs->SetMicroTaskLevel(mMicroTaskLevel);
|
ccjs->SetMicroTaskLevel(mMicroTaskLevel);
|
||||||
|
ccjs->LeaveSyncOperation();
|
||||||
}
|
}
|
||||||
if (mBrowsingContext &&
|
if (mBrowsingContext &&
|
||||||
mSyncBehavior == SyncOperationBehavior::eSuspendInput &&
|
mSyncBehavior == SyncOperationBehavior::eSuspendInput &&
|
||||||
|
|||||||
@@ -59,6 +59,7 @@ CycleCollectedJSContext::CycleCollectedJSContext()
|
|||||||
mDoingStableStates(false),
|
mDoingStableStates(false),
|
||||||
mTargetedMicroTaskRecursionDepth(0),
|
mTargetedMicroTaskRecursionDepth(0),
|
||||||
mMicroTaskLevel(0),
|
mMicroTaskLevel(0),
|
||||||
|
mSyncOperations(0),
|
||||||
mSuppressionGeneration(0),
|
mSuppressionGeneration(0),
|
||||||
mDebuggerRecursionDepth(0),
|
mDebuggerRecursionDepth(0),
|
||||||
mMicroTaskRecursionDepth(0),
|
mMicroTaskRecursionDepth(0),
|
||||||
@@ -783,7 +784,10 @@ bool CycleCollectedJSContext::PerformMicroTaskCheckPoint(bool aForce) {
|
|||||||
break;
|
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.
|
// Microtasks in worker shall never be suppressed.
|
||||||
// Otherwise, mPendingMicroTaskRunnables will be replaced later with
|
// Otherwise, mPendingMicroTaskRunnables will be replaced later with
|
||||||
// all suppressed tasks in mDebuggerMicroTaskQueue unexpectedly.
|
// 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 SetMicroTaskLevel(uint32_t aLevel) { mMicroTaskLevel = aLevel; }
|
||||||
|
|
||||||
|
void EnterSyncOperation() { ++mSyncOperations; }
|
||||||
|
void LeaveSyncOperation() { --mSyncOperations; }
|
||||||
|
bool IsInSyncOperation() const { return mSyncOperations > 0; }
|
||||||
|
|
||||||
MOZ_CAN_RUN_SCRIPT
|
MOZ_CAN_RUN_SCRIPT
|
||||||
bool PerformMicroTaskCheckPoint(bool aForce = false);
|
bool PerformMicroTaskCheckPoint(bool aForce = false);
|
||||||
|
|
||||||
@@ -339,6 +343,8 @@ class CycleCollectedJSContext : dom::PerThreadAtomCache, private JS::JobQueue {
|
|||||||
|
|
||||||
uint32_t mMicroTaskLevel;
|
uint32_t mMicroTaskLevel;
|
||||||
|
|
||||||
|
uint32_t mSyncOperations;
|
||||||
|
|
||||||
std::deque<RefPtr<MicroTaskRunnable>> mPendingMicroTaskRunnables;
|
std::deque<RefPtr<MicroTaskRunnable>> mPendingMicroTaskRunnables;
|
||||||
std::deque<RefPtr<MicroTaskRunnable>> mDebuggerMicroTaskQueue;
|
std::deque<RefPtr<MicroTaskRunnable>> mDebuggerMicroTaskQueue;
|
||||||
RefPtr<SuppressedMicroTasks> mSuppressedMicroTasks;
|
RefPtr<SuppressedMicroTasks> mSuppressedMicroTasks;
|
||||||
|
|||||||
Reference in New Issue
Block a user