[Fix] (Tools/TraceReplay): show window surface after first present

This commit is contained in:
2026-06-28 15:00:00 +08:00
parent 0ef9c76224
commit d61a0b6904
5 changed files with 153 additions and 6 deletions
@@ -7,10 +7,12 @@
#include <dlfcn.h>
#include <algorithm>
#include <chrono>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <thread>
namespace {
@@ -87,6 +89,28 @@ void *Lookup(const char *name) {
return dlsym(RTLD_DEFAULT, name);
}
void HoldAfterTargetPresent(const char *callNo) {
const char *holdMsText = std::getenv("MOBILEGL_TRACE_HOLD_MS");
if (holdMsText == nullptr || holdMsText[0] == '\0') {
return;
}
const int holdMs = std::atoi(holdMsText);
if (holdMs <= 0) {
return;
}
const char *holdDone = std::getenv("MOBILEGL_TRACE_HOLD_DONE");
if (holdDone != nullptr && std::strcmp(holdDone, "1") == 0) {
return;
}
const char *holdCall = std::getenv("MOBILEGL_TRACE_HOLD_CALL");
if (holdCall != nullptr && holdCall[0] != '\0' && std::strcmp(holdCall, callNo) != 0) {
return;
}
std::this_thread::sleep_for(std::chrono::milliseconds(holdMs));
setenv("MOBILEGL_TRACE_HOLD_DONE", "1", 1);
}
template <typename T>
bool Load(T &slot, const char *name) {
slot = reinterpret_cast<T>(Lookup(name));
@@ -175,6 +199,7 @@ public:
setenv("MOBILEGL_PRESENT_CURRENT_CALL", callNo, 1);
gEgl.swapBuffers(gDisplay, surface);
unsetenv("MOBILEGL_PRESENT_CURRENT_CALL");
HoldAfterTargetPresent(callNo);
}
}