Skip to content

Expected behavior of BT in background #54

Open

Description

@dennislysenko

Hi @mickeyl, first off, thanks for helping to troubleshoot the other issue I had recently.

I was curious what the expected behavior is of BT when going into the background. I have this app using LTSupportAutomotive, that runs a web server in the background using the silent audio trick exposing OBD readings that are polled every 0.3s (we're just running it via Testflight, it doesn't need to pass app review).

Project: https://github.com/dennislysenko/OBD2Loxone

image

We have all these background modes selected. However when going to background, the web server keeps running for hours (indicating that the app is still awake, as intended), but the BT connection seems to go down.

Do you know what the expected behavior is of BLE under these conditions, when the app is running in the background (not getting killed)? I did a quick search for any UIApplicationDidEnterBackground etc. in the LTSupportAutomotive repo, and didn't find any reason to think the library would switch off BT connections when backgrounding.

Activity

  1. mickeyl commented on Apr 5, 2024

    @mickeyl
    Owner

    This is a very interesting question. I still don't have the final verdict and need to carry out more tests, but it seems there are a whole lot of factors involved:

    • Operating system version and device grade (pro or not).
    • Whether you are a TestFlight/AppStore app or not.
    • Whether the Xcode debugger is connected to the device.
    • Whether power saving mode is enabled.
    • Whether actual BLE traffic is happening or not.
    • Whether you have an Apple Watch (or auxiliary BLE devices, such as pacemakers, fitness equipment, etc.) connected.
    • What kind of operations are carried out in the foreground app.

    In one of my production apps, I'm using BLE via L2CAP COC. This app has only [x] Uses Bluetooth LE accessories enabled and survives 27 seconds in background, before the app is killed. The L2CAP connection holds for so long, but (naturally) gets closed when the app is killed.

    Let me do the silent audio trick next week and check whether I can get the L2CAP connection to hold any longer.
    I'm also not sure whether L2CAP COC has any other runtime characteristics than the standard BLE connectivity.

    Like I said, this is a complex, but very interesting topic and authoritative or definite information are little. Perhaps we can work together here, sharing our experiences.

  2. mlawlerau commented on Jun 13, 2024

    @mlawlerau

    I have had my app run for much longer than 30s in background, but I dont think it has lasted longer than 30m. I will need mine to run for hours in the background. I am interested in this topic.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions