Bug 1691517: Do not crash inside TaskController when the main thread is unavailable. r=smaug

Differential Revision: https://phabricator.services.mozilla.com/D105402
This commit is contained in:
Bas Schouten 2021-02-18 03:53:29 +00:00
Родитель d3f260db6d
Коммит bbb0d338be
1 изменённых файлов: 12 добавлений и 5 удалений

Просмотреть файл

@ -655,10 +655,15 @@ bool TaskController::ExecuteNextTaskOnlyMainThreadInternal(
bool TaskController::DoExecuteNextTaskOnlyMainThreadInternal( bool TaskController::DoExecuteNextTaskOnlyMainThreadInternal(
const MutexAutoLock& aProofOfLock) { const MutexAutoLock& aProofOfLock) {
#ifdef MOZ_GECKO_PROFILER
nsCOMPtr<nsIThread> mainIThread; nsCOMPtr<nsIThread> mainIThread;
NS_GetMainThread(getter_AddRefs(mainIThread)); NS_GetMainThread(getter_AddRefs(mainIThread));
nsThread* mainThread = static_cast<nsThread*>(mainIThread.get()); nsThread* mainThread = static_cast<nsThread*>(mainIThread.get());
mainThread->SetRunningEventDelay(TimeDuration(), TimeStamp()); if (mainThread) {
mainThread->SetRunningEventDelay(TimeDuration(), TimeStamp());
}
#endif
uint32_t totalSuspended = 0; uint32_t totalSuspended = 0;
for (TaskManager* manager : mTaskManagers) { for (TaskManager* manager : mTaskManagers) {
@ -735,10 +740,12 @@ bool TaskController::DoExecuteNextTaskOnlyMainThreadInternal(
TimeStamp now = TimeStamp::Now(); TimeStamp now = TimeStamp::Now();
#ifdef MOZ_GECKO_PROFILER #ifdef MOZ_GECKO_PROFILER
if (task->GetPriority() < uint32_t(EventQueuePriority::InputHigh)) { if (mainThread) {
mainThread->SetRunningEventDelay(TimeDuration(), now); if (task->GetPriority() < uint32_t(EventQueuePriority::InputHigh)) {
} else { mainThread->SetRunningEventDelay(TimeDuration(), now);
mainThread->SetRunningEventDelay(now - task->mInsertionTime, now); } else {
mainThread->SetRunningEventDelay(now - task->mInsertionTime, now);
}
} }
#endif #endif