UI: better lag logging (#24042)

* UI: better lag logging

* remove print
pull/24009/merge
Adeeb Shihadeh 2022-03-25 13:52:37 -07:00 committed by GitHub
parent 4802c864d5
commit 67e3a2c39a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 4 deletions

View File

@ -267,6 +267,11 @@ void OnroadHud::drawIcon(QPainter &p, int x, int y, QPixmap &img, QBrush bg, flo
}
// NvgWindow
NvgWindow::NvgWindow(VisionStreamType type, QWidget* parent) : fps_filter(UI_FREQ, 3, 1. / UI_FREQ), CameraViewWidget("camerad", type, true, parent) {
}
void NvgWindow::initializeGL() {
CameraViewWidget::initializeGL();
qInfo() << "OpenGL version:" << QString((const char*)glGetString(GL_VERSION));
@ -376,9 +381,9 @@ void NvgWindow::paintGL() {
double cur_draw_t = millis_since_boot();
double dt = cur_draw_t - prev_draw_t;
if (dt > 66) {
// warn on sub 15fps
LOGW("slow frame time: %.2f", dt);
double fps = fps_filter.update(1. / dt * 1000);
if (fps < 15) {
LOGW("slow frame rate: %.2f fps", fps);
}
prev_draw_t = cur_draw_t;
}

View File

@ -3,6 +3,7 @@
#include <QStackedLayout>
#include <QWidget>
#include "selfdrive/common/util.h"
#include "selfdrive/ui/qt/widgets/cameraview.h"
#include "selfdrive/ui/ui.h"
@ -66,7 +67,7 @@ class NvgWindow : public CameraViewWidget {
Q_OBJECT
public:
explicit NvgWindow(VisionStreamType type, QWidget* parent = 0) : CameraViewWidget("camerad", type, true, parent) {}
explicit NvgWindow(VisionStreamType type, QWidget* parent = 0);
protected:
void paintGL() override;
@ -77,7 +78,9 @@ protected:
void drawLead(QPainter &painter, const cereal::ModelDataV2::LeadDataV3::Reader &lead_data, const QPointF &vd);
inline QColor redColor(int alpha = 255) { return QColor(201, 34, 49, alpha); }
inline QColor whiteColor(int alpha = 255) { return QColor(255, 255, 255, alpha); }
double prev_draw_t = 0;
FirstOrderFilter fps_filter;
};
// container for all onroad widgets