Floating menu script not always updating and getting stuck. Restarting BTT fixes.

Describe the bug

Floating menu script not always updating and getting stuck. Not sure if bug, or else is there a way to force an update?

I have a floating menu behind the Notch that uses Applescripts to launch and play Spotify if it is not already running, and if it is already running, to press play if it is paused, or pause if it is currently playing. There is also a Menu Item that gets the current artist and track name from Spotify and returns it. This menu item runs every 1.25 seconds (I changed it from 1 to 1.25 as part of my debugging).

My bug is that the Menu Item showing the track does not always update, and can get stuck on either a previous track, or returning the other outputs, such as "Spotify is Paused". I can't find a way of fixing it when it gets stuck except for restarting BTT. I don't know what causes it to get stuck, it just happens seemingly randomly. Happy to upload the preset if it helps. Thanks.

**Affected input device: Floating Menu

  • Type of Mac: MacBook Air M2
  • macOS version: macOS Sonoma 14.5
  • BetterTouchTool version: 4.583

Uploading the preset is a good idea. (or send to andreas@folivora.ai)
A general tip: potentially wrap your script in try catch blocks, to catch any errors that might happen

    #your script
 on error errStr number errorNumber
    # something  in case of error
end try

Spotify_NotchMenu.bttpreset (63.5 KB)

Here you go :slight_smile: thanks for such a speedy reply!

Unfortunately I need to leave now, will look into your preset later today!

No problem! Look forward to hearing back from you later.

As a quick off-topic aside (but adjacent to this preset), when using an icon from the disk for a menu item, does it get stored internally to BTT and so I can remove it from its location after choosing it as an icon, or does BTT always look up the original location of the icon?

Unless you explicitly select this option:

It should be copied to the preset's data folder:

Ah but I'm using the Icon section further down, not the Image in the Background section, as I want the Menu Item to look like a button and change colour when I hover over it. If I use the Icon as the background, then it doesn't highlight when I hover over it.

Icons should always be copied!

Did you manage to get a chance to check why the menu item is repeatedly getting stuck with this script?

Unfortunately not, I had it running for like 1-2 hours but it didn't get stuck here. How fast / often does this happen for you?

Oh, weird. I'd say pretty consistently after an hour or so of use. When you tested it were you actively using it to pause/play Spotify and checking it had updated after tracks move on?

Could you try closing and quitting Spotify and restarting it few times to see if that's what causes it. It's been difficult for me to pin-down an exact cause - mostly I just notice it gets stuck after a while.

But just now it's stuck again, and the only thing I can say with confidence is that earlier it was working, I have since quit Spotify, and now when restarting it it's stuck again, so perhaps it has something to do with that?

Also, just to be clear, it's only the returned text of the Menu Item showing the currently playing artist and track name that is getting stuck. The function of the actions that are triggered by clicking on the all menu items continue to work as scripted.

I'll try!

I was indeed just able to reproduce it, and luckily had the debugger attached. I might have found what the issue is but I'm not 100% sure.

I'll upload a new alpha version (4.588 ), would be great if you'd test that.

Hi Andreas. Thanks for the debugging. Downloaded the 4.588 alpha. Initially thought it seemed better at keeping and staying updated, but it's just gotten stuck again. I'm struggling to figure how to reproduce it consistently. It feels pretty random to me.

Strange, I have it running successfuly since 2 hours so far :wink: Will debug again once it gets stuck again (the script itself seems to run fine, it's updating the text that gets stuck)

Hi Andreas. I haven't seen this happen again under 4.589, so I'm hoping you have indeed managed to fix it :crossed_fingers: :smile:

I'll keep an eye out, but for the meantime, seems good. Thanks for all your amazing work and prompt support and replies.

I think it's not fixed in 4.589 but I have found the issue and it should be fixed in 4.590 later!

1 Like

Unfortunately it's not yet fixed.

I know why it's happening but haven't figured out what leads to this situation. It's basically "just" a rendering problem, the script is running fine. Will continue to investigate tomorrow.

I'm running a similar preset and have done a ton of debugging so this may be helpful. (My preset only shows the artwork, title and song in the notch but as a floating menu). I'm not a developer but will try my best.

Essentially mine always gets in the paused state (no art/title/artist) when BTTInitialize() is called. The workaround I have is I re-enable the Notch Bar (Toggle BTT Notch Bar Visible/Hidden).

This allows these User Script temporary variables to appear and be available (confirmed via a comparison within BTT Settings):

  • BTTCurrentlyPlaying
  • BTTNowPlayingInfoArtist
  • BTTNowPlayingInfoTitle
  • BTTNowPlayingInfoAlbum

For some reason, they are not available if the notch is disabled but they are available if the notch bar is enabled.

Script I am using:

    if(data.note == 'BTTNowPlayingInfoChanged') {
        let currentlyPlayingSong = await get_string_variable({variable_name: 'BTTNowPlayingInfoTitle'});
        let currentlyPlayingArtist = await get_string_variable({variable_name: 'BTTNowPlayingInfoArtist'});

        let currentlyPlayingStatus = await get_string_variable({variable_name: 'BTTCurrentlyPlaying'});