Merge "Add logic to clean up resources more frequently" into sc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
54fbff341e
@@ -210,6 +210,14 @@ void CacheManager::onFrameCompleted() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CacheManager::performDeferredCleanup(nsecs_t cleanupOlderThanMillis) {
|
||||||
|
if (mGrContext) {
|
||||||
|
mGrContext->performDeferredCleanup(
|
||||||
|
std::chrono::milliseconds(cleanupOlderThanMillis),
|
||||||
|
/* scratchResourcesOnly */true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
} /* namespace renderthread */
|
} /* namespace renderthread */
|
||||||
} /* namespace uirenderer */
|
} /* namespace uirenderer */
|
||||||
} /* namespace android */
|
} /* namespace android */
|
||||||
|
|||||||
@@ -23,6 +23,7 @@
|
|||||||
#include <SkSurface.h>
|
#include <SkSurface.h>
|
||||||
#include <utils/String8.h>
|
#include <utils/String8.h>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
#include "utils/TimeUtils.h"
|
||||||
|
|
||||||
namespace android {
|
namespace android {
|
||||||
|
|
||||||
@@ -53,6 +54,8 @@ public:
|
|||||||
size_t getBackgroundCacheSize() const { return mBackgroundResourceBytes; }
|
size_t getBackgroundCacheSize() const { return mBackgroundResourceBytes; }
|
||||||
void onFrameCompleted();
|
void onFrameCompleted();
|
||||||
|
|
||||||
|
void performDeferredCleanup(nsecs_t cleanupOlderThanMillis);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
friend class RenderThread;
|
friend class RenderThread;
|
||||||
|
|
||||||
|
|||||||
@@ -461,6 +461,7 @@ void CanvasContext::prepareTree(TreeInfo& info, int64_t* uiFrameInfo, int64_t sy
|
|||||||
}
|
}
|
||||||
|
|
||||||
void CanvasContext::stopDrawing() {
|
void CanvasContext::stopDrawing() {
|
||||||
|
cleanupResources();
|
||||||
mRenderThread.removeFrameCallback(this);
|
mRenderThread.removeFrameCallback(this);
|
||||||
mAnimationContext->pauseAnimators();
|
mAnimationContext->pauseAnimators();
|
||||||
mGenerationID++;
|
mGenerationID++;
|
||||||
@@ -619,10 +620,25 @@ nsecs_t CanvasContext::draw() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cleanupResources();
|
||||||
mRenderThread.cacheManager().onFrameCompleted();
|
mRenderThread.cacheManager().onFrameCompleted();
|
||||||
return mCurrentFrameInfo->get(FrameInfoIndex::DequeueBufferDuration);
|
return mCurrentFrameInfo->get(FrameInfoIndex::DequeueBufferDuration);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CanvasContext::cleanupResources() {
|
||||||
|
auto& tracker = mJankTracker.frames();
|
||||||
|
auto size = tracker.size();
|
||||||
|
auto capacity = tracker.capacity();
|
||||||
|
if (size == capacity) {
|
||||||
|
nsecs_t nowNanos = systemTime(SYSTEM_TIME_MONOTONIC);
|
||||||
|
nsecs_t frameCompleteNanos =
|
||||||
|
tracker[0].get(FrameInfoIndex::FrameCompleted);
|
||||||
|
nsecs_t frameDiffNanos = nowNanos - frameCompleteNanos;
|
||||||
|
nsecs_t cleanupMillis = ns2ms(std::max(frameDiffNanos, 10_s));
|
||||||
|
mRenderThread.cacheManager().performDeferredCleanup(cleanupMillis);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void CanvasContext::reportMetricsWithPresentTime() {
|
void CanvasContext::reportMetricsWithPresentTime() {
|
||||||
if (mFrameMetricsReporter == nullptr) {
|
if (mFrameMetricsReporter == nullptr) {
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -312,6 +312,7 @@ private:
|
|||||||
bool mExpectSurfaceStats = false;
|
bool mExpectSurfaceStats = false;
|
||||||
|
|
||||||
std::function<void(int64_t, int64_t, int64_t)> mASurfaceTransactionCallback;
|
std::function<void(int64_t, int64_t, int64_t)> mASurfaceTransactionCallback;
|
||||||
|
void cleanupResources();
|
||||||
};
|
};
|
||||||
|
|
||||||
} /* namespace renderthread */
|
} /* namespace renderthread */
|
||||||
|
|||||||
Reference in New Issue
Block a user