Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AltTab closes on its own #704

Closed
alt-tab-macos-bot opened this issue Nov 20, 2020 · 44 comments
Closed

AltTab closes on its own #704

alt-tab-macos-bot opened this issue Nov 20, 2020 · 44 comments
Labels
bug Something isn't working need breakthrough Need a breakthrough idea to move forwards unreproducible Need help from the author to reproduce the issue

Comments

@alt-tab-macos-bot
Copy link

This issue was opened by a bot after a user submitted feedback through the in-app form.

From: ionescu.vlad1@gmail.com

Message:

For some reason, this has started crashing a lot on Big Sur. I am just doing my work: browsing, chatting and text editing, and all of a sudden alt+tab doesn't do anything anymore and the app isn't open. Everything works fine after I reopen.

Debug profile

  • App version: 6.12.0
  • App preferences:
    • MSAppCenter310AppCenterUserDefaultsMigratedKey: 1
    • MSAppCenter310CrashesUserDefaultsMigratedKey: 1
    • MSAppCenterInstallId: 9FD9482E-475B-4412-8BBB-743158FF2FE8
    • MSAppCenterPastDevices: {length = 1126, bytes = 0x62706c69 73743030 d4010203 04050607 ... 00000000 00000374 }
    • MSAppCenterSessionIdHistory: {length = 452, bytes = 0x62706c69 73743030 d4010203 04050607 ... 00000000 0000014e }
    • MSAppCenterUserIdHistory: {length = 447, bytes = 0x62706c69 73743030 d4010203 04050607 ... 00000000 00000149 }
    • NSWindow Frame SUUpdateAlert: 650 505 620 398 0 0 1920 1055
    • SUHasLaunchedBefore: 1
    • SULastCheckTime: 2020-11-20 15:11:02 +0000
    • SUUpdateRelaunchingMarker: 0
    • holdShortcut: ⌘
    • holdShortcut2: ⌘
    • menubarIcon: 0
    • nextWindowShortcut2: 1
    • preferencesVersion: 6.12.0
    • showHiddenWindows: 2
    • startAtLogin: true
    • updatePolicy: 1
    • windowMaxWidthInRow: 30
  • Applications: 58
  • Windows: 22
    • {isFullscreen: false, isMinimized: false, isHidden: false, isTabbed: false, isOnAllSpaces: false, spaceId: 1, spaceIndex: 1}
    • {isFullscreen: false, isMinimized: false, isHidden: false, isTabbed: false, isOnAllSpaces: false, spaceId: 1, spaceIndex: 1}
    • {isFullscreen: false, isMinimized: false, isHidden: false, isTabbed: false, isOnAllSpaces: false, spaceId: 1, spaceIndex: 1}
    • {isFullscreen: false, isMinimized: false, isHidden: false, isTabbed: false, isOnAllSpaces: false, spaceId: 1, spaceIndex: 1}
    • {isFullscreen: false, isMinimized: false, isHidden: false, isTabbed: false, isOnAllSpaces: false, spaceId: 1, spaceIndex: 1}
    • {isFullscreen: false, isMinimized: false, isHidden: false, isTabbed: false, isOnAllSpaces: false, spaceId: 1, spaceIndex: 1}
    • {isFullscreen: false, isMinimized: false, isHidden: false, isTabbed: false, isOnAllSpaces: false, spaceId: 1, spaceIndex: 1}
    • {isFullscreen: false, isMinimized: false, isHidden: false, isTabbed: false, isOnAllSpaces: false, spaceId: 1, spaceIndex: 1}
    • {isFullscreen: false, isMinimized: false, isHidden: false, isTabbed: false, isOnAllSpaces: false, spaceId: 1, spaceIndex: 1}
    • {isFullscreen: false, isMinimized: false, isHidden: false, isTabbed: false, isOnAllSpaces: false, spaceId: 1, spaceIndex: 1}
    • {isFullscreen: false, isMinimized: false, isHidden: false, isTabbed: false, isOnAllSpaces: false, spaceId: 1, spaceIndex: 1}
    • {isFullscreen: false, isMinimized: false, isHidden: false, isTabbed: false, isOnAllSpaces: false, spaceId: 1, spaceIndex: 1}
    • {isFullscreen: false, isMinimized: false, isHidden: false, isTabbed: false, isOnAllSpaces: false, spaceId: 18446744073709551615, spaceIndex: 9223372036854775807}
    • {isFullscreen: false, isMinimized: false, isHidden: false, isTabbed: false, isOnAllSpaces: false, spaceId: 18446744073709551615, spaceIndex: 9223372036854775807}
    • {isFullscreen: false, isMinimized: false, isHidden: false, isTabbed: false, isOnAllSpaces: false, spaceId: 18446744073709551615, spaceIndex: 9223372036854775807}
    • {isFullscreen: false, isMinimized: true, isHidden: false, isTabbed: false, isOnAllSpaces: false, spaceId: 1, spaceIndex: 1}
    • {isFullscreen: false, isMinimized: false, isHidden: false, isTabbed: false, isOnAllSpaces: false, spaceId: 1, spaceIndex: 1}
    • {isFullscreen: false, isMinimized: false, isHidden: false, isTabbed: false, isOnAllSpaces: false, spaceId: 1, spaceIndex: 1}
    • {isFullscreen: false, isMinimized: false, isHidden: false, isTabbed: false, isOnAllSpaces: false, spaceId: 1, spaceIndex: 1}
    • {isFullscreen: false, isMinimized: true, isHidden: false, isTabbed: false, isOnAllSpaces: false, spaceId: 1, spaceIndex: 1}
    • {isFullscreen: false, isMinimized: false, isHidden: false, isTabbed: false, isOnAllSpaces: false, spaceId: 1, spaceIndex: 1}
    • {isFullscreen: false, isMinimized: false, isHidden: false, isTabbed: false, isOnAllSpaces: false, spaceId: 1, spaceIndex: 1}
  • OS version: Version 10.16 (Build 20B29)
  • OS architecture: x86_64
  • Locale: en_RO (current)
  • Spaces: 1
  • Dark mode: Light
  • "Displays have separate Spaces": checked
  • Hardware model: MacBookPro15,1
  • Screens: 1
    • {x: 0.0, y: 0.0, width: 1680.0, height: 1050.0}
  • CPU model: Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
  • Memory size: 17.18 GB
  • Active CPU count: 16
  • Current CPU frequency: 2.3 Ghz
  • Resource utilization:
    • CPU: 0.0%
    • Memory: 82M
    • Threads count: 9

@lwouis
Copy link
Owner

lwouis commented Nov 20, 2020

When you restart the app, do you get the prompt to send a crash report? Did you press yes?

If you didn't get the prompt, could you please manually upload the crash report(s) here in a zip? You can find then in Console.app in Crash Reports on the left sidebar.

Please also note that Big Sur is not officially supported. By that i mean that it was never tested by me since i no longer update macOS versions in the first months of a new major release.

Thank you!

@ivdorelian
Copy link

When you restart the app, do you get the prompt to send a crash report? Did you press yes?

If you didn't get the prompt, could you please manually upload the crash report(s) here in a zip? You can find then in Console.app in Crash Reports on the left sidebar.

Please also note that Big Sur is not officially supported. By that i mean that it was never tested by me since i no longer update macOS versions in the first months of a new major release.

Thank you!

No, I do not get the option to send a crash report, and they do not appear in Console.app either. How strange - perhaps "crash" isn't the right term then, but the app does quit for no reason about 2-3 times a day. Sorry I couldn't be of more help, but do let me know if there's anything else I can do to help you debug this.

I understand that there's no official support yet hopefully it will come soon as I really like the app :).

Thanks and all the best!

@lwouis
Copy link
Owner

lwouis commented Nov 20, 2020

That's really weird. AltTab shouldn't stop without crashing. How is that possible? Maybe some permission issue, or a new feature of the OS similar to Sudden Termination, and not opt-in? Weird stuff.

If you can, try to notice the patterns when it does it, like is it when you plug an external display, after waking from sleep, etc

@lwouis lwouis added macOS 11 macOS 11 Big Sur specific issue bug Something isn't working unclear Need help from the author to provide more information to flesh out the issue unreproducible Need help from the author to reproduce the issue labels Nov 20, 2020
@ivdorelian
Copy link

Looking back on it and doing a few experiments, it seems to do it when I turn on my 2 external displays in the morning (don't know if exactly then or sometime during the night). I haven't had the chance to use my macbook much without external displays. Also during periods of more intense activity, such as opening multiple (10+) browser tabs, running some rather CPU intensive code etc. So it might have something to do with some sort of automatic unused app cleanup, I guess. My free RAM never gets below 3 GB (i have 16). I'm new to macs, whats Sudden Termination and where can I check if it's active?

I was able to reproduce it twice in the last 4 hours, but I still cannot do it on demand. A heavier workload seems to favor it, but I can't tell exactly.

@SoPat712
Copy link

During the time when it's crashed, is Alt-Tab using CPU? You can check by going to activity monitor, or using an app like IStatMenus to see what apps are using how much CPU during that particular moment. Are you able to open the preferences panel from the menubar, or is the entire app crashed? I've had an issue where under enormous workload, like rendering a video file in Premiere Pro, or building a particularly heavy app in Android Studio, but it's always loaded after waiting 5 or so seconds, and almost never occurs when my CPU usage is below 90%.

@ivdorelian
Copy link

No, it's just completely gone, not responding to alt+tab, not showing up in the menubar or activity monitor. I restart it with cmd+space > altTab.app. The "heavier workloads" i mentioned don't get my CPU that high, I haven't noticed hangs like that.

@ibrahimabdo
Copy link

I have the same issue after updating to Big Sur. I open AltTab, use it normally and after a while it doesn't work anymore and the process does not show up in Activity Monitor, and I have to start it again.

There is no crash log in Console.app either.

@ibrahimabdo
Copy link

Running AltTab through terminal (/Applications/AltTab.app/Contents/MacOS/AltTab), shows these outputs right before it closes:

"Adding app" 42827 "com.google.Keystone.Agent"
"OS event" "apps quit" [(42827, Optional("com.google.Keystone.Agent"))]
"Deinit app" "com.google.Keystone.Agent"
"Accessibility event" "AXApplicationActivated" "AltTab"
The application cannot be opened for an unexpected reason, error=Error Domain=NSOSStatusErrorDomain Code=-600 "procNotFound: no eligible process with specified descriptor" UserInfo={_LSLine=379, _LSFunction=_LSAnnotateAndSendAppleEventWithOptions}

It seems that it's always com.google.Keystone.Agent the last app that is handled before it crashes. I'm not sure if it's just a coincidence because I use Google Chrome a lot or not.

I cannot tell what was the last action it did because it runs well for several hours and I don't notice immediately when it crashes.

@PolCPP
Copy link

PolCPP commented Nov 30, 2020

Same issue here, crashes, no logs, i don't have chrome installed (use brave though) I've been running via terminal like @ibrahimabdo did and it crashed with the same message.

"Accessibility event" "AXApplicationActivated" "loginwindow"
"Accessibility event" "AXMainWindowChanged" "Inicio de sesión"
polcpp@MBP-de-Pol ~ %           The application cannot be opened for an unexpected reason, error=Error Domain=NSOSStatusErrorDomain Code=-600 "procNotFound: no eligible process with specified descriptor" UserInfo={_LSLine=379, _LSFunction=_LSAnnotateAndSendAppleEventWithOptions}

Seeing the log it seems to have crashed after returning from sleep.

I had moonlight running before getting it to sleep so maybe the process that was looking for was a moonlight window (since it closes it when network goes down on sleep)

@zakroma
Copy link

zakroma commented Dec 7, 2020

Same here on Big Sur. Very annoying :<

@ibrahimabdo
Copy link

One way to make this issue less noticeable until is fixed is to run AltTab from terminal in a loop:
while true; do; /Applications/AltTab.app/Contents/MacOS/AltTab; done

This way, when it crashes it will start again.

@lwouis
Copy link
Owner

lwouis commented Dec 7, 2020

Thanks @ibrahimabdo for the creative workaround! I'm overwhelmed with work currently. I hope soon to be able to download BigSur in a VM, and start seeing what I get there.

@PolCPP mentioned a potential cause with sleep/wake. Can anyone confirm if this plays a role or not?

@lwouis lwouis changed the title [In-app feedback] AltTab closes on its own under Big Sur Dec 14, 2020
@eischet
Copy link

eischet commented Dec 18, 2020

Hi guys, this might be related: I've noticed that since upgrading to macOS 11.x (now on 11.1), the app seems to always quit while the mac is sleeping overnight. I can't reproduce this with short sleeps during the day, but every morning I have to start the app again. No crash reports. It has also happened to me with Scroll Reverser, but there it happens only every couple of days. Maybe it's the OS that's "quitting" some apps for some arcane reason?

@lwouis
Copy link
Owner

lwouis commented Dec 18, 2020

It seems to be some change introduced by Big Sur that has to do with terminating apps silently. I haven't read any docs about Big Sur yet.

If someone has a link to a migration guide that would highlight this breaking change for instance, please share it here and i'll read it 👍

@lwouis
Copy link
Owner

lwouis commented Dec 18, 2020

I found this in the AppKit release notes:

The keys NSSupportsAutomaticTermination and NSSupportsSuddenTermination are no longer part of the default Info.plist for new Xcode projects. This ensures that applicationWillTerminate(_:) is called during termination, in cases where disableSuddenTermination or enableSuddenTermination is not used to explicitly manage the ability to quickly exit the app.

It doesn't seem like it should impact, but maybe they did other changes to Sudden Termination or Automatic Termination. Maybe fixing this issue is as easy as forcing them to false in the info.plist?

@lwouis
Copy link
Owner

lwouis commented Dec 21, 2020

Interesting read. The complexity of all the different state an app can be in, coupled with poor documentation from Apple on those features, and importantly, on their evolution, makes it difficult to evaluate what's at play for people reporting issues in this ticket.

I think I'll try setting this in the Info.plist:

<key>NSSupportsAutomaticTermination</key>
<string>false</string>

It's supposed to be false if not specified, but maybe they silently changed that in Big Sur. Here is a local build I made with this change. Can you please try it out and tell me if it fixes the issue for you? 👍

Just to recap the state of AltTab regarding these OS features that may be a problem here:

  • Automatic Termination: AltTab doesn't want that feature as it is not a good use-case for it. AltTab doesn't mention touch that setting. It's supposed to be false by default. The build above explicitly sets it to false in Info.plist
  • Sudden Termination: AltTab used to support this, but a feature we have now makes it impossible to support it, so it was set to false in Info.plist
  • App Nap: AltTab doesn't want that feature as it is not a good use-case for it. macOS seems to ignore the plist value, so AltTab uses a common programatic pattern to force it off.

@PolCPP
Copy link

PolCPP commented Dec 21, 2020

I've been running that build it since you posted it and it seems stable, no crashes yet. Will keep it running a few days more just in case.

Edit actually it's been running smoother too, not sure if related to that fix or some other commits applied since the last release

Edit 2 i had it crash just now. So it took me a full day for it to crash..

@ibrahimabdo
Copy link

I tested the local build too in the past 2 days and it is still crashing like before, unfortunately. So it's not that.

In terminal it's the same error as before:

The application cannot be opened for an unexpected reason, error=Error Domain=NSOSStatusErrorDomain Code=-600 "procNotFound: no eligible process with specified descriptor" UserInfo={_LSLine=379, _LSFunction=_LSAnnotateAndSendAppleEventWithOptions

@lwouis
Copy link
Owner

lwouis commented Jan 6, 2021

Apple as usual is not helping us much here with this error.

Anyone managed to get clear reproduction steps? I got Big Sur running in a VM, so I could test AltTab there. Everything works nice for me.

Many people here mentioned running the app through the Terminal. I tried it, and I had to add the 2 system permissions to Terminal.app. I assume people did that. Then it worked. I'm going to keep it running and see if I get the error.

Some things you could do to help:

  • Is AltTab.app in your /Applications folder? Running an app from other folders puts it into quarantine, and creates all sorts of bad side-effects. Make sure it runs from there. Normally the app should warn you if you run it from another path.
  • Can you run this command? pkgutil --check-signature /Applications/AltTab.app and share the output here?
  • Are you using only one user to do everything? Not switching users, or using sudo when running AltTab?
  • Are you using AppleEvents or AppleScripts? Apple says it may throw this error
  • You can try running this command: xattr /Applications/AltTab.app. For me on Catalina, it shows nothing, but on Big Sur, it shows com.apple.quarantine which seems to indicate it was put in quarantine even though it's in /Applications, and even though the app is correctly signed and notarised by Apple. If you see this, try removing the flag with xattr -dr com.apple.quarantine /Applications/AltTab.app.

@lwouis
Copy link
Owner

lwouis commented Jan 6, 2021

@zakroma @PolCPP @ibrahimabdo How are you running getting the error in the Terminal? When I run AltTab in the terminal the way you showed, it detached itself after a while. That is, the parent process stops being zsh and becomes launchd, and the Terminal window stops listing logs from the process. What are you doing to avoid that?

@ibrahimabdo
Copy link

@lwouis I didn't do anything special in the terminal. Just opened it and ran the command. Even now, after days of running (and some automatically restarts) I can see the output there.

To answer your questions from the previous message:

  • AltTab.app is inside /Applications folder. You can also see this from the command above: /Applications/AltTab.app/Contents/MacOS/AltTab
  • The output from pkgutil --check-signature /Applications/AltTab.app:
Status: signed by a certificate trusted by macOS
   Certificate Chain:
    1. Developer ID Application: Louis Pontoise (QXD7GW8FHY)
       Expires: 2025-01-27 11:04:18 +0000
       SHA256 Fingerprint:
           77 8C D1 D8 D5 ED 1A 94 70 0C 24 0C E1 89 82 62 79 0C BC F3 10 1D 
           DB 81 5E 72 B8 3B BA F5 1A A0
       ------------------------------------------------------------------------
    2. Developer ID Certification Authority
       Expires: 2027-02-01 22:12:15 +0000
       SHA256 Fingerprint:
           7A FC 9D 01 A6 2F 03 A2 DE 96 37 93 6D 4A FE 68 09 0D 2D E1 8D 03 
           F2 9C 88 CF B0 B1 BA 63 58 7F
       ------------------------------------------------------------------------
    3. Apple Root CA
       Expires: 2035-02-09 21:40:36 +0000
       SHA256 Fingerprint:
           B0 B1 73 0E CB C7 FF 45 05 14 2C 49 F1 29 5E 6E DA 6B CA ED 7E 2C 
           68 C5 BE 91 B5 A1 10 01 F0 24
  • On my laptop I have only one user, and I do not run AltTab in terminal with sudo, but I do use sudo for other commands.
  • Not using any AppleEvents or AppleScripts as far as I know
  • Running xattr /Applications/AltTab.app does not output anything

@lwouis lwouis added need breakthrough Need a breakthrough idea to move forwards and removed unclear Need help from the author to provide more information to flesh out the issue labels Jan 7, 2021
@lwouis
Copy link
Owner

lwouis commented Jan 15, 2021

I got a potential hypothesis of what could be happening.

Every 5s, the app checks the state of System Permissions (Accessibility and Screen Recording). The Screen Recording permission however, was introduced in 10.15, and there is no public API to check if it's granted or not. So I used a workaround. It's possible that this workaround fails in exotic scenarios, creating this situation where AltTab exits on his own without crashing.

What's not explained in this hypothesis is why the code doesn't restart though, as this scenario is supposed to trigger a restart, not a simple quit. And when I stress test it manually many time by removing the permission as it's running, it successfully restarts.

I made a local build which logs extra lines if the check every 5s fails. Could you guys try this build on your machine? Run it through the Terminal, so you see the logs. When it stops, please share the end of the logs here. Thanks!

@PolCPP
Copy link

PolCPP commented Jan 15, 2021

@lwouis I've run it this morning from xcode to see if i could catch something extra and it crashed pair of minutes ago, i'm pretty sure that error doesn't fire up when you run it from the terminal. It crashed just after those 4 lines without complaining

"Accessibility event" "AXMainWindowChanged" "General"
"Accessibility event" "AXApplicationActivated" "AltTab"
2021-01-15 19:02:33.544231+0000 AltTab[31318:1184663] [main] 10759711: Error #17  (os/kern) invalid right attempting to add send right to port ( port:187691/0x2dd2b rcv:0,send:0,d:1 limit:0).
"Accessibility event" "AXWindowMoved" "General"

(This is unrelated to the Apple silicon thing, ran it on a 16 inch mbp)

@lwouis
Copy link
Owner

lwouis commented Jan 16, 2021

You have run what in XCode? The master branch?

Could you try running the build i shared above? It has extra log lines.

in your logs, i'm wondering what on Earth this is:

2021-01-15 19:02:33.544231+0000 AltTab[31318:1184663] [main] 10759711: Error #17 (os/kern) invalid right attempting to add send right to port ( port:187691/0x2dd2b rcv:0,send:0,d:1 limit:0).

Also it would seem that it crashed after you focused AltTab preferences window and move it. Do you remember doing that?

@PolCPP
Copy link

PolCPP commented Jan 16, 2021

Yeah, it was master.

I'm pretty sure that the settings window was closed but maybe i had it open on the background since i copied the settings to the new mac. Was writing some docs so i was switching between iterm, vs code, brave, and slack.

Edit: I just set it to run.
Edit 2 18/1 Morning, still no crash yet

@PolCPP
Copy link

PolCPP commented Jan 19, 2021

Added an extra one instead of editing so you get an email notification.

It finally crashed. Does this give you any additional info?

"Accessibility event" "AXApplicationActivated" "Splashtop Business"
"screenRecordingIsGranted_ 1"
"screenRecordingIsGranted_ 1"
"screenRecordingIsGranted_ 1"
"screenRecordingIsGranted_ 1"
"screenRecordingIsGranted_ 2" "Splashtop Business"
"screenRecordingIsGranted_ 3" <NSRunningApplication: 0x7f82c1e09e10 (com.splashtop.stb.macosx - 18968) LSASN:{hi=0x0;lo=0x15d15d}>
"screenRecordingIsGranted_ 1"
"screenRecordingIsGranted_ 2" "Dock"
"screenRecordingIsGranted_ 3" <NSRunningApplication: 0x7f82c43da2e0 (com.apple.dock - 448) LSASN:{hi=0x0;lo=0x15015}>
"screenRecordingIsGranted_ 1"
"screenRecordingIsGranted_ 2" "Dock"
"screenRecordingIsGranted_ 3" <NSRunningApplication: 0x7f82c3711e90 (com.apple.dock - 448) LSASN:{hi=0x0;lo=0x15015}>
"screenRecordingIsGranted_ 1"
"screenRecordingIsGranted_ 3" "nil"
"screenRecordingIsGranted_ 4" [[kCGWindowOwnerPID: 18968, kCGWindowBounds: {
    Height = 1120;
    Width = 1792;
    X = 0;
    Y = 0;
}, kCGWindowStoreType: 1, kCGWindowAlpha: 1, kCGWindowSharingState: 0, kCGWindowMemoryUsage: 1232, kCGWindowNumber: 9606, kCGWindowIsOnscreen: 1, kCGWindowOwnerName: Splashtop Business, kCGWindowLayer: 0], [kCGWindowStoreType: 2, kCGWindowAlpha: 1, kCGWindowBounds: {
    Height = 1120;
    Width = 1792;
    X = 0;
    Y = 0;
}, kCGWindowIsOnscreen: 1, kCGWindowOwnerPID: 448, kCGWindowName: Fullscreen Backdrop, kCGWindowNumber: 9566, kCGWindowMemoryUsage: 5440, kCGWindowLayer: -2147483622, kCGWindowOwnerName: Dock, kCGWindowSharingState: 1], [kCGWindowSharingState: 1, kCGWindowMemoryUsage: 1232, kCGWindowName: Desktop Picture - __7_eleven_drawn_by_koh_minagi_kou__f6f6fed607deb16681e76c0c9e53b1de.jpg, kCGWindowNumber: 9575, kCGWindowLayer: -2147483624, kCGWindowIsOnscreen: 1, kCGWindowBounds: {
    Height = 1120;
    Width = 1792;
    X = 0;
    Y = 0;
}, kCGWindowOwnerName: Dock, kCGWindowStoreType: 1, kCGWindowOwnerPID: 448, kCGWindowAlpha: 1], [kCGWindowIsOnscreen: 1, kCGWindowLayer: -2147483626, kCGWindowAlpha: 1, kCGWindowMemoryUsage: 5440, kCGWindowName: Desktop, kCGWindowSharingState: 1, kCGWindowStoreType: 2, kCGWindowBounds: {
    Height = 1120;
    Width = 1792;
    X = 0;
    Y = 0;
}, kCGWindowOwnerName: Window Server, kCGWindowNumber: 2, kCGWindowOwnerPID: 148]]
"observePermissionsPostStartup" true false
"Accessibility event" "AXUIElementDestroyed" "nil"

@lwouis
Copy link
Owner

lwouis commented Jan 19, 2021

@PolCPP wow very cool! It seems that this was indeed the issue in the end: the app mis-detecting that the Screen Recording permission is not granted, and quitting.

I think the next step now is that I find a heuristic that still detects the Screen Recording permission status, without the false negatives.

Another thing would be to try and understand why the app is not restarting for you. Something may be wrong with the restart code.

@lwouis
Copy link
Owner

lwouis commented Jan 19, 2021

Wow back in the day I implemented something based on this StackOverflow thread. I see that today they have found an actual public API that checks it. I guess official documentation from Apple didn't help with discoverability...

I'll try this out. I'm worried that it could be missing on early minor versions of macOS 10.15 though. Not easy to tell if it's safe for these users

Update: it crashes on my machine (running 10.15.7)

dyld: Symbol not found: _CGPreflightScreenCaptureAccess
  Referenced from: /Users/lwouis/Library/Caches/JetBrains/AppCode2020.3/DerivedData/alt-tab-macos-gxyfkayjoyzvawcavapngminwlnu/Build/Products/Debug/AltTab.app/Contents/MacOS/AltTab
  Expected in: /System/Library/Frameworks/CoreGraphics.framework/Versions/A/CoreGraphics

Signal: SIGABRT (signal SIGABRT)

It looks like the API was added recently, in macOS 11. I see it in the 11.1 SDK but not in the 10.15 SDK.

I think what this means is that it's a newly exposed API, that can be used in targets from 10.15 onwards. It's a weird thing, and I don't know if we can trust it. I'm going to try to compile from within a macOS 11 VM and see if that runs on my system. Man the hoops we have to jump through with Apple...

@PolCPP
Copy link

PolCPP commented Jan 19, 2021

Actually it restarted found by chance that the terminal started one was dead.

@lwouis
Copy link
Owner

lwouis commented Jan 19, 2021

Actually it restarted found by chance that the terminal started one was dead.

But this ticket is about AltTab closing on its own, which implies it wouldn't restart but remain closed.

Does it usually restart or stay closed?

Maybe the issue is a mix of false-positive permission checks triggering a restart + the restart code failing to restart sometimes?

@PolCPP
Copy link

PolCPP commented Jan 19, 2021

@lwouis Actually it just crashed on me on the other mac without restart. So i guess i was lucky and it autorestarted that time.

@lwouis
Copy link
Owner

lwouis commented Jan 19, 2021

I was able to build on macOS 11 and try the new CGPreflightScreenCaptureAccess API. Well, it sucks. It doesn't update during the app runtime. It only returns the state of the permission when the app was launched.

I'm going to try and use this alternative workaround instead of the one I'm using currently. Hopefully it doesn't produce false negatives like the current one. In my tests it's behaving well.

I've also updated the restart code, so that hopefully it always succeeds to restart instead of only closing.

@PolCPP @MuhammedZakir @ibrahimabdo @ivdorelian @eischet Here is a local build with both fixes. Could you please try it out and let me know if it fixes the issue from this ticket? Hopefully it's now very stable

@eischet
Copy link

eischet commented Jan 19, 2021

Thanks, I'm running the local build now. No issues yet...
I'll have a look at Alt-Tab when I return to the office tomorrow.

You seem to have fixed the (unrelated, I think) issue where the IntelliJ cursor disappears after pressing Ctrl-Enter, too, which is great. :-)

@lwouis
Copy link
Owner

lwouis commented Jan 19, 2021

You seem to have fixed the (unrelated, I think) issue where the IntelliJ cursor disappears after pressing Ctrl-Enter, too, which is great. :-)

This fix and a few others will be released in the next public release. I've had them on the back-burner for a while. I was waiting for the author of #727 (comment) to test the ticket to release the Jetbrains fix.

@eischet
Copy link

eischet commented Jan 20, 2021

Just came back to the office and woke up my old Mac Pro: Alt-Tab is still running. I think that's the first time since "upgrading" to Big Sur. Thank you!

Update: one day later, it's still working.

@ibrahimabdo
Copy link

So far so good, with the latest build it didn't crashed anymore and it's 2 days already. Will report back in case it will.

@lwouis
Copy link
Owner

lwouis commented Jan 22, 2021

Excellent news! I'll make a public release after the weekend then! Please let me know around that time if it's still working great 👍

@ibrahimabdo
Copy link

AltTab survived the weekend, and the whole week. Not a single crash for me. 👍

@eischet
Copy link

eischet commented Jan 25, 2021

Same here: not a single issue yet... the app has been running fine for 5 days in a row.

@lwouis
Copy link
Owner

lwouis commented Jan 25, 2021

Cool! I'll make a public release then 👍

@lwouis lwouis closed this as completed in d621ce5 Jan 25, 2021
lwouis pushed a commit that referenced this issue Jan 25, 2021
# [6.13.0](v6.12.0...v6.13.0) (2021-01-25)

### Bug Fixes

* app would sometimes quit while in the background (closes [#704](#704)) ([d621ce5](d621ce5))
* disable standard tab detection for all JetBrains apps ([25343ea](25343ea)), closes [#716](#716)
* prevent macos 11 from terminating alt-tab randomly ([2447140](2447140))
* restarting the app would sometimes fail to start again ([56d47fc](56d47fc))
* show window controls, even when mouse hover option is disabled ([c256933](c256933))

### Features

* add app category meta-data ([96572a8](96572a8))
* add swedish and czech localizations ([00e95d6](00e95d6))
* add ukrainian localization ([e576ca1](e576ca1))
* display windows partially on screen correctly (closes [#727](#727)) ([2f92936](2f92936))
* show window partially on-screen (closes [#727](#727)) ([b121162](b121162))
* update japanese, turkish, chinese localizations ([7226c25](7226c25))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working need breakthrough Need a breakthrough idea to move forwards unreproducible Need help from the author to reproduce the issue
Projects
None yet
Development

No branches or pull requests

9 participants