SwiftcordApp/Swiftcord

[Bug]: Swiftcord locks up on wake

PaRkThEcAr opened this issue · 9 comments

Describe the Bug

Bug Description
Swiftcord will lock up on Macs running the M1 Max chipset after a few hours of inactivity. this is prominent when the machine is waking up from sleep. on macos 13.0.1

Actual Behaviour
program locks up requiring you to force quit before you use it.

Expected Behavior
the program to let you continue using it.

Reproducing the Bug

1... Launch Swiftcord on M1 Max macOS device running macos 13.0.1
2... let it sit idle for a while. you can let it fall asleep or use other programs.
3... come back and the program will be frozen.

Version

0.5.1

Category

Other

Relevant Log Output

No response

Screenshots

No response

Additional Info

No response

Same occurs on my 2018 macbook pro 15"

This bug is concerning and sounds like a reconnect loop of some sort. Is it possible for you guys to help retrieve Swiftcord's logs following this guide? It'll be most helpful to obtain the logs right after a hang.

Yeah! i can get logs for it when i get home today.

@PaRkThEcAr I just reproduced this issue, actually. By any chance were you using an external monitor?

Some notable observations:

  • Swiftcord never locks up during inactivity, the hang occurs seconds before waking from sleep
  • This seems to be some issue related to resuming the window location after sleeping, but I'm not too sure

Things specific to an external display - I'm using an LG 32UN880 which charges and receives video from one USBC cable. I leave my Mac plugged in all the time, but sometimes with its lid closed. This issue seems to stem from the Mac "sleeping" while connected to the external display (macOS never really sleeps when power is connected).

  • Throughout the time when the lid is closed, this message is spammed multiple times a second in the console:
    [] [0x146955020] Bad CurrentVBLDelta for display 1 is zero. defaulting to 60Hz.
    
  • Right after macOS wakes up, the following lines are printed out repeatedly until the hang occurs:
    [default] Invalid display 0x00000001
    

These messages do not appear without an external display connected, which makes me think this is an issue pertaining to waking from sleep with an external monitor.

After leaving this running for a day after the hang, it didn't recover and the only thread with any activity was the Sentry hang thread. It's safe to say this is a fatal hang.

Screenshot 2023-01-01 at 9 17 57 AM

@PaRkThEcAr I just reproduced this issue, actually. By any chance were you using an external monitor?

sorry for the late replies on this XD life has been busy so i hope this is useful:

Yes, i am using an external monitor! its a 2012 thunderbolt display going over a Thunderbolt 2 -> Thunderbolt 3 Adapter.

to comment on the newer threads, it seems its a UI thing. were you able to isolate and address the issue?

@PaRkThEcAr From my logs, it appears to be something to do with macOS moving the main window to a non-existent display while trying to restore the window location on wake. I'm hypothesising that this occurs because external monitors wake after the Mac does, so it doesn't actually exist when macOS tries to restore window position.

However, I neither know why this leads to an app hang, nor how to fix it.

Unfortunately, I just had this same issue occur to one of my other, much simpler, SwiftUI app with the exact symptoms.

These were the last logs right before the hang, which also aligns with what we're experiencing in Swiftcord:
Screenshot 2023-07-27 at 7 51 05 PM

Thus it appears that this isn't an isolated issue in Swiftcord but instead a problem within SwiftUI/AppKit/macOS. I regret to inform that there is not much that we can do to work around issues like these, due to their unpredictable native.