summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author “Shadman <shadmans@google.com> 2025-03-03 16:13:39 +0000
committer “Shadman <shadmans@google.com> 2025-03-07 00:29:47 +0000
commit25345d82ce0d85e073365d0fc83eeb407356a6b8 (patch)
treee237df8757686210b4e5800a4ec068c603aabec3
parentfabe2265f7146d3497e0f75ed75a200c2d719429 (diff)
Fix render thread priority for allocateBuffers
Increase the prio for the thread allocateBuffer runs on so we don't cause the main RT prio thread wait as long during frame draws. Bug: 399701430 Test: app launch test Flag: com.android.graphics.libgui.flags.allocate_buffer_priority Change-Id: Ic56697866f1f58c6c5575909da9e1ecd95a3cb06
-rw-r--r--libs/gui/BLASTBufferQueue.cpp15
-rw-r--r--libs/gui/libgui_flags.aconfig11
2 files changed, 22 insertions, 4 deletions
diff --git a/libs/gui/BLASTBufferQueue.cpp b/libs/gui/BLASTBufferQueue.cpp
index fa971426a7..1aae13c1f4 100644
--- a/libs/gui/BLASTBufferQueue.cpp
+++ b/libs/gui/BLASTBufferQueue.cpp
@@ -937,15 +937,22 @@ public:
: Surface(igbp, controlledByApp, scHandle), mBbq(bbq) {}
void allocateBuffers() override {
+ ATRACE_CALL();
uint32_t reqWidth = mReqWidth ? mReqWidth : mUserWidth;
uint32_t reqHeight = mReqHeight ? mReqHeight : mUserHeight;
auto gbp = getIGraphicBufferProducer();
- std::thread ([reqWidth, reqHeight, gbp=getIGraphicBufferProducer(),
- reqFormat=mReqFormat, reqUsage=mReqUsage] () {
+ std::thread allocateThread([reqWidth, reqHeight, gbp = getIGraphicBufferProducer(),
+ reqFormat = mReqFormat, reqUsage = mReqUsage]() {
+ if (com_android_graphics_libgui_flags_allocate_buffer_priority()) {
+ androidSetThreadName("allocateBuffers");
+ pid_t tid = gettid();
+ androidSetThreadPriority(tid, ANDROID_PRIORITY_DISPLAY);
+ }
+
gbp->allocateBuffers(reqWidth, reqHeight,
reqFormat, reqUsage);
-
- }).detach();
+ });
+ allocateThread.detach();
}
status_t setFrameRate(float frameRate, int8_t compatibility,
diff --git a/libs/gui/libgui_flags.aconfig b/libs/gui/libgui_flags.aconfig
index 534f05e987..2c3222dd82 100644
--- a/libs/gui/libgui_flags.aconfig
+++ b/libs/gui/libgui_flags.aconfig
@@ -142,3 +142,14 @@ flag {
bug: "340934031"
is_fixed_read_only: true
} # wb_media_migration
+
+flag {
+ name: "allocate_buffer_priority"
+ namespace: "wear_system_health"
+ description: "Boost priority for buffer allocation"
+ bug: "399701430"
+ metadata {
+ purpose: PURPOSE_BUGFIX
+ }
+ is_fixed_read_only: true
+} # allocate_buffer_priority