Skip to content

ui diff: add multithreading and improve logging (split from #37328)#37474

Open
TheSecurityDev wants to merge 7 commits intocommaai:masterfrom
TheSecurityDev:diff-multithreading-and-refactor
Open

ui diff: add multithreading and improve logging (split from #37328)#37474
TheSecurityDev wants to merge 7 commits intocommaai:masterfrom
TheSecurityDev:diff-multithreading-and-refactor

Conversation

@TheSecurityDev
Copy link
Contributor

@TheSecurityDev TheSecurityDev commented Feb 28, 2026

Split out some of the extra stuff in #37328 (e.g. multi-threading and refactors) so it will be easier to review (will cause merge conflicts, but that's fine).

This PR specifically introduces multithreading for generating the diff video in the background while generating the rest of the report, and also does the frame hash generation in parallel now to save time. This makes a huge difference for longer videos which will be coming in the future. For example, generating the diff video takes almost as long as the rest of the script, but it's completely unnecessary to wait for it.

Also improves the script logging, adds some missing Python types, and switches to Path types for video paths which makes things a bit easier to work with.

-nostdin is added to the ffmpeg commands that run in threads since otherwise it breaks my terminal.

Example output
============================================================
UI VIDEO DIFF - HTML REPORT
============================================================
Video 1:      /home/user/openpilot/selfdrive/ui/tests/diff/report/tizi_ui_replay_old.mp4
Video 2:      /home/user/openpilot/selfdrive/ui/tests/diff/report/tizi_ui_replay_new.mp4
HTML output:  diff.html
Diff video:   diff.mp4

[1/4] Starting full video diff generation in background thread...
[2/4] Hashing frames...
Generating frame hashes for both videos...
  Found 814 frames in video 1 and 1760 frames in video 2.
[3/4] Finding different frames...
  Found 783 different frames.
[4/4] Generating HTML report...
  Results: ❌ Found 1729 different frames out of 1760 total (98.2%). Video 2 is longer by 946 frames.
  Report generated at: /home/user/openpilot/selfdrive/ui/tests/diff/report/diff.html
Waiting for diff video generation to finish...

Copilot AI review requested due to automatic review settings February 28, 2026 06:00
@github-actions github-actions bot added the ui label Feb 28, 2026
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR splits out the multithreading improvements and logging enhancements from PR #37328 into a standalone, easier-to-review change. It introduces background threading for diff video generation and parallel frame-hash extraction, which significantly reduces total runtime for long videos. It also modernizes the script with Path types, adds missing type annotations, and improves console output formatting.

Changes:

  • Adds background threading for create_diff_video (runs while the rest of the report is generated) and parallel frame-hash extraction using ThreadPoolExecutor.
  • Refactors video path arguments from str to Path, adds full type annotations, and splits find_differences into a dedicated get_video_frame_hashes helper + find_frame_differences.
  • Improves console logging with step indicators ([1/4], etc.), alignment, and a "Waiting for diff video…" message.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@github-actions
Copy link
Contributor

github-actions bot commented Feb 28, 2026

UI Preview

mici: Videos are identical! View Diff Report
big: Videos are identical! View Diff Report

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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.

2 participants