Skip to content

bug: Kivy RecycleView data mutated from background thread in show_debug_log (crash/corruption) #114

@RockyOmvi

Description

@RockyOmvi

Describe the bug

In src/buskill_gui.py, the show_debug_log() method modifies self.rv.data (a Kivy RecycleView property) from a background threading.Thread. Kivy's UI properties are not thread-safe — they must only be modified from the main thread. This can cause random crashes, data corruption, or visual glitches.

Code reference

src/buskill_gui.py:1026-1032:

threading.Thread( target=self.show_debug_log ).start()
...

def show_debug_log( self ):
    lines = []
    for line in self.debug_log_contents.splitlines(keepends=False):
        lines.append({'text': line})
    self.rv.data = lines   # <-- UI mutation from background thread

Expected behavior

Use Clock.schedule_once() to schedule the data update on the main thread:

def show_debug_log( self ):
    lines = [{'text': line} for line in self.debug_log_contents.splitlines(keepends=False)]
    from kivy.clock import Clock
    Clock.schedule_once(lambda dt: setattr(self.rv, 'data', lines), 0)

Severity

Medium — can cause hard-to-reproduce crashes and visual corruption in the debug log screen.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions