diff options
author | 2024-12-12 19:58:05 +0000 | |
---|---|---|
committer | 2024-12-13 18:40:43 +0000 | |
commit | 20f066cace9ff7043643eebf6504d1f1c17868bf (patch) | |
tree | 856f77c0e128f3411296a0b88af1b2166ecec6cb | |
parent | 11608e9f71e1136ce69ab2ccbf3feecb96b8a24e (diff) |
render thread early preload optimizations
1. preload eglContext when renderthread preload is called so setSurface
work is not waiting for this work during app launch crit path.
2. Additionally queue GraphicBufferAllocator instance get, so
allocateBuffer does not wait for initialization during app launch
critical path.
Impact: Large improvement in app launch latency for low core devices
- ~70ms of improvement in our view based app launch
- ~27ms of improvement in material3 compose base app launch
Test: manual built and flashed
Bug: 383612849
Flag: early_preload_gl_context
Change-Id: I580e31de1d3a9878cf102dfdcad39bfd64bf2c53
-rw-r--r-- | libs/hwui/Properties.cpp | 8 | ||||
-rw-r--r-- | libs/hwui/Properties.h | 3 | ||||
-rw-r--r-- | libs/hwui/aconfig/hwui_flags.aconfig | 7 | ||||
-rw-r--r-- | libs/hwui/renderthread/RenderThread.cpp | 12 |
4 files changed, 28 insertions, 2 deletions
diff --git a/libs/hwui/Properties.cpp b/libs/hwui/Properties.cpp index 064cac2a6fc6..7d01dfbb446f 100644 --- a/libs/hwui/Properties.cpp +++ b/libs/hwui/Properties.cpp @@ -54,6 +54,9 @@ constexpr bool resample_gainmap_regions() { constexpr bool query_global_priority() { return false; } +constexpr bool early_preload_gl_context() { + return false; +} } // namespace hwui_flags #endif @@ -291,5 +294,10 @@ bool Properties::resampleGainmapRegions() { return sResampleGainmapRegions; } +bool Properties::earlyPreloadGlContext() { + return base::GetBoolProperty(PROPERTY_EARLY_PRELOAD_GL_CONTEXT, + hwui_flags::early_preload_gl_context()); +} + } // namespace uirenderer } // namespace android diff --git a/libs/hwui/Properties.h b/libs/hwui/Properties.h index db930f3904de..280a75a28e65 100644 --- a/libs/hwui/Properties.h +++ b/libs/hwui/Properties.h @@ -236,6 +236,8 @@ enum DebugLevel { #define PROPERTY_SKIP_EGLMANAGER_TELEMETRY "debug.hwui.skip_eglmanager_telemetry" +#define PROPERTY_EARLY_PRELOAD_GL_CONTEXT "debug.hwui.early_preload_gl_context" + /////////////////////////////////////////////////////////////////////////////// // Misc /////////////////////////////////////////////////////////////////////////////// @@ -381,6 +383,7 @@ public: static bool initializeGlAlways(); static bool resampleGainmapRegions(); + static bool earlyPreloadGlContext(); private: static StretchEffectBehavior stretchEffectBehavior; diff --git a/libs/hwui/aconfig/hwui_flags.aconfig b/libs/hwui/aconfig/hwui_flags.aconfig index e497ea1f3cb4..76ad2acccf89 100644 --- a/libs/hwui/aconfig/hwui_flags.aconfig +++ b/libs/hwui/aconfig/hwui_flags.aconfig @@ -166,4 +166,11 @@ flag { metadata { purpose: PURPOSE_BUGFIX } +} + +flag { + name: "early_preload_gl_context" + namespace: "core_graphics" + description: "Initialize GL context and GraphicBufferAllocater init on renderThread preload. This improves app startup time for apps using GL." + bug: "383612849" }
\ No newline at end of file diff --git a/libs/hwui/renderthread/RenderThread.cpp b/libs/hwui/renderthread/RenderThread.cpp index 92c6ad10d1c7..69fe40c755ea 100644 --- a/libs/hwui/renderthread/RenderThread.cpp +++ b/libs/hwui/renderthread/RenderThread.cpp @@ -25,6 +25,7 @@ #include <private/android/choreographer.h> #include <sys/resource.h> #include <ui/FatVector.h> +#include <ui/GraphicBufferAllocator.h> #include <utils/Condition.h> #include <utils/Log.h> #include <utils/Mutex.h> @@ -518,11 +519,18 @@ bool RenderThread::isCurrent() { void RenderThread::preload() { // EGL driver is always preloaded only if HWUI renders with GL. if (Properties::getRenderPipelineType() == RenderPipelineType::SkiaGL) { - std::thread eglInitThread([]() { eglGetDisplay(EGL_DEFAULT_DISPLAY); }); - eglInitThread.detach(); + if (Properties::earlyPreloadGlContext()) { + queue().post([this]() { requireGlContext(); }); + } else { + std::thread eglInitThread([]() { eglGetDisplay(EGL_DEFAULT_DISPLAY); }); + eglInitThread.detach(); + } } else { requireVkContext(); } + if (Properties::earlyPreloadGlContext()) { + queue().post([]() { GraphicBufferAllocator::getInstance(); }); + } HardwareBitmapUploader::initialize(); } |