Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Screen Broadcast Stops Unexpectedly After short time when app is in background #510

Open
creativecbr opened this issue Nov 15, 2024 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@creativecbr
Copy link
Contributor

creativecbr commented Nov 15, 2024

Describe the bug

The screen broadcasting session on iOS/iPadOS automatically stops after short time (from 30 seconds to 5 minutes) after moving main app to background. This issue is consistently reproducible in production environments. When running the app with an attached debugger, the broadcast session does not stop, but it repeatedly logs an error in Console.app:

Error acquiring assertion: <Error Domain=RBSAssertionErrorDomain Code=2 "Assertion's invalidation time is in the past" UserInfo={IgnoreOnReconnect=true, NSLocalizedFailureReason=Assertion's invalidation time is in the past}>

In the production build, the broadcasting stops automatically when this error occurs. The issue seems unrelated to the LiveKit SDK version, as it persists across versions 2.0.4, 2.0.15, and 2.0.17. Previously, the broadcasting feature worked correctly without this problem what is weird. Moreover, when the session is running while the main app is in the foreground, it can continue working all day without interruption.

SDK Version

  • LiveKit SDK versions tested: 2.0.4, 2.0.15, 2.0.17

iOS Version

  • Occurs on iOS 15.4, 18.1.

Xcode Version

  • Tested on Xcode 16.0 (16A242d)

Steps to Reproduce

0a. Launch app without debbuger connected.
0b. When running with an attached debugger, observe the error logs in Console.app.

  1. Connect to the LiveKit room.
  2. Start a screen broadcast session using the iOS Broadcast Extension with the LiveKit SDK.
  3. Send app to background by e.g. going to Safari app
  4. Observe the behavior for 30 seconds - 5 minutes.
    5a. The broadcast stops automatically.
    5b. Error in Console.app occurs as in Logs section, stream is continued.

Expected Behavior

The screen broadcast session should continue without interruption, as it did in previous SDK and iOS versions, without stopping after short time.

Screenshots

Project settings:
Screenshot 2024-11-15 at 15 33 28

Logs

Full file: Logs.txt

Sample logs from Console.app which are suspicious:

error	20:20:39.068298+0100	MyApp	Er
ror acquiring assertion: <Error Domain=RBSAssertionErrorDomain Code=2 "Assertion's invalidation time is in the past" UserInfo={IgnoreOnReconnect=true, NSLocalizedFailureReason=Assertion's invalidation time is in the past}>
default	20:20:39.069008+0100	runningboardd	Acquiring assertion targeting [app<com.app.my(7E2299AE-BA30-4489-8C7F-E5EEEDBE3CC4)>:921] from originator [app<com.app.my(7E2299AE-BA30-4489-8C7F-E5EEEDBE3CC4)>:921] with description <RBSAssertionDescriptor| "CMPhoto pool cleanup timer" ID:35-921-3681 target:921 attributes:[
	<RBSDomainAttribute| domain:"com.apple.common" name:"FinishTaskCanSleep" sourceEnvironment:"(null)">
	]>
error	20:20:39.069418+0100	MyApp	Error acquiring assertion: <Error Domain=RBSAssertionErrorDomain Code=2 "Assertion's invalidation time is in the past" UserInfo={IgnoreOnReconnect=true, NSLocalizedFailureReason=Assertion's invalidation time is in the past}>

Please advise if there are any known workarounds or fixes for this issue.

@creativecbr creativecbr added the bug Something isn't working label Nov 15, 2024
@creativecbr
Copy link
Contributor Author


default	15:53:24.587539+0100	RemoteAccessExtension	 [INFO] -[RPBroadcastSampleHandler _processPayloadWithAudioSample:type:]:180 Broadcast extension received audio payload from replayd
default	15:53:24.631859+0100	RemoteAccessExtension	 [INFO] -[RPBroadcastSampleHandler _processPayloadWithAudioSample:type:]:180 Broadcast extension received audio payload from replayd
default	15:53:24.651731+0100	RemoteAccessExtension	 [INFO] -[RPBroadcastSampleHandler _processPayloadWithAudioSample:type:]:180 Broadcast extension received audio payload from replayd
default	15:53:24.672914+0100	RemoteAccessExtension	 [INFO] -[RPBroadcastSampleHandler _processPayloadWithAudioSample:type:]:180 Broadcast extension received audio payload from replayd
default	15:53:24.694622+0100	RemoteAccessExtension	 [INFO] -[RPBroadcastSampleHandler _processPayloadWithAudioSample:type:]:180 Broadcast extension received audio payload from replayd
default	15:53:24.715542+0100	RemoteAccessExtension	 [INFO] -[RPBroadcastSampleHandler _processPayloadWithAudioSample:type:]:180 Broadcast extension received audio payload from replayd
default	15:52:34.196671+0100	RemoteAccess	Received process assertions expiration warning!
default	15:52:34.196779+0100	RemoteAccess	Notifying client of imminent expiration of assertion
default	15:52:34.198385+0100	RemoteAccess	Expiration notification complete
default	15:52:34.198446+0100	RemoteAccess	Firing background task expiration handlers
default	15:52:34.201230+0100	RemoteAccess	On backgroundTaskAssertionQueue, clearing shared assertion
default	15:52:34.201316+0100	RemoteAccess	No background tasks to fire expiration handlers for.
default	15:52:34.205533+0100	RemoteAccess	Received state update for 6226 (app<io.myOtherApp.demo.RemoteAccess(7E2299AE-BA30-4489-8C7F-E5EEEDBE3CC4)>, running-active-NotVisible
error	15:52:39.166929+0100	RemoteAccess	Error acquiring assertion: <Error Domain=RBSAssertionErrorDomain Code=2 "Assertion's invalidation time is in the past" UserInfo={IgnoreOnReconnect=true, NSLocalizedFailureReason=Assertion's invalidation time is in the past}>
error	15:52:39.168303+0100	RemoteAccess	Error acquiring assertion: <Error Domain=RBSAssertionErrorDomain Code=2 "Assertion's invalidation time is in the past" UserInfo={IgnoreOnReconnect=true, NSLocalizedFailureReason=Assertion's invalidation time is in the past}>
error	15:52:39.299004+0100	RemoteAccess	Error acquiring assertion: <Error Domain=RBSAssertionErrorDomain Code=2 "Assertion's invalidation time is in the past" UserInfo={IgnoreOnReconnect=true, NSLocalizedFailureReason=Assertion's invalidation time is in the past}>
default	15:52:39.333158+0100	RemoteAccess	Received state update for 6226 (app<io.myOtherApp.demo.RemoteAccess(7E2299AE-BA30-4489-8C7F-E5EEEDBE3CC4)>, running-suspended-NotVisible
default	15:52:39.333556+0100	RemoteAccess	Received state update for 6226 (app<io.myOtherApp.demo.RemoteAccess(7E2299AE-BA30-4489-8C7F-E5EEEDBE3CC4)>, running-active-NotVisible
default	15:53:05.302310+0100	RemoteAccess	Received process assertions expiration warning!
default	15:53:05.302330+0100	RemoteAccess	Notifying client of imminent expiration of assertion
default	15:53:05.302448+0100	RemoteAccess	Expiration notification complete
default	15:53:05.302469+0100	RemoteAccess	Firing background task expiration handlers
default	15:53:05.302489+0100	RemoteAccess	On backgroundTaskAssertionQueue, clearing shared assertion
default	15:53:05.302546+0100	RemoteAccess	No background tasks to fire expiration handlers for.
default	15:53:05.302664+0100	RemoteAccess	Received state update for 6226 (app<io.myOtherApp.demo.RemoteAccess(7E2299AE-BA30-4489-8C7F-E5EEEDBE3CC4)>, running-active-NotVisible
error	15:53:10.068478+0100	RemoteAccess	Error acquiring assertion: <Error Domain=RBSAssertionErrorDomain Code=2 "Assertion's invalidation time is in the past" UserInfo={IgnoreOnReconnect=true, NSLocalizedFailureReason=Assertion's invalidation time is in the past}>
error	15:53:10.068617+0100	RemoteAccess	Error acquiring assertion: <Error Domain=RBSAssertionErrorDomain Code=2 "Assertion's invalidation time is in the past" UserInfo={IgnoreOnReconnect=true, NSLocalizedFailureReason=Assertion's invalidation time is in the past}>
error	15:53:10.147859+0100	RemoteAccess	Error acquiring assertion: <Error Domain=RBSAssertionErrorDomain Code=2 "Assertion's invalidation time is in the past" UserInfo={IgnoreOnReconnect=true, NSLocalizedFailureReason=Assertion's invalidation time is in the past}>
error	15:53:10.147996+0100	RemoteAccess	Error acquiring assertion: <Error Domain=RBSAssertionErrorDomain Code=2 "Assertion's invalidation time is in the past" UserInfo={IgnoreOnReconnect=true, NSLocalizedFailureReason=Assertion's invalidation time is in the past}>

I created simple app to verify this error and I have reproduction, but now with more logs. It seems that problem is with processing background task, but what is the need of using them?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants