diff options
author | Alec Mouri <alecmouri@google.com> | 2020-03-26 17:17:09 -0700 |
---|---|---|
committer | Alec Mouri <alecmouri@google.com> | 2020-03-26 18:09:53 -0700 |
commit | 026106f6d68382988502b093e963bfb3d4153396 (patch) | |
tree | a5c6735b6ecae6663faff5b7285fdd0dd760ee21 /libs/hwui/renderthread/CanvasContext.cpp | |
parent | 40c41402e4817698a914015d2902d4f297643f67 (diff) |
[HWUI] Add null check for CanvasContext
If ReliableSurface is forced to acquire a fallback buffer then the
Surface may be abandoned. When getting frame timestamps we need to check
that the Surface still exists.
Bug: 152262035
Test: builds, boots
Test: dumpsys gfxinfo
Change-Id: Ifdb198ebf74cc9dc681c4ab51c4901176a7f5fc9
Diffstat (limited to 'libs/hwui/renderthread/CanvasContext.cpp')
-rw-r--r-- | libs/hwui/renderthread/CanvasContext.cpp | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/libs/hwui/renderthread/CanvasContext.cpp b/libs/hwui/renderthread/CanvasContext.cpp index 4299dd3b46fe..c19b1878ad45 100644 --- a/libs/hwui/renderthread/CanvasContext.cpp +++ b/libs/hwui/renderthread/CanvasContext.cpp @@ -555,9 +555,11 @@ void CanvasContext::draw() { FrameInfo* forthBehind = mLast4FrameInfos.front().first; int64_t composedFrameId = mLast4FrameInfos.front().second; nsecs_t acquireTime = -1; - native_window_get_frame_timestamps(mNativeSurface->getNativeWindow(), composedFrameId, - nullptr, &acquireTime, nullptr, nullptr, nullptr, - nullptr, nullptr, nullptr, nullptr); + if (mNativeSurface) { + native_window_get_frame_timestamps(mNativeSurface->getNativeWindow(), composedFrameId, + nullptr, &acquireTime, nullptr, nullptr, nullptr, + nullptr, nullptr, nullptr, nullptr); + } // Ignore default -1, NATIVE_WINDOW_TIMESTAMP_INVALID and NATIVE_WINDOW_TIMESTAMP_PENDING forthBehind->set(FrameInfoIndex::GpuCompleted) = acquireTime > 0 ? acquireTime : -1; mJankTracker.finishGpuDraw(*forthBehind); |