1+ import time
12import numpy as np
23import pyray as rl
3- from cereal import car , log
4+ from cereal import messaging , car , log
45from msgq .visionipc import VisionStreamType
56from openpilot .selfdrive .ui .ui_state import ui_state , UIStatus
67from openpilot .selfdrive .ui .mici .onroad import SIDE_PANEL_WIDTH
@@ -160,6 +161,9 @@ def __init__(self, bookmark_callback=None, stream_type: VisionStreamType = Visio
160161
161162 self ._fade_texture = gui_app .texture ("icons_mici/onroad/onroad_fade.png" )
162163
164+ # debug
165+ self ._pm = messaging .PubMaster (['uiDebug' ])
166+
163167 def is_swiping_left (self ) -> bool :
164168 """Check if currently swiping left (for scroller to disable)."""
165169 return self ._bookmark_icon .is_swiping_left ()
@@ -179,6 +183,7 @@ def _handle_mouse_release(self, mouse_pos: MousePos):
179183 super ()._handle_mouse_release (mouse_pos )
180184
181185 def _render (self , _ ):
186+ start_draw = time .monotonic ()
182187 self ._switch_stream_if_needed (ui_state .sm )
183188
184189 # Update calibration before rendering
@@ -244,6 +249,11 @@ def _render(self, _):
244249 rl .draw_rectangle (int (self .rect .x ), int (self .rect .y ), int (self .rect .width ), int (self .rect .height ), rl .Color (0 , 0 , 0 , 175 ))
245250 self ._offroad_label .render (self ._content_rect )
246251
252+ # publish uiDebug
253+ msg = messaging .new_message ('uiDebug' )
254+ msg .uiDebug .drawTimeMillis = (time .monotonic () - start_draw ) * 1000
255+ self ._pm .send ('uiDebug' , msg )
256+
247257 def _switch_stream_if_needed (self , sm ):
248258 if sm ['selfdriveState' ].experimentalMode and WIDE_CAM in self .available_streams :
249259 v_ego = sm ['carState' ].vEgo
0 commit comments