mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-09-05 15:28:39 +09:00
1367905 - Try to run GC/CC slices, including forgetSkippable, during idle time
1367905 - Try to run GC/CC slices, including forgetSkippable, during idle time. 1367905 - Try to run GC/CC slices, including forgetSkippable, during idle time, tweaks to keep reftest memory usage lower.
This commit is contained in:
parent
85f7844b5a
commit
137e995c26
6 changed files with 373 additions and 163 deletions
|
|
@ -1663,6 +1663,46 @@ nsRefreshDriver::RunFrameRequestCallbacks(TimeStamp aNowTime)
|
|||
}
|
||||
}
|
||||
|
||||
struct RunnableWithDelay
|
||||
{
|
||||
nsCOMPtr<nsIRunnable> mRunnable;
|
||||
uint32_t mDelay;
|
||||
};
|
||||
|
||||
static AutoTArray<RunnableWithDelay, 8>* sPendingIdleRunnables = nullptr;
|
||||
|
||||
void
|
||||
nsRefreshDriver::DispatchIdleRunnableAfterTick(nsIRunnable* aRunnable,
|
||||
uint32_t aDelay)
|
||||
{
|
||||
if (!sPendingIdleRunnables) {
|
||||
sPendingIdleRunnables = new AutoTArray<RunnableWithDelay, 8>();
|
||||
}
|
||||
|
||||
RunnableWithDelay rwd = {aRunnable, aDelay};
|
||||
sPendingIdleRunnables->AppendElement(rwd);
|
||||
}
|
||||
|
||||
void
|
||||
nsRefreshDriver::CancelIdleRunnable(nsIRunnable* aRunnable)
|
||||
{
|
||||
if (!sPendingIdleRunnables) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (uint32_t i = 0; i < sPendingIdleRunnables->Length(); ++i) {
|
||||
if ((*sPendingIdleRunnables)[i].mRunnable == aRunnable) {
|
||||
sPendingIdleRunnables->RemoveElementAt(i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (sPendingIdleRunnables->IsEmpty()) {
|
||||
delete sPendingIdleRunnables;
|
||||
sPendingIdleRunnables = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
nsRefreshDriver::Tick(int64_t aNowEpoch, TimeStamp aNowTime)
|
||||
{
|
||||
|
|
@ -1944,7 +1984,7 @@ nsRefreshDriver::Tick(int64_t aNowEpoch, TimeStamp aNowTime)
|
|||
}
|
||||
mPresShellsToInvalidateIfHidden.Clear();
|
||||
|
||||
bool notifyGC = false;
|
||||
bool dispatchRunnablesAfterTick = false;
|
||||
if (mViewManagerFlushIsPending) {
|
||||
RefPtr<TimelineConsumers> timelines = TimelineConsumers::Get();
|
||||
|
||||
|
|
@ -1982,7 +2022,7 @@ nsRefreshDriver::Tick(int64_t aNowEpoch, TimeStamp aNowTime)
|
|||
timelines->AddMarkerForDocShell(docShell, "Paint", MarkerTracingType::END);
|
||||
}
|
||||
|
||||
notifyGC = true;
|
||||
dispatchRunnablesAfterTick = true;
|
||||
}
|
||||
|
||||
nsTObserverArray<nsAPostRefreshObserver*>::ForwardIterator iter(mPostRefreshObservers);
|
||||
|
|
@ -1999,9 +2039,14 @@ nsRefreshDriver::Tick(int64_t aNowEpoch, TimeStamp aNowTime)
|
|||
ScheduleViewManagerFlush();
|
||||
}
|
||||
|
||||
if (notifyGC && nsContentUtils::XPConnect()) {
|
||||
nsContentUtils::XPConnect()->NotifyDidPaint();
|
||||
nsJSContext::NotifyDidPaint();
|
||||
if (dispatchRunnablesAfterTick && sPendingIdleRunnables) {
|
||||
AutoTArray<RunnableWithDelay, 8>* runnables = sPendingIdleRunnables;
|
||||
sPendingIdleRunnables = nullptr;
|
||||
for (uint32_t i = 0; i < runnables->Length(); ++i) {
|
||||
NS_IdleDispatchToCurrentThread((*runnables)[i].mRunnable.forget(),
|
||||
(*runnables)[i].mDelay);
|
||||
}
|
||||
delete runnables;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue