Skip to content

fix: schedule RecycleView data update on main thread in show_debug_log#125

Open
RockyOmvi wants to merge 1 commit into
BusKill:masterfrom
RockyOmvi:fix/debug-log-thread-safety
Open

fix: schedule RecycleView data update on main thread in show_debug_log#125
RockyOmvi wants to merge 1 commit into
BusKill:masterfrom
RockyOmvi:fix/debug-log-thread-safety

Conversation

@RockyOmvi

Copy link
Copy Markdown

Description

\show_debug_log()\ runs inside a \ hreading.Thread\ but was directly mutating \self.rv.data\ (a Kivy \RecycleView\ property), which is not thread-safe. Kivy UI properties must only be modified from the main thread.

Fix

Wrapped the \self.rv.data\ assignment in \Clock.schedule_once\ so it executes on the main thread on the next frame. \Clock\ was already imported at the top of the file.

Testing

The thread builds the \lines\ list, schedules the callback, and exits. The \DebugLog\ screen is kept alive by the screen manager, so \self\ won't be GC'd before the callback fires.

Related issue: #114

show_debug_log() runs inside a threading.Thread and was directly
mutating self.rv.data (a Kivy RecycleView property), which is not
thread-safe. Wrapping the assignment in Clock.schedule_once ensures
it executes on the main thread, preventing potential crashes and
visual corruption.
Copilot AI review requested due to automatic review settings June 3, 2026 03:49

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

This PR adjusts how the debug log view updates its RecycleView data by deferring the assignment onto Kivy’s Clock, likely to ensure UI updates occur on the main event loop.

Changes:

  • Replace direct self.rv.data = lines with a Clock.schedule_once(...) deferred update.

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

Comment thread src/buskill_gui.py
for line in self.debug_log_contents.splitlines(keepends=False):
lines.append({'text': line})
self.rv.data = lines
Clock.schedule_once(lambda dt: setattr(self.rv, 'data', lines), 0)
Comment thread src/buskill_gui.py
for line in self.debug_log_contents.splitlines(keepends=False):
lines.append({'text': line})
self.rv.data = lines
Clock.schedule_once(lambda dt: setattr(self.rv, 'data', lines), 0)
@github-actions

github-actions Bot commented Jun 3, 2026

Copy link
Copy Markdown

INFO: No unicode characters found in PR's commits

(source)

@maltfield

Copy link
Copy Markdown
Member

@RockyOmvi Thanks for the PR :)

Please note that this repo does not accept contributions that use AI

Can you please tell us if you wrote this code, comments, and PR contents entirely by yourself? Or if you used AI for any part of it?

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants