From e11b677e0192dec29b75471f70c3476cb22d9cb8 Mon Sep 17 00:00:00 2001 From: Willem Melching Date: Fri, 22 Jan 2021 14:26:35 +0100 Subject: [PATCH] qt ui: slow frame warning --- selfdrive/ui/qt/home.cc | 11 +++++++++++ selfdrive/ui/qt/home.hpp | 1 + 2 files changed, 12 insertions(+) diff --git a/selfdrive/ui/qt/home.cc b/selfdrive/ui/qt/home.cc index d388490d64..3745d00016 100644 --- a/selfdrive/ui/qt/home.cc +++ b/selfdrive/ui/qt/home.cc @@ -12,6 +12,8 @@ #include #include "common/params.h" +#include "common/timing.h" +#include "common/swaglog.h" #include "home.hpp" #include "paint.hpp" @@ -223,6 +225,7 @@ void GLWindow::initializeGL() { wake(); + prev_draw_t = millis_since_boot(); timer->start(1000 / UI_FREQ); backlight_timer->start(BACKLIGHT_DT * 1000); } @@ -270,6 +273,14 @@ void GLWindow::resizeGL(int w, int h) { void GLWindow::paintGL() { if(GLWindow::ui_state.awake){ ui_draw(&ui_state); + + 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(%llu) time: %.2f", ui_state.sm->frame, dt); + } + prev_draw_t = cur_draw_t; } } diff --git a/selfdrive/ui/qt/home.hpp b/selfdrive/ui/qt/home.hpp index bdf0ded979..11e5fb6719 100644 --- a/selfdrive/ui/qt/home.hpp +++ b/selfdrive/ui/qt/home.hpp @@ -41,6 +41,7 @@ private: QtSound sound; bool onroad = true; + double prev_draw_t = 0; // TODO: this shouldn't be here float brightness_b = 0;