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

SoundSeer stops functioning when Mac awakes from sleep #37

Open
podpah opened this issue May 15, 2024 · 14 comments
Open

SoundSeer stops functioning when Mac awakes from sleep #37

podpah opened this issue May 15, 2024 · 14 comments
Labels
bug Something isn't working

Comments

@podpah
Copy link

podpah commented May 15, 2024

Version

SoundSeer - v1.1.1
macOS - Sonoma 14.4.1
M1 Chip

Issue

After the Mac goes to sleep, the icon stops updating and becomes an ear. The error shown is:
Not enough room for song. Try restarting
But when I restart it shows the song properly. This issue only occurs after the Mac has been sleeping
image
It is fixed when you restart the app, but since it happens every time the Mac goes to sleep...

@jonathangarelick jonathangarelick added the bug Something isn't working label May 15, 2024
@jonathangarelick
Copy link
Owner

Hi there, thank you for using SoundSeer and for reporting this issue. Right now I am unable to replicate this. A couple questions:

  • Are you using the version downloaded from the App Store?
  • How much room is there between your menu bar icons and the physical "notch" ? It's hard to tell based on the image.

@podpah
Copy link
Author

podpah commented May 15, 2024

1 - I built from source
2 - I use it on a large monitor so there's no notch as my Mac stays closed (if I understand correctly and you're asking about the camera notch). I've tried with just the Mac and in that case the ear doesn't show up - if the right bar doesn't have enough space, SoundSeer isn't seen at all.

@jonathangarelick
Copy link
Owner

I see, thank you. In that case, it seems that there are too many menu bar icons. Unfortunately, Apple doesn't give me much leverage in this case--the operating system will kick icons off the menu bar and I am unable to control that. (If I remember correctly, it kicks off older ones first.)

Right now, I think the best I can do is what you're seeing--minimize the app to just a small icon to display a warning message. If you have any other suggestions though, I am happy to hear them.

@podpah
Copy link
Author

podpah commented May 15, 2024

I just did some testing around with it - it indeed is because there's too many menu bar icons for the laptop screen, even though I'm on just the display and it has more than enough space for it as it displays just fine with a ton of icons on display.

On ideas - I'm not sure how it works but going off the error message and the fact it asks to restart because of the lack of space, maybe when it's on lack of space every 10/15s or so try and calculate the space again? Since it only happens with the larger display I'm guessing the calculation is based on the laptop screen when restarting before it loads on display and then gives up once it fails

@jonathangarelick
Copy link
Owner

jonathangarelick commented May 15, 2024

Oh, I see. You're opening SoundSeer when the laptop is the main display, then you switch over to your monitor?

It'll be a bit tricky, but what I can do is add a button to the menu to manually recalculate width. The issue is that I can only determine the max width when SoundSeer disappears, so if I run it at an interval, it will create a flashing animation when it disappears and appears again.

@podpah
Copy link
Author

podpah commented May 16, 2024

No, I never open the laptop. But since the problem is because there's no space on the laptop screen and it gets triggered on the display, I'm assuming when the Mac is waking up, the calculation gets done with the laptop display (even though it's not in use) before it loads on the display

@jonathangarelick
Copy link
Owner

Okay. Honestly, I'm not really sure how to address that. However, you can make the following change to SoundSeerApp.swift, which should solve the problem for now:

if spotifyViewModel.playerState == .playing, spotifyViewModel.prefixLength <= 0 {
    Button("Not enough room for song. Try restarting.", systemImage: "exclamationmark.triangle", action: {})
        .labelStyle(.titleAndIcon)
        .disabled(true)

    // START CODE
    Button("Reset Width", systemImage: "arrow.left.and.line.vertical.and.arrow.right") {
        spotifyViewModel.prefixLength = 45
    }
    .labelStyle(.titleAndIcon)

    Divider()
    // END CODE
}

Apple is giving me a hard time about Apple Music integration right now, so updates are coming out a little bit slowly. I will try to package this with the v1.2.0 release, which should go out within a week or two.

@jonathangarelick
Copy link
Owner

Added to main: dc82f08

@podpah
Copy link
Author

podpah commented May 17, 2024

The button worked once and then it stopped showing up even after restarting app/rebuilding (not sure if this is intended as I don't have experience with Swift Apps but it looks like the setting persisted) - it does partially work as a solution, but ends up being shortened on larger songs. Basing it on song length as it does normally might be a better setting than the fixed 45?
image

@jonathangarelick
Copy link
Owner

Right, I should clarify this behavior. The "Reset Width" button will only appear when there's no room in the menu bar (i.e., when a song is playing and the ear icon is shown).

You are welcome to change the prefix length to something larger like 60, of course. I tried not to make it too large in order to be a good "neighbor" to other apps that have a menu bar presence.

@jonathangarelick
Copy link
Owner

Oh, I'm looking at your original comment in my emails. Yes, I can now see why it would be useful to permanently display an option to reset the width.

@podpah
Copy link
Author

podpah commented May 17, 2024

Right, I should clarify this behavior. The "Reset Width" button will only appear when there's no room in the menu bar (i.e., when a song is playing and the ear icon is shown).

On this I meant that there was persistence with the setting through runs. After I clicked it the first time even after restarting the app/rebuilding it would act as the spotifyViewModel.prefixLength = 45 when I woke the Mac and reduce the size but not change to the ear (I might be going crazy)

And on this one:

You are welcome to change the prefix length to something larger like 60, of course. I tried not to make it too large in order to be a good "neighbor" to other apps that have a menu bar presence.

I was under the impression that even though the length is set to something, if the title is smaller it'll automatically shrink? So when I was playing a song with a short title, when I clicked it, it seemed to shrink? I can get pictures on Monday to clarify what I mean, so I don't think making it large would be unneighbourly

@jonathangarelick
Copy link
Owner

I'm not entirely sure I understand your comment about persistence--how it works right now is that every time the app starts, the maximum text length is set to 45. If the app detects that it disappeared, it will gradually shrink itself until it either hits zero (ear icon) or appears again. Then it will never expand again until either (1) you use the button I posted, or (2) you restart the app.

I'm looking at your image ("I Smoked Away My Brain" song) and it's definitely not 45 characters long. What probably happened is that some external display weirdness caused it to shrink.

if the title is smaller it'll automatically shrink?

As it's implemented now, it should only shrink when there's not enough room. prefixLength is not dependent on the song name itself.

You can make the "Reset Width" button permanently visible by taking it out of the if statement. Right now I am working through a refactor and I plan to permanently have a Reset Width button available just in case.

@jonathangarelick
Copy link
Owner

Oh, and I will also note that the app always removes everything after the parentheses in the song name.

So, My Song (feat. Some Other Artist) - My Artist becomes My Song - My Artist.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants