lwouis / alt-tab-macos

Windows alt-tab on macOS
https://alt-tab-macos.netlify.app
GNU General Public License v3.0
10.58k stars 322 forks source link

Keyboard shortcuts sometimes stop working (Secure Input) #157

Closed stevemartina-salesforce closed 4 years ago

stevemartina-salesforce commented 4 years ago

v2.3.2 often doesn't fire - Alt-Tab invokes the standard MacOS switcher, except releasing the keys doesn't dismiss the dialog. I need to click on an icon or press Enter to dismiss. Alt keys is Cmd, Tab is 48, theme is MacOS. MacOS Mojave 10.14.6

Normally restarting Alt-Tab does the trick, but lately it doesn't change anything.

lwouis commented 4 years ago

Hi @stevemartina-salesforce! Thank you for sharing this feedback!

It seems to be some kind of OS-level priority about who gets to register the global shortcut. I will say that the current implementation is naive, and exhibits some limitations: #133, #17, #50.

I would suggest 2 approaches:

kingfisher77 commented 4 years ago

Same here

kungpaogao commented 4 years ago

I'm on AltTab 3.2.1 now and Catalina 10.15.4, and the issue of not firing seems to occur after my computer wakes from sleep.

EDIT: looked through other issues, seems to be related to #176.

EDIT 2: I let my computer sleep overnight, and AltTab still works this morning... maybe it's not related to sleep.

lwouis commented 4 years ago

@kungpaogao I tried also to sleep/wake and it didn't stop AltTab from working.

I think there is a big lack of clarity as to what behavior is exhibited with this issue.

From @stevemartina-salesforce, I understand that he presses the AltTab shortcut, but AltTab doesn't show up. Instead the built-in app-switcher does. Is AltTab opened at this point? I could imagine it crashed for example, which would explain why the built-in app-switcher is showing instead. That wouldn't explain why releasing the cmd key fails at that point. That could be a second, different issue, like AltTab not properly releasing global shortcuts on crash for example. It seems suspiciously similar to https://github.com/lwouis/alt-tab-macos/issues/175.

@kungpaogao is the above behavior exactly the same for you? Could you elaborate on the symptoms you see? I would really like to understand if AltTab is still running or if it crashed.

I tried assigning the same shortcut as the app-switcher, starting/stopping AltTab, sleeping/waking my machine, etc. I also tried binding a global shortcut using System Preferences > Keyboard > Shortcuts after I start AltTab. I wanted to see if maybe the way it works is "last come gets the shortcut". That could explain the issue as the system may sometimes re-grab the global shortcuts for some reason, maybe after a wake, maybe on restart, etc, and that would mean AltTab doesn't respond to it anymore. "Unfortunately", I never got any problems. The shortcut works all the time for me.

Update: another possibility is an interaction with the Accessibility permissions. I say that because if restarting AltTab doesn't fix the issue, it may be that the accessibility permission has some issue. Is the app running after restart, or quitting instantly? Is the checkbox there in the System Preferences > Security & Privacy > Privacy?

lwouis commented 4 years ago

Sharing some research: https://github.com/Kentzo/ShortcutRecorder/issues/114#issuecomment-607128701

kungpaogao commented 4 years ago

Yah, I'm having a hard time reproducing the bug within the past few days. I'm honestly not sure what triggered it. It occurred on an older version, but then I updated, and maybe it occurred because I had to reset the Accessibility permissions after the new install (which I now have).

Best case, it just doesn't occur again :)

stevemartina-salesforce commented 4 years ago

HI @lwlouis,

Sometimes randomly Alt-Tab stops triggering, i.e. it doesn't show up any more. I can still see it's active in the notification area. Very rarely closing it from the menu and restarting seems to work, but I haven't noticed a pattern. When I close it Alt-Tab works normally as per vanilla MacOS, and when I start it again most of the time it still doesn't trigger, but releasing Cmd still fails anyway - I have to press Enter or click on an icon to dismiss the OOTB switcher.

I'm sorry I can't be more helpful but I'm not much of a MacOS user - I use linux whenever possible and have to use a MBP for work as it's a company standard. I don't really know much about the ins and outs of MacOS once you move away from vanilla *NIX (e.g. I don't know Swift or AppleScript)

Thx -

Steve Martina

On Wed, 1 Apr 2020 at 10:05, lwouis notifications@github.com wrote:

@kungpaogao https://github.com/kungpaogao I tried also to sleep/wake and it didn't stop AltTab from working.

I think there is a big lack of clarity as to what behavior is exhibited with this issue.

From @stevemartina-salesforce https://github.com/stevemartina-salesforce, I understand that he presses the AltTab shortcut, but AltTab doesn't show up. Instead the built-in app-switcher does. Is AltTab opened at this point? I could imagine it crashed for example, which would explain why the built-in app-switcher is showing instead. That wouldn't explain why releasing the cmd key fails at that point. That could be a second, different issue, like AltTab not properly releasing global shortcuts on crash for example.

@kungpaogao https://github.com/kungpaogao is the above behavior exactly the same for you? Could you elaborate on the symptoms you see? I would really like to understand if AltTab is still running or if it crashed.

β€” You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/lwouis/alt-tab-macos/issues/157#issuecomment-607097806, or unsubscribe https://github.com/notifications/unsubscribe-auth/ANDR27PZYIZSLKKWCYKAVRLRKLYQZANCNFSM4KS6U36Q .

lwouis commented 4 years ago

@stevemartina-salesforce are you on the latest version now? If not, could you try it, and see if the issue still happens to you? It seems upgrading fixed it for @kungpaogao.

Another thing you could do is check in the System Preferences > Security & Privacy what's listed, and potentially removing/adding back.

stevemartina-salesforce commented 4 years ago

I've just downloaded v3.4.0, it looks great! I think the latest I tried before this was v3.1.3, I think it wasn't firing at all and I reverted to the previous known "mostly working" version.

I'll let you know if v3.4.0 exhibits the same odd behaviour. I'll give it a few weeks and if I don't see it I'll consider the issue fixed.

Thanks for all your work, this is a lifesaver for me...

Steve Martina

On Fri, 3 Apr 2020 at 08:43, lwouis notifications@github.com wrote:

@stevemartina-salesforce https://github.com/stevemartina-salesforce are you on the latest version now? If not, could you try it, and see if the issue still happens to you? It seems upgrading fixed it for @kungpaogao https://github.com/kungpaogao.

Another thing you could do is check in the System Preferences > Security & Privacy what's listed, and potentially removing/adding back.

β€” You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/lwouis/alt-tab-macos/issues/157#issuecomment-608259728, or unsubscribe https://github.com/notifications/unsubscribe-auth/ANDR27M4NOVRVGG22B7FN6TRKWARNANCNFSM4KS6U36Q .

lwouis commented 4 years ago

Hi @stevemartina-salesforce! Do you think we can close this issue now, or have you seen it happen again?

stevemartina-salesforce commented 4 years ago

I was going to ping you to let you know it seemed resolved, but then it happened again on Thursday. I suspect it might have something to do with being unplugged / replugged into a docking station? Not sure if it's the monitor changes or maybe a keyboard being added/removed but it happened again, and restarting didn't help.

Steve Martina

Senior Technical Architect

Commerce Cloud B2C Services | CSG EMEA Services

Mobile: +393429959196

https://www.salesforce.com

On Sun, 3 May 2020 at 17:43, lwouis notifications@github.com wrote:

Hi @stevemartina-salesforce https://github.com/stevemartina-salesforce! Do you think we can close this issue now, or have you seen it happen again?

β€” You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/lwouis/alt-tab-macos/issues/157#issuecomment-623129319, or unsubscribe https://github.com/notifications/unsubscribe-auth/ANDR27KW5OJFZ7CJRGG63I3RPWGINANCNFSM4KS6U36Q .

lwouis commented 4 years ago

Oh! Dynamically adding/removing keyboards! That's a use-case i haven't explored in depth! It's possible that registering keyboard inputs as we do for the shortcuts is specific to the active keyboard, and that switching to another keyboard means we need to bind again.

I'll experiment locally with keyboard, mouse, and display, being added and removed in the middle of using AltTab. I think that may be the root cause, and could affect also mouse and display. Update: I experimented with mouse, keyboard and displays connecting/disconnecting, and AltTab reacts perfectly to all scenarios.

lwouis commented 4 years ago

I just tested with my external bluetooth keyboard and connecting/disconnecting it doesn't affect AltTab at all. Interestingly, I can use AltTab with the built-in macbook pro keyboard, or the external bluetooth keyboard, or both at the same time like holding alt on one and tab on the other. This makes me think that there is an OS layer converting keyboards inputs to events, and we subscribe later on the stack at the events level which is independent on physical keyboards used.

To recap, things I have explored without reproducing the issue so far:

I'm a bit out of ideas on what could be triggering the issue here. Especially since it persists through AltTab being restarted.

One thing that may help: @stevemartina-salesforce could you please try following the instructions I wrote here? There is a link to a debug build of AltTab which logs keyboard events. You could run that build locally, and when it gets stuck next time, open Console.app, press the shortcut, and share here what is printed.

mfn commented 4 years ago

I've also experiences this, rare but it happens.

My unscientific impression was this happened when I was "faster then light" at times switching between windows/apps. Happened also to HyperSwitch countless of times.

I'll pay more attention next times about the details.

lwouis commented 4 years ago

I re-read this whole thread here, and to be honest I'm not 100% sure that we are all talking about the same issue. The descriptions given are a bit unclear to be honest.

Could you please record using Loom or some other easy to use tool to share video capture of your screen next time a similar issue happens? This way I can review the footage and maybe get a clue at what's happening. Right now I'm pretty much stuck because I have actually never seen it happen, the descriptions are pretty fuzzy as to what the behaviors are, and I tried every step-by-step here to reproduce and it didn't.

mfn commented 4 years ago

It always happens in the worst possible time where I can't just stop and and analyze it to deep :-( [i.e. during work]

Last time, CMD-tab was not recognized at all. Even stopping and starting (!) AltTab did not fix it. Eventually after "some time" it suddenly just worked again (same happened to HyperSwitch I was having run in CMD-~). I did not reboot to fix it, it simply "cured" itself.

I know, this is even less then you asked for, sorry!

lwouis commented 4 years ago

@mfn i'm starting to wonder if this issue is related to AltTab. You say that it affects HyperSwitch as well, and most importantly, that it happens when AltTab is not running. When AltTab is not running, there should not be any interaction with the OS.

I'm thinking that you may have some keyboard disfunction. Are you using an external keyboard, or is it a built-in macbook keyboard perhaps?

On macbooks, there has been lots of talks about defective keyboards for instance. Dust could get stuck behind the keys and prevent them from working properly.

Do you think this could be the issue here? This or another global app (I use Karabiner for instance to remap my keyboard)

mfn commented 4 years ago

that it happens when AltTab is not running

Hmm, wait, I didn't say that. Or at least, didn't meant to :)

CMD-tab falls back to its default OSX behaviour, using only the built-in app/window switching capabilities. Sorry if this wasn't clear.

I.e. closing AltTab and starting it again did not immediately fix it. It just happened to work after "some time" again (minutes, not hours).

Are you using an external keyboard, or is it a built-in macbook keyboard perhaps?

External! Connected via USB (2?) via adapter to USB-C

On macbooks, there has been lots of talks about defective keyboards for instance. Dust could get stuck behind the keys and prevent them from working properly.

Ah yes, but the key-press it's working, it's just AltTab (and HyperSwitch) not picking it up πŸ˜„

lwouis commented 4 years ago

@mfn It seems to me that the issue you describe is very different from the OP. We may want to make a new ticket to distinguish these. There may even be more than 3, because some of the descriptions here are a bit hard to visualise.

Now about your specific case, it's pretty mysterious. It may be a macOS issue where the queue of apps listening has some issue that fixes itself after a few minutes? Pretty much impossible to investigate without more data :/

joeberlin123 commented 4 years ago

@lwouis First of all, thank for the great app.

I see the same behavior as @mfn

lwouis commented 4 years ago

I just released v4.0.0 which I believe fixes this issue. I closed the ticket, but please if you encounter the issue again after upgrading, comment here and I'll re-open the issue immediately πŸ‘

stevemartina-salesforce commented 4 years ago

I've upgraded to v4 and the symptom immediately happens I'm afraid.

On Mon, 25 May 2020 at 19:51, lwouis notifications@github.com wrote:

I just released v4.0.0 which I believe fixes this issue. I closed the ticket, but please if you encounter the issue again after upgrading, comment here and I'll re-open the issue immediately πŸ‘

β€” You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/lwouis/alt-tab-macos/issues/157#issuecomment-633667200, or unsubscribe https://github.com/notifications/unsubscribe-auth/ANDR27LS7Q2UBETHFCUTQILRTKVWZANCNFSM4KS6U36Q .

joeberlin123 commented 4 years ago

I can confirm. Same here. Happened again...

lwouis commented 4 years ago

That's sad news. I was convinced thread explosion was the issue as i could reproduce that part locally with many windows open.

Could you guys use the built-in feedback form to send a debug profile here? That way we can see if something is up with your local environment like same version of macOS or something.

Another point: could you help me understand the symptoms? Currently, when the shortcut stop working, how is the app? Is it still running? Can you open the preferences or click "show"? You partially answered these questions already, but it's useful to go through them again for this new v4 i think as it may look similar but actually be a different bug.

Anyway thanks for helping the investigation! I never see this issue locally unfortunately

stevemartina-salesforce commented 4 years ago

I'll see what I can do about the debug profile - this is my work laptop and we're pretty strict (paranoid++) on security.

The symptoms:

FWIW, it magically started working again since my last email.

Thx for all your work on this, BTW. As far as I'm concerned, your app is the MacOS switcher. When it stops triggering and I see the standard switcher I know productivity will dip until your app kicks in again.

Steve Martina

On Tue, 26 May 2020 at 10:23, lwouis notifications@github.com wrote:

That's sad news. I was convinced thread explosion was the issue as i could reproduce that part locally with many windows open.

Could you guys use the built-in feedback form to send a debug profile here? That way we can see if something is up with your local environment like same version of macOS or something.

Another point: could you help me understand the symptoms? Currently, when the shortcut stop working, how is the app? Is it still running? Can you open the preferences or click "show"? You partially answered these questions already, but it's useful to go through them again for this new v4 i think as it may look similar but actually be a different bug.

Anyway thanks for helping the investigation! I never see this issue locally unfortunately

β€” You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/lwouis/alt-tab-macos/issues/157#issuecomment-633882232, or unsubscribe https://github.com/notifications/unsubscribe-auth/ANDR27OZX6AWDRZ2RXNUXITRTN35RANCNFSM4KS6U36Q .

lwouis commented 4 years ago

Based on your symptoms, then it must really be the OS event tap that starts sending the app the keyboard inputs. I asked ShortcutRecorder maintainer if he knew what could be the reason and he said that if the app takes too long to respond then the OS may disable the tap. However in v4 i reworked the code so that it returns the event to the tap extremely fast and does the work asynchronously. It was not doing much work anyway even in v3. I handled events asynchronously from v3 i believe.

Furthermore, there is code to detect that the tap was disabled and reenable it immediatly.

How this happens on your system is a mystery to me, and i don't see how to investigate that without you running the app in xcode locally and poking around the code with breakpoints and logs to see what is happening.

Only alternative i can imagine is that i make a local build of AltTab in which i add a bunch of logs near the tap code, and then you share those logs here next time it happens and we may get clues from that?

Oh and thanks for the encouraging words!

stevemartina-salesforce commented 4 years ago

I think it's a reasonable explanation - I did notice that very rarely nothing happens when I trigger AltTab with the keyboard shortcut. It's possible it's not responding within a set time, and then the OS no longer delivers events to it.

Having said that, most of the time there is no obvious pattern.

Steve Martina

On Tue, 26 May 2020 at 11:44, lwouis notifications@github.com wrote:

Based on your symptoms, then it must really be the OS event tap that starts sending the app the keyboard inputs. I asked ShortcutRecorder maintainer if he knew what could be the reason and he said that if the app takes too long to respond then the OS may disable the tap. However in v4 i reworked the code so that it returns the event to the tap extremely fast and does the work asynchronously. It was not doing much work anyway even in v3. I handled events asynchronously from v3 i believe.

Furthermore, there is code to detect that the tap was disabled and reenable it immediatly.

How this happens on your system is a mystery to me, and i don't see how to investigate that without you running the app in xcode locally and poking around the code with breakpoints and logs to see what is happening.

Only alternative i can imagine is that i make a local build of AltTab in which i add a bunch of logs near the tap code, and then you share those logs here next time it happens and we may get clues from that?

β€” You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/lwouis/alt-tab-macos/issues/157#issuecomment-633922426, or unsubscribe https://github.com/notifications/unsubscribe-auth/ANDR27MBSCSNV7FOQI4BTJTRTOFKFANCNFSM4KS6U36Q .

nathang21 commented 4 years ago

This happens to me fairly often still as well, will send a bug report as soon as I can and reference this issue.

Happy to install debug builds as well if I can help.

On Tue, May 26, 2020 at 4:30 AM Steve Martina notifications@github.com wrote:

I think it's a reasonable explanation - I did notice that very rarely nothing happens when I trigger AltTab with the keyboard shortcut. It's possible it's not responding within a set time, and then the OS no longer delivers events to it.

Having said that, most of the time there is no obvious pattern.

Steve Martina

On Tue, 26 May 2020 at 11:44, lwouis notifications@github.com wrote:

Based on your symptoms, then it must really be the OS event tap that starts sending the app the keyboard inputs. I asked ShortcutRecorder maintainer if he knew what could be the reason and he said that if the app takes too long to respond then the OS may disable the tap. However in v4 i reworked the code so that it returns the event to the tap extremely fast and does the work asynchronously. It was not doing much work anyway even in v3. I handled events asynchronously from v3 i believe.

Furthermore, there is code to detect that the tap was disabled and reenable it immediatly.

How this happens on your system is a mystery to me, and i don't see how to investigate that without you running the app in xcode locally and poking around the code with breakpoints and logs to see what is happening.

Only alternative i can imagine is that i make a local build of AltTab in which i add a bunch of logs near the tap code, and then you share those logs here next time it happens and we may get clues from that?

β€” You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub < https://github.com/lwouis/alt-tab-macos/issues/157#issuecomment-633922426 , or unsubscribe < https://github.com/notifications/unsubscribe-auth/ANDR27MBSCSNV7FOQI4BTJTRTOFKFANCNFSM4KS6U36Q

.

β€” You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/lwouis/alt-tab-macos/issues/157#issuecomment-633968281, or unsubscribe https://github.com/notifications/unsubscribe-auth/AB4CUJWG5GBSYGN56YGCYSTRTOR5FANCNFSM4KS6U36Q .

lwouis commented 4 years ago

Here is a release build I made locally. It has the log lines to try and understand what's happening on your machines: AltTab.app.zip

Could you please run this, and next time the issue manifests, press some of the shortcuts a few times, then grab the logs from Console.app by searching for AltTab there?

For reference, here are the additional log lines:

private func keyboardHandler(proxy: CGEventTapProxy, type: CGEventType, cgEvent: CGEvent, userInfo: UnsafeMutableRawPointer?) -> Unmanaged<CGEvent>? {
    os_log("keyboardHandler1: %{public}@, %{public}@, %{public}@",
        CGEvent.tapIsEnabled(tap: eventTap!), type, cgEvent)
    if type == .keyDown || type == .keyUp || type == .flagsChanged {
        os_log("keyboardHandler2: %{public}@", NSEvent(cgEvent: cgEvent))
        if let event_ = NSEvent(cgEvent: cgEvent),
           // workaround: NSEvent.characters is not safe outside of the main thread; this is not documented by Apple
            // see https://github.com/Kentzo/ShortcutRecorder/issues/114#issuecomment-606465340
           let event = NSEvent.keyEvent(with: event_.type, location: event_.locationInWindow, modifierFlags: event_.modifierFlags,
               timestamp: event_.timestamp, windowNumber: event_.windowNumber, context: nil, characters: "",
               charactersIgnoringModifiers: "", isARepeat: type == .flagsChanged ? false : event_.isARepeat, keyCode: event_.keyCode) {
            let appWasBeingUsed = App.app.appIsBeingUsed
            App.shortcutMonitor.handle(event, withTarget: nil)
            os_log("keyboardHandler3: %{public}@, %{public}@", appWasBeingUsed, App.app.appIsBeingUsed)
            if appWasBeingUsed || App.app.appIsBeingUsed {
                return nil // focused app won't receive the event
            }
        }
    } else if type == .tapDisabledByUserInput || type == .tapDisabledByTimeout {
        os_log("keyboardHandler4: %{public}@", CGEvent.tapIsEnabled(tap: eventTap!))
        CGEvent.tapEnable(tap: eventTap!, enable: true)
        os_log("keyboardHandler5: %{public}@", CGEvent.tapIsEnabled(tap: eventTap!))
    }
    os_log("keyboardHandler6: %{public}@", CGEvent.tapIsEnabled(tap: eventTap!))
    return Unmanaged.passRetained(cgEvent) // focused app will receive the event
}

and

shortcutActions[controlId] = ShortcutAction(shortcut: shortcut, actionHandler: { _ in
    os_log("actionHandler1: %{public}@, %{public}@", controlId, App.app.appIsBeingUsed)
    let isShortcutInitiatingTheApp = ["previousWindowShortcut", "nextWindowShortcut"].contains(controlId)
    if isShortcutInitiatingTheApp {
        App.app.appIsBeingUsed = true
    }
    os_log("actionHandler2: %{public}@", isShortcutInitiatingTheApp)
    if App.app.appIsBeingUsed {
        let isShortcutClosingTheUi = ["holdShortcut", "cancelShortcut"].contains(controlId)
        if isShortcutClosingTheUi {
            App.app.appIsBeingUsed = false
            App.app.isFirstSummon = true
        }
        os_log("actionHandler3: %{public}@, %{public}@, %{public}@", isShortcutClosingTheUi, App.app.appIsBeingUsed, App.app.isFirstSummon)
        DispatchQueue.main.async { () -> () in shortcutsActionsBlocks[controlId]!() }
    }
    return true
})
nathang21 commented 4 years ago

I'm not sure if this helps, but as soon as I installed and opened the debug version it started okay, I could edit my preferences.

However, as soon as I pressed the keyboard shortcut, or Menu --> Show the app instantly crashed. I never actually saw the Alt+Tab UI overlay show up, only the Mac OS default one appeared.

I captured the logs, hope these are useful still. Happy to try another version/steps as well.

157-debug.txt

lwouis commented 4 years ago

@nathang21 sorry about that! πŸ™‡β€β™‚οΈ I thought os_log had a decent API, and also it compiled so I thought it was correct. Turns out I was far from putting working log lines. I've updated the log lines, and tested locally. Now I can confirm it works correctly and doesn't crash the app.

Please use this build instead: AltTab.app.zip

nathang21 commented 4 years ago

New version worked great. I had trouble reproducing, although while the console was open, performance was not ideal when rapidly switching windows for a couple minuets. Seperate issue though, might not be much that can be done there.

Logs are here if they are helpful. Will continue using the debug version for a few days to see if I can get better repro.

157-v2-debug.txt

lwouis commented 4 years ago

Hey @nathang21, just to clarify: you couldn't actually reproduce the issue of this ticket while recording the logs you shared above? If so, there is not much use to look at them i'm afraid. I need to see what logs come out when AltTab stops responding to shortcuts.

Regarding the performance issue, could you please compare with the regular production build? That would help us learn if it is an issue specific to the ad-hoc build i shared here. In that case it could be that logs are adding overhead. I doubt that, but who knows

nathang21 commented 4 years ago

Hey @lwouis you were correct I had trouble reproducing so feel free to ignore the previous logs.

It hasn't been happening as often, but I did just have it happen once this morning, and I grabbed the console logs right after. 157-repo.txt

lwouis commented 4 years ago

@nathang21 thanks for sharing these logs! They are showing the symptoms indeed. Just compare them with the previous logs you shared. It's immediately apparent that something is wrong.

I noticed some log error from ShortcutRecorder inside, so I asked a question to the main maintainer.

When the logs start, the issue seem to already be happening. Could you share the logs before that, before 8:58:37? Basically, there are no actionHandler lines towards the top of your logs file. I would like to see from the last actionHandler, what happens so that these stop happening.

Also which shortcuts did you set for AltTab? Specifically this line:

image

nathang21 commented 4 years ago

Unfortunately I have restarted since then, so it looks like all the logs are gone.

Here are my key mappings. Screen Shot 2020-06-10 at 6 46 37 PM

lwouis commented 4 years ago

I dug a bit deeper in your logs, and it seems that the only times you pressed tab was in either of those combinations: control+tab or control+shift+tab. There are standalone presses of command, but it is never combined with tab.

I'm wondering if this is not an issue with some other app you use to remap your keyboard. I know I use Karabiner-Elements myself to remap control to command. It seems to me based on the logs, that AltTab is listening correctly to keyboard events, but that it's receiving shortcuts for which it is not set to react (i.e. control-tab and control-shift-tab) thus it's normal that it doesn't appear.

nathang21 commented 4 years ago

