BTT option "restart btt after wake from sleep" restarts after lldl debugging finishes and possibly other random events

Note: Before bug reporting, please make sure you have tried the latest (alpha) version of BetterTouchTool and that you have already tried to restart your system :-). If you encounter a crash, please attach a crash log from the macOS Console.app from the "User Diagnostic Reports" section.

Describe the bug
When enabling the "Restart BTT after wake from sleep option" and then running a project with lldl debugging enabled in the Lazarus IDE, when the project app closes, BTT restarts as if computer woke from sleep. Does not happen if running the project without debugging.

Affected input device (e.g. MacBook Trackpad, Magic Mouse/Trackpad, Touch Bar, etc.):
Macbook Pro 2021 16" m1 max

Screenshots
N/A

Device information:

  • Type of Mac: Macbook pro 2021 m1 max 16"
  • macOS version: 13.1
  • BetterTouchTool version: (please post the exact version - not just "the latest one") 3.952 2117

Additional information (e.g. StackTraces, related issues, screenshots, workarounds, etc.):
When the test app with debugging quits, log says the following. Disabling "wake from sleep" option in BTT stops BTT from restarting like this. Also, adding an entry to react to "wake from sleep" with "restart BTT" within the app, as an event, does NOT produce this issue. This issue also happens randomly during other events as it seems, but I have been unable to pinpoint which so far. It doesn't crash, just restarting like this. We'll see if these other events also stop triggering the behavior now that I disabled the option.

1671006174.667532|ASL|found|

1671006174.667977|SNAPAREA|return existing (updated)|

1671006174.668007|SNAP|Did recognize 41040 4251086178 dragpoints: 0 - 4|

1671006174.668035|SNAP|Did reset snap areas 1 0|

1671006190.249164|LOGIN|RESTART AFTER LOGIN|

1671006190.253759|xw|should relaunch|

1671006190.254322|xw|BTTRelaunch found|

1671006190.254378|xw|BTTRelaunch call seems successfull|

1671006190.267770|TERMINATE|SHOULDTERMINATE|

1671006190.619228|ASL|NSDocumentController Info.plist warning: The values of CFBundleTypeRole entries must be 'Editor', 'Viewer', 'None', or 'Shell'.|

1671006190.640833|SYS|Running on macOS: 13.1.0|

The only time this message is logged, is if the previous active app was the login window (com.apple.loginwindow) and only if before that a wake event has been triggered by the system (NSWorkspaceDidWakeNotification)

I have no idea why this would happen after debugging :frowning:

That's so weird. And if I disable that option in settings and replace it with an event triggering on wake from sleep (same action: restart btt), the issue doesn't happen anymore. Is there a difference in how this event is triggered vs the setting in general setting?

I first acknowledged this issue when adding a notification when the battery goes below 30%. Since this event is triggered after every restart of btt, it became an indicator of btt unexpectedly restarting. Looking at the log, I noticed plenty of these restarts at random times. The only consistent example is the case with the iidb debugger finishing when a test project app stops.

Ok, so I've been going days now with the "Restart on wake from sleep" option OFF in settings, BUT replacing it with an event that reacts to "wake from sleep" with the action of restarting BTT: i.e. the exact same thing, just not using the built in setting.

And I have ZERO random restarts. There really is a difference and something going on with the setting "Restart on wake from sleep" that makes BTT restart when the lldb debugger finishes and at other random times.