Repository navigation
Unbind recorder keyboard callbacks on release - #9424
Conversation
Signed-off-by: Charan Rathore <[email protected]>
|
Thanks for the PR. The However, the leak is still present in win.bind(on_key_down=partial(on_recorder_key, ctx.recorder))and Suggested change in def start(win, ctx):
...
ctx.recorder = Recorder(window=win, **keys)
ctx.key_handler = partial(on_recorder_key, ctx.recorder)
win.bind(on_key_down=ctx.key_handler)
def stop(win, ctx):
if hasattr(ctx, 'recorder'):
win.unbind(on_key_down=ctx.key_handler)
ctx.recorder.release()Please also add a test that calls the module's Separately: I couldn't find an issue or user report for this. If you have one, please link it in the description. |
start() kept a partial-bound on_key_down observer that stop() never removed, so a stopped recorder module still recorded (F8) and the recorder stayed retained by the window. Keep the handler on the context and unbind it before releasing the recorder. Signed-off-by: Charan Rathore <[email protected]>
Start/stop the recorder module against a stand-in window: F8 records and creates the file while started; after stop() no on_key_down observers remain, F8 does nothing, no file is created, and the recorder is collectable. Signed-off-by: Charan Rathore <[email protected]>
|
Thanks @ElliotGarbus - extended the fix to the module in 13e8fd8 and 038a9f3, exactly along your verified snippet:
On the issue link: there is no user report - I found this while auditing the recorder's release path, same class as the release() leak. Happy to file a tracking issue and link it if you'd like the paper trail. |
|
@charan-rathore It's not about the "paper trail" - it is really about priorities. The project has over 700 open issues. That is quite a backlog. If a user has reported the issue it provides a way to let them know it is fixed. CI is failing on every platform with the same test:
With those three changes the test passes with your fix (5 passed) and fails without the module change (I checked both). Please run the new test locally before pushing, since the description says it passes. |
Expect both on_key_down observers after start(), dispatch F8 with the key argument only so the check fails without the fix, and drop the stored key handler before the garbage-collection check. Signed-off-by: Charan Rathore <[email protected]>
|
All three fixed in 4573477: expect 2 on_key_down observers after start(), dispatch F8 with the key only, and drop ctx.key_handler before the GC check. You're right on the process point too - I pushed that test without running it; this environment can't build kivy, which is an explanation, not an excuse. Thanks for running it. |
|
@kuzeyron Ready to merge. |
|
Successfully created backport PR for |
Recorder.__init__()binds three partial callbacks for key-up, key-down and keyboard events.release()tries to unbind the underlying methods instead, which never matches those partials, and it skips the keyboard event entirely. A released recorder keeps receiving input and stays retained by the window.Fix
release(), then clear the recorder's callback references.Testing
kivy/tests/test_recorder.pycover the observer identities, keyboard dispatch before and after release, repeated release, a second recorder on the same window, and garbage collection.release(). With the fix, all 4 pass.