Post

Replies

Boosts

Views

Activity

Live Activity Stops Updating after iPhone Lock
My background audio app stops updating its Live Activity after the iPhone locks, and doesn't resume updating the activity after tapping the screen or even after FaceID unlocks the device (without opening the lock screen). My live activity requests a ContentState update & iOS updates the content for the activity as below: Task{ log.debug("LiveActivityManager.updateLiveActivity() with new ContentState") await liveActivity.update( ActivityContent(state:contentState, staleDate:nil) ) } Below what my log looks like: <<<<SWIPE LOCK SCREEN DOWN>>>> DEBUG: LiveActivityManager.updateLiveActivity() with new ContentState iOS: Updating content for activity 0A519263-1E46-4BB6-BA4F-F3DDBC081AB4 DEBUG: LiveActivityManager.updateLiveActivity() with new ContentState iOS: Updating content for activity 0A519263-1E46-4BB6-BA4F-F3DDBC081AB4 <<<<PRESS LOCK BUTTON->Lock iPhone>>>> INFO: --------protectedDataWillBecomeUnavailableNotification-------- DEBUG: LiveActivityManager.updateLiveActivity() with new ContentState iOS: Updating content for activity 0A519263-1E46-4BB6-BA4F-F3DDBC081AB4 DEBUG: LiveActivityManager.updateLiveActivity() with new ContentState DEBUG: LiveActivityManager.updateLiveActivity() with new ContentState DEBUG: LiveActivityManager.updateLiveActivity() with new ContentState <<<<LOOK AT & TAP LOCK SCREEN->Unlock iPhone without swiping up>>>> INFO: --------protectedDataDidBecomeAvailableNotification----------- DEBUG: LiveActivityManager.updateLiveActivity() with new ContentState DEBUG: LiveActivityManager.updateLiveActivity() with new ContentState DEBUG: LiveActivityManager.updateLiveActivity() with new ContentState As shown in the log, normally iOS updates the content for my activity after my liveActivity.update request. This works fine in the Dynamic Island and when after switching apps and swiping down to see the lock screen without locking the phone. However, once I lock the phone, iOS stops updating the Live Activity content, and doesn't resume updates until after the app regains the foreground at least once. Has anyone else encountered this behavior? Is this a setting that I'm missing, or a bug?
12
1
4.5k
Jul ’24
Task in @MainActor Function Appears to Become Detached
I'm hoping someone can help me understand some unexpected behavior in a @MainActor Function which internally calls a task that calls a method on a background actor. Normally, the function would call the task, pause until the task completes, and finish the end of the function. However, when the function is annotated @Main actor, the internal task appears to become detached and execute asynchronously such that it finishes after the @MainActor function. The code below demonstrates this behavior in a playground: actor SeparateActor{ func actorFunc(_ str:String){ print("\tActorFunc(\(str))") } } class MyClass{ var sa = SeparateActor() @MainActor func mainActorFunctionWithTask(){ print("mainActorFunctionWithTask Start") Task{ await self.sa.actorFunc("mainActorFunctionWithTask") } print("mainActorFunctionWithTask End") } func normalFuncWithTask(){ print("normalFuncWithTask Start") Task{ await self.sa.actorFunc("normalFuncWithTask") } print("normalFuncWithTask End") } } Task{ let mc = MyClass() print("\nCalling normalFuncWithTask") mc.normalFuncWithTask() print("\nCalling mainActorFunctionWithTask") await mc.mainActorFunctionWithTask() } I would expect both the normalFunc and the mainActorFunc to behave the same, with the ActorFunc being called before the end of the task, but instead, my mainActor function completes before the task. Calling normalFuncWithTask normalFuncWithTask Start ActorFunc(normalFuncWithTask) normalFuncWithTask End Calling mainActorFunctionWithTask mainActorFunctionWithTask Start mainActorFunctionWithTask End ActorFunc(mainActorFunctionWithTask)
2
0
1.1k
Mar ’24
XCode 14 & iOS 16 Beta: No AVSpeechSynthesisVoice.speechVoices available
I'm testing my App in the Xcode 14 beta (released with WWDC22) on iOS 16, and it seems that AVSpeechSynthesisVoice is not working correctly. The following code always returns an empty array: AVSpeechSynthesisVoice.speechVoices() Additionally, attempting to initialize AVSpeechSynthesisVoice returns nil for all of the following: AVSpeechSynthesisVoice(language: AVSpeechSynthesisVoice.currentLanguageCode()) AVSpeechSynthesisVoice(language: "en") AVSpeechSynthesisVoice(language: "en-US") AVSpeechSynthesisVoice(identifier: AVSpeechSynthesisVoiceIdentifierAlex) AVSpeechSynthesisVoice.speechVoices().first
15
3
5k
Feb ’23
Useless XCTMetrics (XCTMemoryMetric & XCTCPUMetric) when Measuring XCUIApplicaiton
I've noticed that XCTMemoryMetric &amp; XCTCPUMetric seem to record empty or nonsensical data when running a UI test flow for an XCUIApplication. I'm attempting to test the memory and CPU footprint for a SwiftUI iOS app using the following code: Swift func testBasicFlowMemory() throws{ let app = XCUIApplication() app.launch() var metrics:[XCTMetric] = [] metrics.append( XCTClockMetric() ) metrics.append( XCTMemoryMetric(application: app) ) metrics.append( XCTCPUMetric(application: app) ) self.measure(metrics: metrics){ /*Method which uses XCUI API to test the app instance*/ self.runBasicFlowTest(app: app) } } When I run the test above, I notice runBasicFlowTest is executed 6 times (even though the metics only record 5 values. Of the three metrics I wanted to track only XCTClockMetric returned meaningful data: [Clock Monotonic Time, s] values: [114.728229, 114.944770, 121.813337, 116.394432, 117.491242] XCTMemoryMetric mostly recorded 0.0 or nonsense data: [Memory Physical, kB] values: [3596.288000, 0.000000, 0.000000, 0.000000, 0.000000] [Memory Peak Physical, kB] values: [0.000000, 0.000000, 0.000000, 0.000000, 0.000000] XCTCPUMetric likewise recorded 0.0 or nonsense data: [CPU Instructions Retired, kI] values: [0.000000, 206223944.266000, 0.000000, 0.000000, 211895544.471000] [CPU Cycles, kC] values: [0.000000, 252096240.472000, 0.000000, 0.000000, 257352232.305000], [CPU Time, s] values: [0.000000, 86.585296, 0.000000, 0.000000, 0.000000] I'm on Xcode Version 12.4 (12D4e), and my app is targeting iOS 14.4 on a simulated iPhone 11 Pro. Has anyone had any luck using XCTMetrics with UI Tests?
4
1
2.7k
Oct ’22
Xcode 14: Simulator Disappeared After Crash
Testing my app in an iOS 15.5 simulator with Xcode 14 beta, it crashed hard, locking up my entire laptop. After restarting, it seems that the iOS 15.5 simulator runtime disappeared, and I'm now getting the following error: The com.apple.CoreSimulator.SimRuntime.iOS-15-5 simulator runtime is not available. runtime profile not found Download the com.apple.CoreSimulator.SimRuntime.iOS-15-5 simulator runtime from the Components section in Xcode's Preferences. Unfortunately, Xcode seems to think that I already have the runtime, and no longer gives me the option to download it.
3
2
4.5k
Jun ’22
Live Activity Stops Updating after iPhone Lock
My background audio app stops updating its Live Activity after the iPhone locks, and doesn't resume updating the activity after tapping the screen or even after FaceID unlocks the device (without opening the lock screen). My live activity requests a ContentState update & iOS updates the content for the activity as below: Task{ log.debug("LiveActivityManager.updateLiveActivity() with new ContentState") await liveActivity.update( ActivityContent(state:contentState, staleDate:nil) ) } Below what my log looks like: <<<<SWIPE LOCK SCREEN DOWN>>>> DEBUG: LiveActivityManager.updateLiveActivity() with new ContentState iOS: Updating content for activity 0A519263-1E46-4BB6-BA4F-F3DDBC081AB4 DEBUG: LiveActivityManager.updateLiveActivity() with new ContentState iOS: Updating content for activity 0A519263-1E46-4BB6-BA4F-F3DDBC081AB4 <<<<PRESS LOCK BUTTON->Lock iPhone>>>> INFO: --------protectedDataWillBecomeUnavailableNotification-------- DEBUG: LiveActivityManager.updateLiveActivity() with new ContentState iOS: Updating content for activity 0A519263-1E46-4BB6-BA4F-F3DDBC081AB4 DEBUG: LiveActivityManager.updateLiveActivity() with new ContentState DEBUG: LiveActivityManager.updateLiveActivity() with new ContentState DEBUG: LiveActivityManager.updateLiveActivity() with new ContentState <<<<LOOK AT & TAP LOCK SCREEN->Unlock iPhone without swiping up>>>> INFO: --------protectedDataDidBecomeAvailableNotification----------- DEBUG: LiveActivityManager.updateLiveActivity() with new ContentState DEBUG: LiveActivityManager.updateLiveActivity() with new ContentState DEBUG: LiveActivityManager.updateLiveActivity() with new ContentState As shown in the log, normally iOS updates the content for my activity after my liveActivity.update request. This works fine in the Dynamic Island and when after switching apps and swiping down to see the lock screen without locking the phone. However, once I lock the phone, iOS stops updating the Live Activity content, and doesn't resume updates until after the app regains the foreground at least once. Has anyone else encountered this behavior? Is this a setting that I'm missing, or a bug?
Replies
12
Boosts
1
Views
4.5k
Activity
Jul ’24
Task in @MainActor Function Appears to Become Detached
I'm hoping someone can help me understand some unexpected behavior in a @MainActor Function which internally calls a task that calls a method on a background actor. Normally, the function would call the task, pause until the task completes, and finish the end of the function. However, when the function is annotated @Main actor, the internal task appears to become detached and execute asynchronously such that it finishes after the @MainActor function. The code below demonstrates this behavior in a playground: actor SeparateActor{ func actorFunc(_ str:String){ print("\tActorFunc(\(str))") } } class MyClass{ var sa = SeparateActor() @MainActor func mainActorFunctionWithTask(){ print("mainActorFunctionWithTask Start") Task{ await self.sa.actorFunc("mainActorFunctionWithTask") } print("mainActorFunctionWithTask End") } func normalFuncWithTask(){ print("normalFuncWithTask Start") Task{ await self.sa.actorFunc("normalFuncWithTask") } print("normalFuncWithTask End") } } Task{ let mc = MyClass() print("\nCalling normalFuncWithTask") mc.normalFuncWithTask() print("\nCalling mainActorFunctionWithTask") await mc.mainActorFunctionWithTask() } I would expect both the normalFunc and the mainActorFunc to behave the same, with the ActorFunc being called before the end of the task, but instead, my mainActor function completes before the task. Calling normalFuncWithTask normalFuncWithTask Start ActorFunc(normalFuncWithTask) normalFuncWithTask End Calling mainActorFunctionWithTask mainActorFunctionWithTask Start mainActorFunctionWithTask End ActorFunc(mainActorFunctionWithTask)
Replies
2
Boosts
0
Views
1.1k
Activity
Mar ’24
XCode 14 & iOS 16 Beta: No AVSpeechSynthesisVoice.speechVoices available
I'm testing my App in the Xcode 14 beta (released with WWDC22) on iOS 16, and it seems that AVSpeechSynthesisVoice is not working correctly. The following code always returns an empty array: AVSpeechSynthesisVoice.speechVoices() Additionally, attempting to initialize AVSpeechSynthesisVoice returns nil for all of the following: AVSpeechSynthesisVoice(language: AVSpeechSynthesisVoice.currentLanguageCode()) AVSpeechSynthesisVoice(language: "en") AVSpeechSynthesisVoice(language: "en-US") AVSpeechSynthesisVoice(identifier: AVSpeechSynthesisVoiceIdentifierAlex) AVSpeechSynthesisVoice.speechVoices().first
Replies
15
Boosts
3
Views
5k
Activity
Feb ’23
Useless XCTMetrics (XCTMemoryMetric & XCTCPUMetric) when Measuring XCUIApplicaiton
I've noticed that XCTMemoryMetric &amp; XCTCPUMetric seem to record empty or nonsensical data when running a UI test flow for an XCUIApplication. I'm attempting to test the memory and CPU footprint for a SwiftUI iOS app using the following code: Swift func testBasicFlowMemory() throws{ let app = XCUIApplication() app.launch() var metrics:[XCTMetric] = [] metrics.append( XCTClockMetric() ) metrics.append( XCTMemoryMetric(application: app) ) metrics.append( XCTCPUMetric(application: app) ) self.measure(metrics: metrics){ /*Method which uses XCUI API to test the app instance*/ self.runBasicFlowTest(app: app) } } When I run the test above, I notice runBasicFlowTest is executed 6 times (even though the metics only record 5 values. Of the three metrics I wanted to track only XCTClockMetric returned meaningful data: [Clock Monotonic Time, s] values: [114.728229, 114.944770, 121.813337, 116.394432, 117.491242] XCTMemoryMetric mostly recorded 0.0 or nonsense data: [Memory Physical, kB] values: [3596.288000, 0.000000, 0.000000, 0.000000, 0.000000] [Memory Peak Physical, kB] values: [0.000000, 0.000000, 0.000000, 0.000000, 0.000000] XCTCPUMetric likewise recorded 0.0 or nonsense data: [CPU Instructions Retired, kI] values: [0.000000, 206223944.266000, 0.000000, 0.000000, 211895544.471000] [CPU Cycles, kC] values: [0.000000, 252096240.472000, 0.000000, 0.000000, 257352232.305000], [CPU Time, s] values: [0.000000, 86.585296, 0.000000, 0.000000, 0.000000] I'm on Xcode Version 12.4 (12D4e), and my app is targeting iOS 14.4 on a simulated iPhone 11 Pro. Has anyone had any luck using XCTMetrics with UI Tests?
Replies
4
Boosts
1
Views
2.7k
Activity
Oct ’22
Xcode 14: Simulator Disappeared After Crash
Testing my app in an iOS 15.5 simulator with Xcode 14 beta, it crashed hard, locking up my entire laptop. After restarting, it seems that the iOS 15.5 simulator runtime disappeared, and I'm now getting the following error: The com.apple.CoreSimulator.SimRuntime.iOS-15-5 simulator runtime is not available. runtime profile not found Download the com.apple.CoreSimulator.SimRuntime.iOS-15-5 simulator runtime from the Components section in Xcode's Preferences. Unfortunately, Xcode seems to think that I already have the runtime, and no longer gives me the option to download it.
Replies
3
Boosts
2
Views
4.5k
Activity
Jun ’22