Qt: log icon and window timings to find the icon lag on the phone
Each icon request logs its key and how long it took (ultra.icon), each icon logs when it shows, and the app state, scene graph and first frames are logged too, so logcat shows where the time goes when icons appear late. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DPL5hiQsCq11CwCPnKPp9D
This commit is contained in:
4 files changed
+24
No files matched your search
@@ -219,6 +219,7 @@ public class HomeActivity extends QtActivity {
|
||||
@Override
|
||||
public void onStart() {
|
||||
super.onStart();
|
||||
Log.i("ultra", "onStart");
|
||||
widgetHost.startListening();
|
||||
Updater.check(this, false);
|
||||
}
|
||||
@@ -226,6 +227,7 @@ public class HomeActivity extends QtActivity {
|
||||
@Override
|
||||
public void onStop() {
|
||||
super.onStop();
|
||||
Log.i("ultra", "onStop");
|
||||
widgetHost.stopListening();
|
||||
}
|
||||
|
||||
|
||||
@@ -25,6 +25,7 @@ Item {
|
||||
mipmap: true
|
||||
sourceSize.width: Math.ceil(root.size * Screen.devicePixelRatio)
|
||||
sourceSize.height: Math.ceil(root.size * Screen.devicePixelRatio)
|
||||
onStatusChanged: if (status === Image.Ready || status === Image.Error) console.info("ultra.icon shown", root.key, status === Image.Ready)
|
||||
source: root.key ? "image://icon/" + encodeURIComponent(root.key) + "?" + root.generation : ""
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,11 @@
|
||||
#include <QColor>
|
||||
#include <QPainter>
|
||||
#include <QUrl>
|
||||
#include <QElapsedTimer>
|
||||
#include <QLoggingCategory>
|
||||
#include <QThread>
|
||||
|
||||
Q_LOGGING_CATEGORY(lcIcon, "ultra.icon")
|
||||
|
||||
#include <cmath>
|
||||
|
||||
@@ -17,6 +22,8 @@ QImage IconProvider::requestImage(const QString &id, QSize *size, const QSize &r
|
||||
if (q >= 0) key.truncate(q);
|
||||
key = QUrl::fromPercentEncoding(key.toUtf8());
|
||||
const int px = requested.width() > 0 ? requested.width() : 144;
|
||||
QElapsedTimer took;
|
||||
took.start();
|
||||
QImage img;
|
||||
#ifdef Q_OS_ANDROID
|
||||
// Premultiplied RGBA, side x side, straight from an Android bitmap.
|
||||
@@ -54,5 +61,7 @@ QImage IconProvider::requestImage(const QString &id, QSize *size, const QSize &r
|
||||
p.drawText(QRectF(0, 0, px, px), Qt::AlignCenter, name.left(1).toUpper());
|
||||
#endif
|
||||
if (size) *size = img.size();
|
||||
// Timing, to find what holds icons up on a phone: adb logcat -s ultrahome:*
|
||||
qCInfo(lcIcon, "icon %s %dpx %lldms%s", qPrintable(key), px, took.elapsed(), img.isNull() ? " (none)" : "");
|
||||
return img;
|
||||
}
|
||||
@@ -28,5 +28,17 @@ int main(int argc, char *argv[]) {
|
||||
[] { QCoreApplication::exit(1); }, Qt::QueuedConnection);
|
||||
engine.loadFromModule("Launcher", "Main");
|
||||
if (engine.rootObjects().isEmpty()) return 1;
|
||||
// Timing of the window's lifecycle, next to the icon timings (category ultra.icon).
|
||||
QObject::connect(&app, &QGuiApplication::applicationStateChanged, [](Qt::ApplicationState s) {
|
||||
qInfo("ultra.state %d", int(s));
|
||||
});
|
||||
if (auto *win = qobject_cast<QQuickWindow *>(engine.rootObjects().first())) {
|
||||
QObject::connect(win, &QQuickWindow::sceneGraphInitialized, [] { qInfo("ultra.sg initialized"); });
|
||||
QObject::connect(win, &QQuickWindow::sceneGraphInvalidated, [] { qInfo("ultra.sg invalidated"); });
|
||||
QObject::connect(win, &QQuickWindow::frameSwapped, win, [win] {
|
||||
static int n = 0;
|
||||
if (n++ < 3) qInfo("ultra.sg frame %d", n);
|
||||
});
|
||||
}
|
||||
return app.exec();
|
||||
}
|
||||
Reference in new issue
Block a user