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

Option to disconnect/reconnect dummies after sleep to further fix sleep issues #13

Closed
wookash opened this issue Oct 26, 2021 · 33 comments
Closed
Assignees
Labels
done All tasks are completed enhancement New feature or request released Released

Comments

@wookash
Copy link

wookash commented Oct 26, 2021

Hi, I'm using MBA M1 on my 34uc88 (2k) monitor and I really like the app. The only issue that I have is that is does not display any picture on the external device once MBA is waking from sleep. I have to kill the app and re-launch it, which is daunting. Is there any way to fix this?

@waydabber
Copy link
Owner

Interesting. Is the built-in display open as well? Can you describe the exact display and mirroring configuration you use? Does this issue happen after short sleeps as well or only after longer periods of sleep?

But sure, I could add an option to disconnect and then reconnect the virtual display upon wake if that helps (that should be identical to relaunching the app) - but this will cause temporary changes/flickering in resolution (especially is there is a switch from and to HiDPI mode).

@wookash
Copy link
Author

wookash commented Oct 26, 2021

hi, I'm closing the built in display (lid), device goes to sleep, I open the lid and the built-in display wakes but the external monitor seems to wake but displays black screen (most often). I configured app as per your instructions and chose resolution (HIDPI) 2408 x 1008. In some cases (rare) screen flickers, in other cases black screen is on both built0in and external screens. This behavior is now tested on battery btw. not when plugged in to charger. [edit] seems to be the same when plugged in

@waydabber
Copy link
Owner

Thank you, I will try to recreate and investigate this. I'll also provide a test version which you could try that cycles the created dummies upon wake to see if that helps.

@waydabber waydabber self-assigned this Oct 27, 2021
@waydabber waydabber added the bug Something isn't working label Oct 27, 2021
@wookash
Copy link
Author

wookash commented Oct 27, 2021

Thanks. Let me know when I can test it. And keep up awesome work!

@waydabber
Copy link
Owner

Of course. I'll implement it as soon as I get to it! #17 is needed first as an underlying functionality. :)

@waydabber waydabber added the in progress Implementing label Oct 27, 2021
@waydabber waydabber changed the title Sleep issue Option to disconnect/reconnect dummies after sleep to further fix sleep issues Oct 27, 2021
@waydabber
Copy link
Owner

waydabber commented Oct 28, 2021

Hey @wookash

can you please try this beta and see if it helps? Please enable Settings/Disconnect and Reconnect...

Screen Shot 2021-10-28 at 22 08 01

https://github.com/waydabber/BetterDummy/releases/tag/v1.0.6b

Thanks for your feedback in advance! :)

(btw... this might not help or the cycling might happen to quickly and I need to add a delay for it to help, just want some early feedback as I cannot reproduce the actual issue on my setup)

@waydabber waydabber added done All tasks are completed and removed in progress Implementing labels Oct 28, 2021
@wookash
Copy link
Author

wookash commented Oct 28, 2021

hey, thank you for this update. Unfortunately, does not seem to work - all sort of issues when on battery, does not seem to reconnect after sleep (weird things happen like a portion of screen is visible - "small window"). On power adapter, device wakes fine but "forgets the dummy", i.e. the app shows dummy connected but it's not visible in display preferences and does not yield effect, meaning it does not apply the correct resolution..

@wookash
Copy link
Author

wookash commented Oct 28, 2021

@waydabber
Copy link
Owner

All right. It seems like the dummy is discarded all right but is not recreated properly somehow. If you connect on Disconnect and then Connect, does it reactivate then?

It might be that the display itself is waking from sleep slowly and this wreaks havoc. Can you please try what happens if you activate display sleep only briefly but wake before the display itself goes to fully scleep (like for half a second or so - you can try this by defining a hot corner for sleep or use a keyboard shortcut Shift+Control+Eject - if you have an Eject key?

Thank you!

@wookash
Copy link
Author

wookash commented Oct 28, 2021

All right. It seems like the dummy is discarded all right but is not recreated properly somehow. If you connect on Disconnect and then Connect, does it reactivate then?

Yes, it reconnects

It might be that the display itself is waking from sleep slowly and this wreaks havoc. Can you please try what happens if you activate display sleep only briefly but wake before the display itself goes to fully scleep (like for half a second or so - you can try this by defining a hot corner for sleep or use a keyboard shortcut Shift+Control+Eject - if you have an Eject key?

Thank you!

when I did that, the external monitor went black, I could not adjust brightness on the built-in display and after a moment both screens went black after which the dummy was discarded automatically and the picture showed on both displays. I could then manually disconnect and re-connect the dummy and then it works

[edit] the second time when I disconnected the dummy after waking, both screens showed black screen but with visible cursor. I had to put laptop to sleep (wait a few seconds) and then after waking, the dummy was disconnected

@waydabber waydabber added in progress Implementing and removed done All tasks are completed labels Oct 28, 2021
@waydabber
Copy link
Owner

Well. I am not sure what to make of that at the moment. If this solution does not work, I can try making the whole thing delayed or alternatively disconnect the dummy upon sleep and reconnect after wake, or combine it (disconnect upon sleep, reconnect upon wake but wait about 5 seconds before that). We can try these combinations and see which one seems to be the most stable one. :)

@wookash
Copy link
Author

wookash commented Oct 28, 2021

@waydabber cool. Happy to test this :)

@waydabber
Copy link
Owner

All right, I'll let you know if I have the versions for this (I'll upload them somewhere so you can download them). I'll need some time - it might be that I can get back to it during the weekend only (sorry about that and thanks for your patience).

@waydabber
Copy link
Owner

Hi, I tweaked the Settings/Disconnect and Reconnect on Sleep a bit in the latest release. Can you please try this one? If it still does not work, I might provide test releases with more delays to see which one works best. Thank you!

@waydabber waydabber added awaiting response from issue reporter Needs further info and removed in progress Implementing labels Oct 30, 2021
@wookash
Copy link
Author

wookash commented Oct 30, 2021

hi @waydabber. Thanks for this release - it seems to work fine - I will test more and let you know but so far so good! I have only one challenge - I cannot build it from the source - I'm repeating the same steps as before but the only component that is built is the better dummy helper not the main app

[edit] got to the point where I only have this warning:
Screenshot 2021-10-30 at 14 13 02

@waydabber
Copy link
Owner

Hi,

yes, you have to install SwiftFormat and SwiftLint to compile. But this is not needed if you just want to tinker for yourself and not create pull requests - in this case you simply need to remove these items from Build Phases and everything will work out:

Screen Shot 2021-10-30 at 15 53 01

If you want to play with the timing of the reconnect after sleep, change this line:

https://github.com/waydabber/BetterDummy/blob/d6e817951375876ba9152cbbe64aec0b2b9c3e3d/BetterDummy/AppDelegate.swift#L211

the 3.0 there means three seconds after the wake event.

@waydabber waydabber added done All tasks are completed and removed awaiting response from issue reporter Needs further info bug Something isn't working labels Oct 30, 2021
@wookash
Copy link
Author

wookash commented Oct 30, 2021

hey, cool, all clear now, wasn't sure if I can remove this phases and tried to install the missing items. cheers!

@waydabber waydabber added the enhancement New feature or request label Oct 30, 2021
@wookash
Copy link
Author

wookash commented Oct 30, 2021

ok, so I've tested it a bit more and most of the times it works. When I wake up the device, it takes a moment, lags a bit but then launches the dummy and restores resolution. However the sizes of open windows are different (e.g. web browser is not covering full screen, and after a few seconds restores previous full screen position)

But on a few occasions it displays 1/3 screen black and after putting it to sleep and waking up displays correct picture. Sometimes both screens are black and after a while dummy seems to reset and starts working fine.

Overall it kind of works, but would be great if performance was better (btw. I changed DispatchQueue.main.asyncAfter to 2

@waydabber
Copy link
Owner

Interesting. It should not be this sluggish. Maybe you have some stuff running that drains the system a bit. If you experience too many issues, it would make sense to increase the wait time a bit further instead. Also there is an other means to fix sleep, the creation of the temporary display. You might want to try two things:

  1. Disable the creation of this temporary display by commenting out (disabling) the following line:

https://github.com/waydabber/BetterDummy/blob/2b4b2a027f02180e12970a8692b957fc840da5b5/BetterDummy/AppDelegate.swift#L235

  1. Delaying the removal of the temporary display by moving the following two lines to in front of line 221 (under asyncWakeReconnect()):

https://github.com/waydabber/BetterDummy/blob/2b4b2a027f02180e12970a8692b957fc840da5b5/BetterDummy/AppDelegate.swift#L208-L209

@waydabber
Copy link
Owner

I'll now close this issue, but please let me know if you come to any conclusion whether some combination of code works better - if so, then I'd like to update the main version accordingly. Thank you!

@wookash
Copy link
Author

wookash commented Oct 31, 2021

Hey. Will do. I spent time on other things with my home server. Will let you know if I have any news to report. Thank you!

@wookash
Copy link
Author

wookash commented Nov 2, 2021

@waydabber just wanted to report that I took version 1.0.7 and made both tweaks you advised here: #13 (comment)

I also set up DispatchQueue.main.asyncAfter(deadline: in line 211 to 2, not sure if this is needed

Now all works like a charm! even when laptop is waking up from sleep. I will teat lates with clamshell mode (I'm using no clamshell script for the time being)

thank you very much!

@waydabber
Copy link
Owner

Great!

@waydabber
Copy link
Owner

So you say you removed line 235 and sleep works properly (monitor turns off etc?)

@waydabber
Copy link
Owner

waydabber commented Nov 2, 2021

I will make that optional then ("Do not alter display configuration for sleep") as for some it might actually work better.

I reopen this issue now.

@waydabber waydabber reopened this Nov 2, 2021
@waydabber waydabber added in progress Implementing and removed done All tasks are completed labels Nov 2, 2021
@wookash
Copy link
Author

wookash commented Nov 2, 2021

Cool. Yup i did both point 1 and 2

@waydabber
Copy link
Owner

waydabber commented Nov 2, 2021

Ok. Point 2 is actually unnecessary if you do point 1, but the main thing is that it works now for you (I meant them to try out in this sequence :)).

@wookash
Copy link
Author

wookash commented Nov 2, 2021

Got it. I was being lazy :-p

@wookash
Copy link
Author

wookash commented Nov 5, 2021

report after a few days - app is working mostly fine in my home scenario - plugged in to external monitor, sleeping/waking works fine.

However, I recently had to travel and then reboot macbook, then I was presented a screen with wallpaper and nothing on it after login - the dumy did not get disconnected it was still mirroring to the device that wasnt there and was set up as main monitor apparently.. is there any chance to set up built in monitor as main while external monitor is not plugged in? shall I create a new issue?

@waydabber
Copy link
Owner

I plan to support the association of dummies with displays so the dummy gets disconnected/connected automatically when needed (the associated display is present). That should hopefully solve this and similar issues.

@wookash
Copy link
Author

wookash commented Nov 5, 2021

it would be great, I had to enter safe mode and remove app for now. Could not find a folder where it is added as a startup item

@waydabber
Copy link
Owner

I consolidated the sleep issues into a single issue: #76. Let's continue the discussion under the new issue. Thank you!

@waydabber waydabber added done All tasks are completed and removed in progress Implementing labels Nov 6, 2021
@wookash
Copy link
Author

wookash commented Nov 6, 2021

Sure and thank you for all the work!

@waydabber waydabber added the released Released label Feb 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
done All tasks are completed enhancement New feature or request released Released
Projects
None yet
Development

No branches or pull requests

2 participants