numist / Switch

A window-based context switcher for the Mac
157 stars 17 forks source link

Selector updates in unpredictable ways when closing windows #119

Open numist opened 9 years ago

numist commented 9 years ago

Might be a regression from 0.0.8, but I suspect it's not since the state machine tests do not test window closing at all, and reproducing issues like this probably requires specific replay of window updates (and application activation) as provided by the WindowServer, which is also not especially-well mocked in tests.

This bug tracks adding those tests and fixing the issues they uncover. Starting with a log where I closed a bunch of Finder windows and the selector went off into the weeds, including deselecting while there were still windows up:

2015-03-27 12:39:33.979 Switch[11248:6689430] State machine key event with invoke:true direction:increasing repeating:false
<!-- What is this?! -->
2015-03-27 12:39:33.980 Switch[11248:6689430] State machine update window groups: (null)
2015-03-27 12:39:33.986 Switch[11248:6689430] State machine update window groups: {(
    <12785 (SWCoreWindowService.m), 1 windows total>,
    <40258 (numist), 1 windows total>,
    <32318 (untitled 6), 1 windows total>,
    <40262 (numist), 1 windows total>,
    <40260 (numist), 1 windows total>,
    <40256 (numist), 1 windows total>,
    <40254 (numist), 1 windows total>,
    <30633 (NNHashTable.m), 1 windows total>
)}
2015-03-27 12:39:34.180 Switch[11248:6689430] State machine display timer completed
2015-03-27 12:39:36.067 Switch[11248:6689430] State machine event close window
2015-03-27 12:39:36.096 Switch[11248:6689430] State machine update window groups: {(
    <12785 (SWCoreWindowService.m), 1 windows total>,
    <32318 (untitled 6), 1 windows total>,
    <40262 (numist), 1 windows total>,
    <40260 (numist), 1 windows total>,
    <40256 (numist), 1 windows total>,
    <40254 (numist), 1 windows total>,
    <30633 (NNHashTable.m), 1 windows total>
)}
2015-03-27 12:39:36.223 Switch[11248:8311173] SWAccessibilityService.m:232 Closing Finder window <SWAccessibilityService: 0x6080002429a0> took 0.149s
2015-03-27 12:39:37.803 Switch[11248:6689430] State machine event close window
2015-03-27 12:39:37.906 Switch[11248:6689430] State machine update window groups: {(
    <12785 (SWCoreWindowService.m), 1 windows total>,
    <32318 (untitled 6), 1 windows total>,
    <40260 (numist), 1 windows total>,
    <40256 (numist), 1 windows total>,
    <40254 (numist), 1 windows total>,
    <30633 (NNHashTable.m), 1 windows total>
)}
2015-03-27 12:39:37.914 Switch[11248:8311180] SWAccessibilityService.m:232 Closing Finder window <SWAccessibilityService: 0x6080002429a0> took 0.100s
2015-03-27 12:39:38.523 Switch[11248:6689430] State machine event close window
2015-03-27 12:39:38.584 Switch[11248:6689430] State machine update window groups: {(
    <12785 (SWCoreWindowService.m), 1 windows total>,
    <32318 (untitled 6), 1 windows total>,
    <40256 (numist), 1 windows total>,
    <40254 (numist), 1 windows total>,
    <30633 (NNHashTable.m), 1 windows total>
)}
2015-03-27 12:39:38.638 Switch[11248:8311179] SWAccessibilityService.m:232 Closing Finder window <SWAccessibilityService: 0x6080002429a0> took 0.108s
2015-03-27 12:39:39.019 Switch[11248:6689430] State machine event close window
2015-03-27 12:39:39.091 Switch[11248:8311179] SWAccessibilityService.m:232 Closing Finder window <SWAccessibilityService: 0x6080002429a0> took 0.063s
2015-03-27 12:39:39.139 Switch[11248:6689430] State machine update window groups: {(
    <12785 (SWCoreWindowService.m), 1 windows total>,
    <32318 (untitled 6), 1 windows total>,
    <40254 (numist), 1 windows total>,
    <30633 (NNHashTable.m), 1 windows total>
)}
2015-03-27 12:39:39.698 Switch[11248:6689430] State machine key event with invoke:true direction:decreasing repeating:false
2015-03-27 12:39:40.331 Switch[11248:6689430] State machine key event with invoke:true direction:increasing repeating:false
2015-03-27 12:39:42.307 Switch[11248:6689430] State machine event close window
2015-03-27 12:39:42.371 Switch[11248:8311174] SWAccessibilityService.m:232 Closing Finder window <SWAccessibilityService: 0x6080002429a0> took 0.059s
2015-03-27 12:39:42.391 Switch[11248:6689430] State machine update window groups: {(
    <12785 (SWCoreWindowService.m), 1 windows total>,
    <32318 (untitled 6), 1 windows total>,
    <30633 (NNHashTable.m), 1 windows total>
)}
2015-03-27 12:39:43.242 Switch[11248:6689430] State machine key event with invoke:true direction:increasing repeating:false
2015-03-27 12:39:46.426 Switch[11248:6689430] State machine event end invocation
numist commented 9 years ago

Really wish I had #122 for this…

numist commented 8 years ago

This is seriously bad now, and needs tests.