Woops I totally forgot to mention that, I should have thought about it. I am doing the exact same thing, via Karabiner-Elements to remap controlto command.

I can attach Karabiner-Elements logs next time as well if that would be helpful. Screen Shot 2020-06-10 at 7 17 08 PM

lwouis commented 4 years ago

Oh! That's your problem then! These rules are the issue. Not sure how rules order/priority work, but I can imagine, if they are run in order, your 3 rules have a logic bug where you remap control-tab to command-tab, then reverse it, then the 3rd rule does nothing.

Here is my setup that works, if you want to swap control and command (ignore the first line, which I like on the laptop keyboard):

image

That doesn't explain why the issue happens randomly for you though. Maybe right after your restart Karabiner-Elements?

nathang21 commented 4 years ago

That doesn't work for me unfortunately, but I think you're onto something about the rule order/hierarchy.

For context, I want to have Command + Tab for switching applications (via AltTab), and Control + Tab for switching tabs within an Application (aka chrome tabs etc.). Thus I want to swap the keys yes, but also separately configure those shortcuts which results in this odd looking config.

I've taken your options and tweaked them to my setup (see below). Will see if this works better, and report back. Screen Shot 2020-06-10 at 7 46 54 PM Screen Shot 2020-06-10 at 7 47 15 PM

lwouis commented 4 years ago

@stevemartina-salesforce @joeberlin123 @mfn @kungpaogao @kingfisher77 how about you guys? Are you using some software to remap keys as well?

If not, could you please run the version I shared here, and share the logs from Console.app when the issue happens? This ticket is the last remaining real bug in AltTab, and I would be thrilled to either close it as nothing to fix, or to find the root cause and fix it.

kungpaogao commented 4 years ago

Actually, since replying the first time and then updating, I haven't run into any issues with AltTab failing to trigger.

Thank you for the hard work, and hopefully others' issues are resolved!

EDIT: I don't use any remapping software.

joeberlin123 commented 4 years ago

@lwouis I'M not using software to remap keys like Karabiner. Now I installed the Alttab version with more debug logs. I'll send you the logs when the behavior starts again next time.

Kentzo commented 4 years ago

@lwouis Since ShortcutRecorder uses os_trace to log, it's better to use log stream --level debug --process [PID] as traces will eventually (in some cases quite soon) disappear from Console.app

lwouis commented 4 years ago

Hi @stevemartina-salesforce @joeberlin123 @mfn @kungpaogao @kingfisher77! Sorry to bother you guys again, but I would like to know if the issue is still happening on your machines? It still never happens on mine, so I need help to investigate it, if it still occurs.

If the issue is gone for everyone, then I'll happily close this ticket of course!

mfn commented 4 years ago

@lwouis yes, it does. It just happened yesterday night but often times when I'm in "work mode" and can't just stop :-/

Last night behaviour was like it just stopped being recognized and after some time (minutes? 10-15?) it just worked again. I did not restart AltTab in this case but I remember from the past times I tried this, it didn't solve it.

I don't remember in which issue I read it, but something when windows don't respond, AltTab doesn't work. Though AFAIR you fixed that…

I'm on the latest version btw, 4.1.5

lwouis commented 4 years ago

Could you please run this custom build with logs, and share the logs from Console.app when the issue happens? Without logs, I can't investigate further, and fix the issue unfortunately.

mfn commented 4 years ago

Roger!

and share the logs from Console.app

How does this work?

Open "Console" and filter for "alttab" in the search field and then… is there a way to export/save? Sorry not familiar with this app; this is all I see: image

Funnily the "save" on the right side seems to only save the "filter", not the log.

joeberlin123 commented 4 years ago

... the described behaviour unfortunately still exists.

I had used the custom build. Unfortunately I was so stupid and installed updates via the GUI afterwards πŸ™ˆ. So I have no log now...

But I noticed an interesting thing. I use https://www.deepl.com. The shortcut cmd+c defined there always seems to NOT work at the same time, when the shortcut for Alttab does not work. At some point, the shortcut starts to work again, Alttab also works again. Maybe this helps.

lwouis commented 4 years ago

@mfn you can select the line like clicking with the mouse, or doing command-a to select all for instance, then when you hit the copy-paste shortcuts, it will copy-paste the text from all the lines. That's the easiest way to share all the alt-tab logs here