Merge "BLASTSyncEngine: Logging and trace around commit timeout" into tm-dev am: c0573c9851 am: fb8a245885

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/18188882

Change-Id: If500668cc73d1f98bcee99f1f6dc178899567c40
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Rob Carr
2022-05-07 23:31:52 +00:00
committed by Automerger Merge Worker

View File

@@ -153,10 +153,10 @@ class BLASTSyncEngine {
for (WindowContainer wc : mRootMembers) { for (WindowContainer wc : mRootMembers) {
wc.waitForSyncTransactionCommit(wcAwaitingCommit); wc.waitForSyncTransactionCommit(wcAwaitingCommit);
} }
final Runnable callback = new Runnable() { class CommitCallback implements Runnable {
// Can run a second time if the action completes after the timeout. // Can run a second time if the action completes after the timeout.
boolean ran = false; boolean ran = false;
public void run() { public void onCommitted() {
synchronized (mWm.mGlobalLock) { synchronized (mWm.mGlobalLock) {
if (ran) { if (ran) {
return; return;
@@ -171,8 +171,23 @@ class BLASTSyncEngine {
wcAwaitingCommit.clear(); wcAwaitingCommit.clear();
} }
} }
// Called in timeout
@Override
public void run() {
// Sometimes we get a trace, sometimes we get a bugreport without
// a trace. Since these kind of ANRs can trigger such an issue,
// try and ensure we will have some visibility in both cases.
Trace.traceBegin(TRACE_TAG_WINDOW_MANAGER, "onTransactionCommitTimeout");
Slog.e(TAG, "WM sent Transaction to organized, but never received" +
" commit callback. Application ANR likely to follow.");
Trace.traceEnd(TRACE_TAG_WINDOW_MANAGER);
onCommitted();
}
}; };
merged.addTransactionCommittedListener((r) -> { r.run(); }, callback::run); CommitCallback callback = new CommitCallback();
merged.addTransactionCommittedListener((r) -> { r.run(); }, callback::onCommitted);
mWm.mH.postDelayed(callback, BLAST_TIMEOUT_DURATION); mWm.mH.postDelayed(callback, BLAST_TIMEOUT_DURATION);
Trace.traceBegin(TRACE_TAG_WINDOW_MANAGER, "onTransactionReady"); Trace.traceBegin(TRACE_TAG_WINDOW_MANAGER, "onTransactionReady");