WatchFlower icon indicating copy to clipboard operation
WatchFlower copied to clipboard

Bluetooth disabled notification after allowing bluetooth access M1 macOS 12.4

Open lesleyblankendal opened this issue 2 years ago • 18 comments

Describe the bug Bluetooth disabled notification after allowing bluetooth acces macOS 12.4. When the app launches I give it permission but all devices show as offline with a notification that my bluetooth is disabled. Also granted additional access in privacy & settings > bluetooth, to see if that makes any difference.

iPad version that can be run from Mac App Store on M1 iMac doesn't have this issue

Expected behavior Sensors show as online

To Reproduce Steps to reproduce the behavior:

  1. Open app on macOS
  2. grant bluetooth access
  3. Go to Home Screen
  4. See error

Screenshots Schermafbeelding 2022-06-29 om 16 18 29

Your environment Please describe the environment you are using:

  1. macOS 12.4, iMac 24 inch late 2020
  2. downloaded 4.1 update just now to see if it was fixed. Bug was introduced in 4.0
  3. 4.1

lesleyblankendal avatar Jun 29 '22 14:06 lesleyblankendal

Yes the Bluetooth and permission detection can be a little shaky on macOS, but that's usually not that problematic. I'll see if I can fix that once and for... well until next time it break anyway...

emericg avatar Jun 30 '22 17:06 emericg

I'm seeing this one too, though it works if the binary is launched from a terminal rather than through finder which is certainly strange.

steveatinfincia avatar Aug 02 '22 17:08 steveatinfincia

I also see it on an M1

jeeftor avatar Dec 14 '22 16:12 jeeftor

This app has crashed because it attempted to access privacy-sensitive data without a usage description. The app's Info.plist must contain an NSBluetoothAlwaysUsageDescription key with a string value explaining to the user how the app uses this data.

I got this error when I ran it from CLI

jeeftor avatar Dec 14 '22 16:12 jeeftor

Sounds like a .plist issue...

jeeftor avatar Dec 14 '22 16:12 jeeftor

image

But it looks like you have the plist stuff...

jeeftor avatar Dec 14 '22 16:12 jeeftor

Indeed. Can you try with a more recent build? https://github.com/emericg/WatchFlower/actions/runs/3660319742

It has both improvements and newer Qt version, maybe that will help.

emericg avatar Dec 14 '22 16:12 emericg

Still having this issue with version 5 on Mac OS 13.2.1. Also tried a recent build with no luck.

fabiang avatar Apr 16 '23 21:04 fabiang

Yes I'm really sorry, this problem has proven difficult to understand and to solve... But I haven't forgotten it. It's just that I failed every time I had a look at it (last time being tonight :)

emericg avatar Apr 20 '23 18:04 emericg

I've also spent an hour trying to find the error. Imho this must be an upstream bug in Qt and/or OS X?

// Edit: Imho either the .entitlements is not applied correctly when the app is build for OS X and/or bluetooth access is only possible when the app correctly signed (and its a bug for untrusted apps).

fabiang avatar Apr 20 '23 19:04 fabiang

Imho this must be an upstream bug in Qt and/or OS X?

Yes Qt doesn't have a great integration of the "new" Bluetooth permission for macOS. That permission appeared recently, and it was working better before, that is a fact. I had high hopes for the new permission system of Qt 6.5, but so far not much luck with it.

the .entitlements is not applied correctly when the app is build for OS X

There were even weirder cases before, like the app run through Qt Creator, run with a terminal or launched through the icon not behaving the same. But now on my mac it is working, I don't have the permission issue anymore. It is working poorly though, it needs time to bring up the permission popup and after granting the permission it takes time to start working.

bluetooth access is only possible when the app correctly signed (and its a bug for untrusted apps).

That is definitely an issue. I think the app cannot save the permission if not signed, and so every time you launch the app it will ask for it again, and exhibit this issue. It cannot just launch with a permission granted and run like it was running before the permission issue.

emericg avatar Apr 21 '23 10:04 emericg

I think I figured it out. On my local install, I've just added this to my Info.plist:

<key>UIBackgroundModes</key>
<array>
   <string>bluetooth-central</string>
</array>

bluetooth-peripheral seems to work too as a value for this setting. According to this bluetooth-centralis the correct value: https://docs.silabs.com/bluetooth/3.1/general/connections/central-and-peripheral-roles#:~:text=In%20the%20BLE%20world%2C%20the,incoming%20connection%20request%20after%20advertising

Someone able to confirm this? Have it from here: https://stackoverflow.com/a/48390949 Possible value are here: https://developer.apple.com/documentation/bundleresources/information_property_list/uibackgroundmodes

fabiang avatar Dec 03 '23 02:12 fabiang

That's interesting, but it is said that UIBackgroundModes is only for iOS, and that using it prevents you from being accepted on the app store. Weird option...

I'll test this on a mac but yes we'll need people to confirm this has an actual impact beyond placebo.

emericg avatar Dec 04 '23 16:12 emericg

@emericg I've just checked if this automatically prevents you from being accepted to the Appstore and that should only be the case if your App doesn't use Bluetooth (or an Apple employee doesn't understand that is does). And from what I've read this values is definitely needed for Bluetooth to function. I've now working the fifth day with this option.

fabiang avatar Dec 07 '23 00:12 fabiang

It made zero difference in my testing, and the doc still says for iOS only. But truth be told I don't really care enough to go against this, so I've added this line to the plist, we'll see if anyone report an actual difference in behavior...

emericg avatar Dec 16 '23 17:12 emericg

Tested once again with build 7233199927 and can confirm it's working.

fabiang avatar Dec 23 '23 12:12 fabiang

I have the same issue with the last build (https://github.com/emericg/WatchFlower/actions/runs/7233199927) Capture d’écran 2024-01-03 à 14 34 07 Capture d’écran 2024-01-03 à 14 34 28

NathanBnm avatar Jan 03 '24 13:01 NathanBnm

I removed the permission manually and now I'm unable to get it working again. Very weird.

fabiang avatar Jan 03 '24 17:01 fabiang