fix: schedule RecycleView data update on main thread in show_debug_log#125
Open
RockyOmvi wants to merge 1 commit into
Open
fix: schedule RecycleView data update on main thread in show_debug_log#125RockyOmvi wants to merge 1 commit into
RockyOmvi wants to merge 1 commit into
Conversation
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.
There was a problem hiding this comment.
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 = lineswith aClock.schedule_once(...)deferred update.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| 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) |
| 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) |
|
INFO: No unicode characters found in PR's commits (source) |
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? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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