Open mkozjak opened 1 year ago
Seems like this is somehow connected to this part of the code. I guess we're not getting an up-to-date information from the OS.
I tried running Is Dark Mode On preventively at the top of my shortcut in order to try refreshing the state but it didn’t help.
I’ve been having the exact same issue I reported as part of this issue: https://github.com/sindresorhus/Actions/issues/180#issue-1966704683
I did briefly describe a workaround that I’ve done for it, at least for the menus. I’ve encountered it in other shortcuts too though which has been annoying. Last I heard the dev wasn’t able to reproduce the issue though unfortunately.. maybe we can help him pinpoint it
Yes, I tried applying your workarounds also, @rastafaa, but ultimately the Shortcut started crashing so it's not a solution, unfortunately. :/
I actually read the rest of your post now and yeah we both had the same problem of using it to create menu colors, and yeah after first trying the same things you did I did end up finding a workaround that does resolve it. Would be nice to have the bug fixed either way of course
Yes, I tried applying your workarounds also, @rastafaa, but ultimately the Shortcut started crashing so it's not a solution, unfortunately. :/
Oh really.. well in that issue I also came up with a way to prevent the crashing (add a 50ms wait before the first menu action)
it hasn’t crashed since then (it’s been several days)
Gonna try one more time... Thanks!
I see his code comment seems to basically describe the issue, but his solution maybe didn’t fully resolve it. The fact that it’s force-quitting the app probably also explains why my workaround works and also why it crashes.. if it restarts the shortcut before the app has a chance to reload that probably causes it to fail. And also makes sense why adding a short wait resolves the crashing.
“ // iOS does not update the trait collection of apps/extensions that are running in the background, which we are. iOS sometimes reuses the app/extension when running a shortcut a second time, which means it would show outdated values if the dark mode state changed in the meantime. We ensure it always gets a fresh instance by force-quitting the app. Force-quitting the extension made it hang, so it's also important that it's an in-app intent.”
fyi, depending on your device you might need a longer wait.. I’m on 15 pro. So if you have a slower model it might need more time (try 100ms maybe)
Same issue goes for Is Silent Mode On
... 😔
@rastafaa To be honest, your shortcut with the repeat/wait timeout isn't trivial so I don't know how I could apply it to mine.
@rastafaa To be honest, your shortcut with the repeat/wait timeout isn't trivial so I don't know how I could apply it to mine.
Here’s a current version of shortcut that activates the dark mode workaround (about midway down) https://www.icloud.com/shortcuts/f5d72357fc6b4e64b91369b75a5d0359
And the actions in that menu: https://www.icloud.com/shortcuts/3ac060e137c8495c93ddde74a5811d6e
And it turns out I put the crash avoider delay into this shortcut: (which is called in the previous shortcut and is what was crashing) https://www.icloud.com/shortcuts/f4770892dd9a4f16b7263c17ad70e6f9
But if it’s too confusing just send a link of yours with the issues and I can try getting it working for you
But if it’s too confusing just send a link of yours with the issues and I can try getting it working for you
It's in the first post. Thanks!!
But if it’s too confusing just send a link of yours with the issues and I can try getting it working for you
It's in the first post. Thanks!!
Hey I added it to your shortcut, fyi you built it a bit different than me. For changing the menu icon colors I just made a variable that changes white or black depending on appearance value, and then passing that variable to the menu action.. this way you don’t need to duplicate all those actions just to change the color. Suggest trying that in future.
Anyway here’s your shortcut with workaround applied, I didn’t change anything in it except adding my fix and it’s working for me. I did have to move the dark detector to the top to prevent your lock-based items from running twice.
BASE SHORTCUT: https://www.icloud.com/shortcuts/42e723a092064e1986880dc1de6d547a
SHORTCUT RUNNER: https://www.icloud.com/shortcuts/6b0c40ff1399468fa2cbb3dc05234dc6
You’ll need to add both of these. The first one replaces the one you currently have. The second one is what you’ll actually use to run the first shortcut. If you run the second on its own it won’t do anything.
Also I just realized I think you pass input to this shortcut? That’ll probably cause issues with the workaround so you might need to change it a bit but at least you can see now how it works.
Also I just realized I think you pass input to this shortcut? That’ll probably cause issues with the workaround so you might need to change it a bit but at least you can see now how it works.
Nope. No inputs.
Thanks for the patch! TBH, I find writing code in Shortcuts so damn hard that I decided not to refactor it so I left duplications lingering there.
@sindresorhus should I try the latest TestFlight release?
You can try. I have tried some workaround, but unsure if they actually help.
You can try. I have tried some workaround, but unsure if they actually help.
Reverted. There was a bunch of actions missing. For Example, Is Dark Mode On
doesn't seem to be available with it. Same for Is Silent Mode On?
.
@mkozjak You have to restart your device after, because of a Shortcuts bug.
The restart didn't help. :/
Those actions are in the list, though.
@mkozjak Sorry. There was a bug in the that update that made some actions not work. The latest TestFlight build (55) should correct it.
@sindresorhus Ok, this one works. Still the same behaviour in regards to this issue, though, unfortunately.
@sindresorhus Any chances this might get fixed with some new update? Thanks!
@mkozjak The issue is an iOS bug, so it has to be fixed in an iOS update, not an Actions update.
I have not found a workaround, but the code is open-source, so anyone is free to submit a pull request if they manage to find a workaround.
I haven't had the issue since november using my own workarounds.. sorry it didn't work out for you not sure why
@rastafaa sorry, you are using the latest testflight release with your workaround?
I haven't updated actually because the last time I tried the newer version it ran slower.. so I've been afraid to update lol (can't easily downgrade from an official version without jailbreak)
The recent updates completely broke it for me.. it crashes every time dark mode action is ran
I tried beta update because it mentioned bug fixes but now I’m stuck on a version that has broken a lot of my shortcuts :(
edit: got it working again with a delay but things are definitely slower than the older versions
Description
I have an action that I shared here that checks whether Dark Mode is enabled before creating a menu for my Action Button. The first time I run the shortcut after the Dark Mode toggles (either manually or automatically), Is Dark Mode On returns false when dark mode is on and true when it’s off (the opposite of what it should actually be). It is super-simple to reproduce this behavior. Just toggle Dark Mode manually and run the provided shortcut. My menu items will be painted with wrong colors.
It feels like something isn’t refreshing the state that is used by the Is Dark Mode On and is only refreshed after the first time it was queried. Maybe this doesn’t make sense, thought. I have tried running Is Dark Mode On two times in order to try triggering the change and putting Wait after checking the Boolean, but it didn’t help.
Thanks for this great project!
macOS/iOS version
iOS 17.1
Shortcut URL
https://www.icloud.com/shortcuts/6c69d48f302a40e78b6229f86eb86977