We have a push-to-talk client, Part of Push APNS, app never received the BG task expiry.
Correct. From a relatively brief look at the log, it appears that your app has an active Audio Session, which is what's keeping it awake:
2024-09-03 16:18:47.352+0530 [as_client] AVAudioSession_iOS.mm:2654 Activated session 0x6800c
That active audio session is keeping your app awake, which also means background tasks don't expire.
You can actually see this dynamic play out in your own logging :
2024-09-03 16:18:53.970+0530 ...requestBackgroundTask_block_invoke_2 After 10sec Start Remaining BG time: <GIANT NUMBER>
The giant number I left out is "infinity", meaning the assertion (from the audio system) keeping your app awake does not have a fixed expiration time.
Note on this point:
The client allowed BG time more than 30 seconds and looks client has been suspended but Never received a BG task expiration handler from OS
The systems "default" expiration is 30s, but that doesn't mean your tasks will actually expire in 30s. That's what will happen assuming nothing else changes before the task expires. As the simplest example of this, if your foreground your app before the task expires then the task will expire.
Note that this also works in "reverse"- if you start a background task while your in the audio session is active, the system does NOT guarantee that you'll get 30s past the creation time. If you're audio session deactivates before 30s, you'll get much less time than that. Quoting "UIApplication Background Task Notes":
IMPORTANT The value returned by backgroundTimeRemaining is an estimate and can change at any time. You must design your app to function correctly regardless of the value returned. It’s reasonable to use this property for debugging but we strongly recommend that you avoid using as part of your app’s logic.
IMPORTANT Basing app behaviour on the value returned by backgroundTimeRemaining is the number two cause of background task problems on iOS.
__
Kevin Elliott
DTS Engineer, CoreOS/Hardware