From 086645d88a10574ea54aed011bc00b5160ff72f1 Mon Sep 17 00:00:00 2001 From: Nader Jawad Date: Fri, 24 Sep 2021 13:42:47 -0700 Subject: Update RenderEffectCache capability query Updated logic to determine if RenderEffectCache is supported to very both the vendor name as well as the corresponding driver version. Bug: 193145089 Test: Added test to EglManagerTests + RenderEffectCapabilityQueryTests Change-Id: Ia0fd66c40790b94566f495d2c4128c4988d406b6 --- libs/hwui/Properties.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'libs/hwui/Properties.cpp') diff --git a/libs/hwui/Properties.cpp b/libs/hwui/Properties.cpp index 35449875d324..475fd700ccc9 100644 --- a/libs/hwui/Properties.cpp +++ b/libs/hwui/Properties.cpp @@ -50,7 +50,8 @@ bool Properties::showDirtyRegions = false; bool Properties::skipEmptyFrames = true; bool Properties::useBufferAge = true; bool Properties::enablePartialUpdates = true; -bool Properties::enableRenderEffectCache = false; +// Default true unless otherwise specified in RenderThread Configuration +bool Properties::enableRenderEffectCache = true; DebugLevel Properties::debugLevel = kDebugDisabled; OverdrawColorSet Properties::overdrawColorSet = OverdrawColorSet::Default; -- cgit v1.2.3-59-g8ed1b From 10f05d8f000b9b9bc12e0a636fc9904487adf7ab Mon Sep 17 00:00:00 2001 From: Nader Jawad Date: Mon, 20 Sep 2021 21:22:50 -0700 Subject: Conditionally cache RenderEffect results Added property to conditionally cache SkImage instances with SkImageFilters applied. Some GL vendor implementations invoke Fence::waitForver without signalling, leading to ANRs throughout the system. Bug: 193145089 Test: manual Change-Id: I3e478b11b66205d96e9499a362f7412a1d6e952d Merged-In: I3e478b11b66205d96e9499a362f7412a1d6e952d --- libs/hwui/Properties.cpp | 1 + libs/hwui/Properties.h | 1 + libs/hwui/pipeline/skia/RenderNodeDrawable.cpp | 36 ++++++++++++++++++++------ libs/hwui/renderthread/EglManager.cpp | 3 +++ 4 files changed, 33 insertions(+), 8 deletions(-) (limited to 'libs/hwui/Properties.cpp') diff --git a/libs/hwui/Properties.cpp b/libs/hwui/Properties.cpp index 109b5352fe30..35449875d324 100644 --- a/libs/hwui/Properties.cpp +++ b/libs/hwui/Properties.cpp @@ -50,6 +50,7 @@ bool Properties::showDirtyRegions = false; bool Properties::skipEmptyFrames = true; bool Properties::useBufferAge = true; bool Properties::enablePartialUpdates = true; +bool Properties::enableRenderEffectCache = false; DebugLevel Properties::debugLevel = kDebugDisabled; OverdrawColorSet Properties::overdrawColorSet = OverdrawColorSet::Default; diff --git a/libs/hwui/Properties.h b/libs/hwui/Properties.h index 7df6e2c92247..d224a547ab4d 100644 --- a/libs/hwui/Properties.h +++ b/libs/hwui/Properties.h @@ -224,6 +224,7 @@ public: static bool skipEmptyFrames; static bool useBufferAge; static bool enablePartialUpdates; + static bool enableRenderEffectCache; // TODO: Move somewhere else? static constexpr float textGamma = 1.45f; diff --git a/libs/hwui/pipeline/skia/RenderNodeDrawable.cpp b/libs/hwui/pipeline/skia/RenderNodeDrawable.cpp index 7556af918170..2c81c971f7a6 100644 --- a/libs/hwui/pipeline/skia/RenderNodeDrawable.cpp +++ b/libs/hwui/pipeline/skia/RenderNodeDrawable.cpp @@ -231,14 +231,34 @@ void RenderNodeDrawable::drawContent(SkCanvas* canvas) const { SkASSERT(properties.effectiveLayerType() == LayerType::RenderLayer); SkPaint paint; layerNeedsPaint(layerProperties, alphaMultiplier, &paint); - const auto snapshotResult = renderNode->updateSnapshotIfRequired( - canvas->recordingContext(), - layerProperties.getImageFilter(), - clipBounds.roundOut() - ); - sk_sp snapshotImage = snapshotResult->snapshot; - srcBounds = snapshotResult->outSubset; - offset = snapshotResult->outOffset; + sk_sp snapshotImage; + auto* imageFilter = layerProperties.getImageFilter(); + auto recordingContext = canvas->recordingContext(); + // On some GL vendor implementations, caching the result of + // getLayerSurface->makeImageSnapshot() causes a call to + // Fence::waitForever without a corresponding signal. This would + // lead to ANRs throughout the system. + // Instead only cache the SkImage created with the SkImageFilter + // for supported devices. Otherwise just create a new SkImage with + // the corresponding SkImageFilter each time. + // See b/193145089 and b/197263715 + if (!Properties::enableRenderEffectCache) { + if (imageFilter) { + auto subset = SkIRect::MakeWH(srcBounds.width(), srcBounds.height()); + snapshotImage = snapshotImage->makeWithFilter(recordingContext, imageFilter, + subset, clipBounds.roundOut(), + &srcBounds, &offset); + } else { + snapshotImage = renderNode->getLayerSurface()->makeImageSnapshot(); + } + } else { + const auto snapshotResult = renderNode->updateSnapshotIfRequired( + recordingContext, layerProperties.getImageFilter(), clipBounds.roundOut()); + snapshotImage = snapshotResult->snapshot; + srcBounds = snapshotResult->outSubset; + offset = snapshotResult->outOffset; + } + const auto dstBounds = SkIRect::MakeXYWH(offset.x(), offset.y(), srcBounds.width(), diff --git a/libs/hwui/renderthread/EglManager.cpp b/libs/hwui/renderthread/EglManager.cpp index a11678189bad..383c79b27918 100644 --- a/libs/hwui/renderthread/EglManager.cpp +++ b/libs/hwui/renderthread/EglManager.cpp @@ -146,6 +146,9 @@ void EglManager::initialize() { LOG_ALWAYS_FATAL("Unsupported wide color space."); } mHasWideColorGamutSupport = EglExtensions.glColorSpace && hasWideColorSpaceExtension; + + auto* vendor = reinterpret_cast(glGetString(GL_VENDOR)); + Properties::enableRenderEffectCache = (strcmp(vendor, "Qualcomm") != 0); } EGLConfig EglManager::load8BitsConfig(EGLDisplay display, EglManager::SwapBehavior swapBehavior) { -- cgit v1.2.3-59-g8ed1b