From 35b4c44168e224843f9f6371179538daeb374ee6 Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 4 Nov 2026 16:19:45 +0000 Subject: [PATCH] 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 Claude-Session: https://claude.ai/code/session_01DPL5hiQsCq11CwCPnKPp9D --- qt/android/src/dev/ultra/launcher/HomeActivity.java | 2 ++ qt/qml/AppIcon.qml | 1 + qt/src/iconprovider.cpp | 9 +++++++++ qt/src/main.cpp | 12 ++++++++++++ 4 files changed, 24 insertions(+) diff --git a/qt/android/src/dev/ultra/launcher/HomeActivity.java b/qt/android/src/dev/ultra/launcher/HomeActivity.java index f549b09..5178869 100644 --- a/qt/android/src/dev/ultra/launcher/HomeActivity.java +++ b/qt/android/src/dev/ultra/launcher/HomeActivity.java @@ -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(); } diff --git a/qt/qml/AppIcon.qml b/qt/qml/AppIcon.qml index a46bc3a..f85f3df 100644 --- a/qt/qml/AppIcon.qml +++ b/qt/qml/AppIcon.qml @@ -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 : "" } } diff --git a/qt/src/iconprovider.cpp b/qt/src/iconprovider.cpp index ff55412..a0618fc 100644 --- a/qt/src/iconprovider.cpp +++ b/qt/src/iconprovider.cpp @@ -3,6 +3,11 @@ #include #include #include +#include +#include +#include + +Q_LOGGING_CATEGORY(lcIcon, "ultra.icon") #include @@ -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; } diff --git a/qt/src/main.cpp b/qt/src/main.cpp index a7ae38c..6250e19 100644 --- a/qt/src/main.cpp +++ b/qt/src/main.cpp @@ -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(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(); }