Skip to content

ui: remove interactive timeout callback when driver camera dialog closes#38237

Open
srijavuppala wants to merge 1 commit into
commaai:masterfrom
srijavuppala:fix-interactive-timeout-callback-leak
Open

ui: remove interactive timeout callback when driver camera dialog closes#38237
srijavuppala wants to merge 1 commit into
commaai:masterfrom
srijavuppala:fix-interactive-timeout-callback-leak

Conversation

@srijavuppala

Copy link
Copy Markdown

Summary

Fixes #37536.

Device.add_interactive_timeout_callback() only appends to a list; there was no way to remove a callback once added. The driver camera dialog (DriverCameraDialog, both tici and mici variants) is constructed fresh every time it's opened from settings, and each construction registered a new gui_app.pop_widget callback that was never removed. Opening the dialog repeatedly grows _interactive_timeout_callbacks unbounded, as flagged by the existing # TODO: this can grow unbounded comment.

  • Added Device.remove_interactive_timeout_callback() in selfdrive/ui/ui_state.py
  • Call it from hide_event() in both selfdrive/ui/onroad/driver_camera_dialog.py and selfdrive/ui/mici/onroad/driver_camera_dialog.py, removing the leftover TODO comments now that it's handled

The other three call sites listed in the issue (MainLayout, MiciMainLayout, TrainingGuideDMTutorial) register their callback once for the lifetime of the process and aren't constructed repeatedly, so they don't leak and weren't changed.

Test plan

  • ruff check passes on all three changed files
  • Verified Device.remove_interactive_timeout_callback() removes exactly one matching entry from the list (mirrors list.remove() semantics, symmetric with add_interactive_timeout_callback's list.append())
  • Read through both DriverCameraDialog lifecycles to confirm hide_event() is the right place to remove the callback (mirrors how IsDriverViewEnabled and set_override_interactive_timeout are already reset there)

Device.add_interactive_timeout_callback() had no corresponding remove
method, so every time the driver camera dialog was opened a new
gui_app.pop_widget callback was appended and never cleaned up. Opening
the dialog repeatedly grew the callback list unbounded.

Add Device.remove_interactive_timeout_callback() and call it from
hide_event() on both the tici and mici DriverCameraDialog so the
callback is removed when the dialog closes.
@github-actions github-actions Bot added the ui label Jun 25, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Process replay diff report

Replays driving segments through this PR and compares the behavior to master.
Please review any changes carefully to ensure they are expected.

✅ 0 changed, 66 passed, 0 errors

@github-actions

Copy link
Copy Markdown
Contributor

UI Preview

mici: Videos are identical! View Diff Report
big: ⚠️ Videos differ! View Diff Report

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

interactive timeout callbacks are added but never removed

1 participant