Skip to content

Commit 25345d8

Browse files
author
“Shadman
committed
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
1 parent fabe226 commit 25345d8

2 files changed

Lines changed: 22 additions & 4 deletions

File tree

libs/gui/BLASTBufferQueue.cpp

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -937,15 +937,22 @@ class BBQSurface : public Surface {
937937
: Surface(igbp, controlledByApp, scHandle), mBbq(bbq) {}
938938

939939
void allocateBuffers() override {
940+
ATRACE_CALL();
940941
uint32_t reqWidth = mReqWidth ? mReqWidth : mUserWidth;
941942
uint32_t reqHeight = mReqHeight ? mReqHeight : mUserHeight;
942943
auto gbp = getIGraphicBufferProducer();
943-
std::thread ([reqWidth, reqHeight, gbp=getIGraphicBufferProducer(),
944-
reqFormat=mReqFormat, reqUsage=mReqUsage] () {
944+
std::thread allocateThread([reqWidth, reqHeight, gbp = getIGraphicBufferProducer(),
945+
reqFormat = mReqFormat, reqUsage = mReqUsage]() {
946+
if (com_android_graphics_libgui_flags_allocate_buffer_priority()) {
947+
androidSetThreadName("allocateBuffers");
948+
pid_t tid = gettid();
949+
androidSetThreadPriority(tid, ANDROID_PRIORITY_DISPLAY);
950+
}
951+
945952
gbp->allocateBuffers(reqWidth, reqHeight,
946953
reqFormat, reqUsage);
947-
948-
}).detach();
954+
});
955+
allocateThread.detach();
949956
}
950957

951958
status_t setFrameRate(float frameRate, int8_t compatibility,

libs/gui/libgui_flags.aconfig

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,3 +142,14 @@ flag {
142142
bug: "340934031"
143143
is_fixed_read_only: true
144144
} # wb_media_migration
145+
146+
flag {
147+
name: "allocate_buffer_priority"
148+
namespace: "wear_system_health"
149+
description: "Boost priority for buffer allocation"
150+
bug: "399701430"
151+
metadata {
152+
purpose: PURPOSE_BUGFIX
153+
}
154+
is_fixed_read_only: true
155+
} # allocate_buffer_priority

0 commit comments

Comments
 (0)