Skip to content

Commit 0864e4f

Browse files
Shadman ShadidAndroid (Google) Code Review
authored andcommitted
Merge "Fix render thread priority for allocateBuffers" into main
2 parents 5f72385 + 25345d8 commit 0864e4f

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)