Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 58847c56 authored by yihsing.shen's avatar yihsing.shen Committed by Ady Abraham
Browse files

Fix dumpDebugInfo blocked and phone hanging

HWC would be blocked in writing to pipe seldom due to pipe is full unless SurfaceFlinger read data from pipe. To prevent that, we use
other thread to read data from pipe while HWC is writing.

Bug: 248668158
Test: dumpsys pass
Change-Id: Iae03fd36da657bfe8a6959b84479a1be9f182db9
parent 8eb983ce
Loading
Loading
Loading
Loading
+7 −3
Original line number Diff line number Diff line
@@ -264,17 +264,21 @@ std::string AidlComposer::dumpDebugInfo() {
    }

    std::string str;
    // Use other thread to read pipe to prevent
    // pipe is full, making HWC be blocked in writing.
    std::thread t([&]() {
        base::ReadFdToString(pipefds[0], &str);
    });
    const auto status = mAidlComposer->dump(pipefds[1], /*args*/ nullptr, /*numArgs*/ 0);
    // Close the write-end of the pipe to make sure that when reading from the
    // read-end we will get eof instead of blocking forever
    close(pipefds[1]);

    if (status == STATUS_OK) {
        base::ReadFdToString(pipefds[0], &str);
    } else {
    if (status != STATUS_OK) {
        ALOGE("dumpDebugInfo: dump failed: %d", status);
    }

    t.join();
    close(pipefds[0]);
    return str;
}