bluetoothd kills my app bluetooth communication even when app is in foreground

)Hi,

I am developing an react-native app which uses bluetooth. But I see the iOS is killing my bluetooth-central intermittently.

And also my central does not receive disconnect delegate.

I am seeing power assertions from system.But thats the problem with react-native.It consumes significant power at the launch time.

I want to know if something can be done to maintain the bluetooth connection.My app (myBtApp) has enabled "bluetooth-central" in background mode.

I am attaching the console log for reference.




Mar 26 18:52:01 iPhone assertiond[67] <Notice>: [myBtApp:585] Setting up BG permission check timer for 180s

Mar 26 18:52:01 iPhone assertiond[67] <Notice>: [myBtApp:585] New process assertion state; preventSuspend, preventIdleSleep, preventSuspendOnSleep (assertion 0x10072dda0 added: (none); removed: preventThrottleDownUI, preventThrottleDownCPU)

Mar 26 18:52:01 iPhone Amazon[586] <Notice>: +[AIDelegateHelper callSelector:onDelegate:withObjects:] Calling delegate method recordMetric:withValue:withSource:isHighPriority:

Mar 26 18:52:01 iPhone Amazon[586] <Notice>: +[AIMAPiOSLib getAccountWithError:] getAccount API Called

Mar 26 18:52:01 iPhone Amazon[586] <Notice>: +[AIDelegateHelper callSelector:onDelegate:withObjects:] Calling delegate method recordMetric:withValue:withSource:isHighPriority:

Mar 26 18:52:01 iPhone Amazon[586] <Notice>: +[AITokenManager retrieveBlobWithKey:checkUpgrade:error:] Retrieved blob from storage

Mar 26 18:52:01 iPhone assertiond[67] <Notice>: [myBtApp:585] dump all assertions HWM:5 (CPUMON check): {

<BKProcessAssertion: 0x10086b750; "_UIRemoteKeyboard XPC disconnection" (finishTask:180s); id:\M-b\M^@\M-&6DD310F6A3EA> [active]

}

Mar 26 18:52:01 iPhone assertiond[67] <Notice>: [myBtApp:585] setpriority success for resource GPU to PRIO_DARWIN_GPU_DENY

Mar 26 18:52:01 iPhone assertiond[67] <Notice>: [myBtApp:585] setpriority success for resource CPU to PRIO_DARWIN_BG

Mar 26 18:52:01 iPhone assertiond[67] <Notice>: Updating PowerAssertion on myBtApp:585

Mar 26 18:52:01 iPhone assertiond[67] <Notice>: [myBtApp:585] Remove assertion: <BKProcessAssertion: 0x10072dda0; "FBSceneSnapshotAction:com.mydomain.myBtApp-stg" (finishTask:180s); id:\M-b\M^@\M-&EDF89AC45333>

Mar 26 18:52:01 iPhone Amazon[586] <Notice>: +[AIDelegateHelper callSelector:onDelegate:withObjects:] Calling delegate method recordMetric:withValue:withSource:isHighPriority:

Mar 26 18:52:01 iPhone Amazon[586] <Notice>: +[AIDelegateHelper callSelector:onDelegate:withObjects:] Calling delegate method recordMetric:withValue:withSource:isHighPriority:

Mar 26 18:52:01 iPhone assertiond[67] <Notice>: [myBtApp:585] Setting up BG permission check timer for 180s

Mar 26 18:52:01 iPhone assertiond[67] <Notice>: [myBtApp:585] dump all assertions HWM:5 (CPUMON check): {

<BKProcessAssertion: 0x10086b750; "_UIRemoteKeyboard XPC disconnection" (finishTask:180s); id:\M-b\M^@\M-&6DD310F6A3EA> [active]

}

Mar 26 18:52:01 iPhone assertiond[67] <Notice>: Updating PowerAssertion on myBtApp:585

Mar 26 18:52:01 iPhone assertiond[67] <Notice>: [myBtApp:585] Deactivate assertion: <BKProcessAssertion: 0x10086b750; "_UIRemoteKeyboard XPC disconnection" (finishTask:180s); id:\M-b\M^@\M-&6DD310F6A3EA>

Mar 26 18:52:01 iPhone assertiond[67] <Notice>: [myBtApp:585] no more active assertions, resetting _timedAssertionPermittedDuration, _timedAssertionReferenceTime, _timedAssertionDeadlineActive: NO

Mar 26 18:52:01 iPhone assertiond[67] <Notice>: [myBtApp:585] New process assertion state; (none) (assertion 0x10086b750 added: (none); removed: preventSuspend, preventIdleSleep, preventSuspendOnSleep)

Mar 26 18:52:01 iPhone assertiond[67] <Notice>: [myBtApp:585] suspend success

Mar 26 18:52:01 iPhone assertiond[67] <Notice>: [myBtApp:585] Setting jetsam priority to 0 [0]

Mar 26 18:52:01 iPhone assertiond[67] <Notice>: [myBtApp:585] pid_shutdown_sockets(1) success

Mar 26 18:52:01 iPhone assertiond[67] <Notice>: Releasing PowerAssertion on myBtApp:585 from update

Mar 26 18:52:01 iPhone assertiond[67] <Notice>: [myBtApp:585] Remove assertion: <BKProcessAssertion: 0x10086b750; "_UIRemoteKeyboard XPC disconnection" (finishTask:180s); id:\M-b\M^@\M-&6DD310F6A3EA>

Mar 26 18:52:01 iPhone assertiond[67] <Notice>: -[BKAssertion dealloc] - <0x10072de10>

Mar 26 18:52:01 iPhone assertiond[67] <Notice>: -[BKAssertion dealloc] - <0x100864420>

Mar 26 18:52:01 iPhone assertiond[67] <Notice>: -[BKAssertion dealloc] - <0x10072dda0>

Mar 26 18:52:01 iPhone assertiond[67] <Notice>: -[BKAssertion dealloc] - <0x10086b750>

Mar 26 18:52:01 iPhone Amazon[586] <Notice>: +[AITokenManager retrieveBlobWithKey:checkUpgrade:error:] Retrieved blob from storage

Mar 26 18:52:01 iPhone Amazon[586] <Notice>: +[AIDelegateHelper callSelector:onDelegate:withObjects:] Calling delegate method recordMetric:withValue:withSource:isHighPriority:

Mar 26 18:52:01 iPhone SpringBoard[56] <Notice>: Application process state changed for com.mydomain.myBtApp-stg: <SBApplicationProcessState: 0x1334ed1f0; pid: 585; taskState: Suspended; visibility: Background>

Mar 26 18:52:01 iPhone SpringBoard(WiFiPicker)[56] <Notice>: WIFI PICKER [com.mydomain.myBtApp-stg]: isProcessLaunch: 0, isForegroundActivation: 0, isForegroundDeactivation: 0

Mar 26 18:52:01 iPhone CommCenter[81] <Notice>: #I BundleID: <private> is no longer a foreground app

Mar 26 18:52:01 iPhone bluetoothd[79] <Notice>: State of application "com.mydomain.myBtApp-stg" is now "suspended"

Mar 26 18:52:01 iPhone IDSRemoteURLConnectionAgent[446] <Notice>: => Pid 585 suspended!

Mar 26 18:52:01 iPhone IDSRemoteURLConnectionAgent[446] <Notice>: PID: 585 was suspended

Replies

Not sure what you mean with that your bluetooth-central gets killed? Did you mean your app gets suspended?


As you say you have background mode enabled and so it should receive disconnect events when in background. Such event will wake up the app and let it run for up to 10 secs. And then app will get suspended again. So external events from your peripheral should always wake up your app. This could for example also be notifcations from your peripheral.


Cheers! 🙂

Hi, Thanks for reply.

The log (bluetoothd[79] <Notice>: State of application "com.mydomain.myBtApp-stg" is now "suspended"). says the app is suspended by bluetoothd, but my app is active.Only thing is my bluetooth communication with peripheral is broken.I am not able to communicate with my peripheral. And also there is no disconnect event coming to the app or to the peripheral.