Skip to content

Commit e869aee

Browse files
committed
[3171580] don't automatically log GraphicBuffer allocation failures
some of these failures are not fatal and even expected in some cases so they should not emit a dump in the log in those cases. Change-Id: Idcfa252e3bfa9d74e27fe4ad8f8623aa01aa9c5e
1 parent e2abd10 commit e869aee

File tree

5 files changed

+18
-5
lines changed

5 files changed

+18
-5
lines changed

include/ui/GraphicBuffer.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,12 +88,15 @@ class GraphicBuffer
8888
status_t lock(uint32_t usage, const Rect& rect, void** vaddr);
8989
status_t lock(GGLSurface* surface, uint32_t usage);
9090
status_t unlock();
91-
91+
9292
android_native_buffer_t* getNativeBuffer() const;
9393

9494
void setIndex(int index);
9595
int getIndex() const;
9696

97+
// for debugging
98+
static void dumpAllocationsToSystemLog();
99+
97100
private:
98101
virtual ~GraphicBuffer();
99102

include/ui/GraphicBufferAllocator.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ class GraphicBufferAllocator : public Singleton<GraphicBufferAllocator>
6868
status_t free(buffer_handle_t handle);
6969

7070
void dump(String8& res) const;
71+
static void dumpToSystemLog();
7172

7273
private:
7374
struct alloc_rec_t {

libs/ui/GraphicBuffer.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,11 @@ status_t GraphicBuffer::initCheck() const {
9999
return mInitCheck;
100100
}
101101

102+
void GraphicBuffer::dumpAllocationsToSystemLog()
103+
{
104+
GraphicBufferAllocator::dumpToSystemLog();
105+
}
106+
102107
android_native_buffer_t* GraphicBuffer::getNativeBuffer() const
103108
{
104109
return static_cast<android_native_buffer_t*>(

libs/ui/GraphicBufferAllocator.cpp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,13 @@ void GraphicBufferAllocator::dump(String8& result) const
7373
result.append(buffer);
7474
}
7575

76+
void GraphicBufferAllocator::dumpToSystemLog()
77+
{
78+
String8 s;
79+
GraphicBufferAllocator::getInstance().dump(s);
80+
LOGD("%s", s.string());
81+
}
82+
7683
status_t GraphicBufferAllocator::alloc(uint32_t w, uint32_t h, PixelFormat format,
7784
int usage, buffer_handle_t* handle, int32_t* stride)
7885
{
@@ -104,10 +111,6 @@ status_t GraphicBufferAllocator::alloc(uint32_t w, uint32_t h, PixelFormat forma
104111
rec.usage = usage;
105112
rec.size = h * stride[0] * bytesPerPixel(format);
106113
list.add(*handle, rec);
107-
} else {
108-
String8 s;
109-
dump(s);
110-
LOGD("%s", s.string());
111114
}
112115

113116
return err;

services/surfaceflinger/Layer.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -347,6 +347,7 @@ sp<GraphicBuffer> Layer::requestBuffer(int index,
347347
err = buffer->initCheck();
348348

349349
if (err || buffer->handle == 0) {
350+
GraphicBuffer::dumpAllocationsToSystemLog();
350351
LOGE_IF(err || buffer->handle == 0,
351352
"Layer::requestBuffer(this=%p), index=%d, w=%d, h=%d failed (%s)",
352353
this, index, w, h, strerror(-err));

0 commit comments

Comments
 (0)