I've encountered a critical issue while testing my app, which is available on the App Store, on the iOS 17.2 beta (iPhone SE simulator). The app freezes and becomes unresponsive. Currently, I haven't found a workaround, which means my app is completely non-functional and untestable on iOS 17.2 beta.
The app supports iOS 15.2 and later versions, and it has been working fine from iOS 15.2 through iOS 17.1. The problem only occurs on the iOS 17.2 beta.
I have been able to reproduce the issue with the sample code provided below.
■ Test Environment:
- macOS: 14.0 (23A344)
- Xcode Version: 15.1 beta (15C5042i)
- iPhone SE 3rd generation (simulator): iOS 17.2 (21C5029e)
■ Steps to Reproduce:
Prerequisites: Prepare an audio file, such as an m4a or mp3, and add it to the Bundle Resources.
1 Launch the sample code provided below.
2 Tap on any row's NavigationLink.
After tapping, when the program attempts to access the AVPlayer, the following log is displayed in Xcode:
CA_UISoundClient.cpp:1127 Device = 0
HALPlugInManagement.cpp:396 HALPlugInManagement::RegisterPlugIns: loading in-process plug-ins
AddInstanceForFactory: No factory registered for id <CFUUID 0x600000285600> F8BB1C28-BAE8-11D6-9C31-00039315CD46
CA_UISoundClient.cpp:1203 renderer = 0x600000011f90, synchronizer: 0x0, repeat: 0, vol: 1.00
3 Tap the Navigation's Back button at the top left.
Depending on the timing, there may be no response when pressing the button (screen). Approximately 15 seconds later, the following log is displayed, and the screen becomes responsive again as it returns to the previous view.
AQMEIO.cpp:198 timed out after 15.000s (0 0); suspension count=0 (IOSuspensions: )
MEDeviceStreamClient.cpp:467 AQME Default-InputOutput: client stopping after failed start: <CA_UISoundClientBase@0x104015d00>; running count now 0
CA_UISoundClient.cpp:293 CA_UISoundClientBase::StartPlaying: AddRunningClient failed (status = -66681).
changing items while animating can result in a corrupted navigation bar
4 If the issue does not reproduce, quit the app and then return to step 1.
In the sample code, whether the issue occurs or not may depend on the timing of screen transitions, scrolling, and tapping. (The issue might occur with a high probability if you tap 'back' during a screen transition animation.) On the production app in question, the issue occurs 100% of the time.
■ Sample code
import SwiftUI
import AVFoundation
@main
struct iOSAppHangSampleApp: App {
@StateObject var model = ContentModel()
var body: some Scene {
WindowGroup {
if #available(iOS 17, *) {
NavigationStack {
ContentView()
.environmentObject(model)
}
} else {
NavigationView {
ContentViewIOS15()
.environmentObject(model)
}.navigationViewStyle(.stack)
}
}
}
}
@MainActor
class ContentModel: ObservableObject {
private let player = AVPlayer()
@Published var playbackDuration: TimeInterval = .zero
func load() {
let url = Bundle.main.url(forResource: "YourAudioFilename", withExtension: "m4a")! // Change to your audio.
let avassetURL = AVURLAsset(url: url, options: [AVURLAssetPreferPreciseDurationAndTimingKey: true])
let avPlayerItem = AVPlayerItem(asset: avassetURL)
self.player.replaceCurrentItem(with: avPlayerItem)
self.playbackDuration = avPlayerItem.asset.duration.seconds
}
}
@available(iOS 17, *)
struct ContentView: View {
@EnvironmentObject private var model: ContentModel
private let urls: [URL] = {
(0..<50).map { URL(fileURLWithPath: "\($0)")}
}()
@State private var selected: Int?
var body: some View {
List(selection: $selected) {
ForEach(urls.indices, id: \.self) { idx in
let _ = urls[idx]
NavigationLink(value: idx) {
Text("\(idx)")
}
}
}
.navigationDestination(item: $selected) { idx in
Content3View()
.environmentObject(model)
}
}
}
@available(iOS 15, *)
struct ContentViewIOS15: View {
@EnvironmentObject var model: ContentModel
let urls: [URL] = {
(0..<50).map { URL(fileURLWithPath: "\($0)")}
}()
@State var selected: Int?
var body: some View {
List() {
ForEach(urls.indices, id: \.self) { idx in
let _ = urls[idx]
NavigationLink(tag: idx, selection: $selected) {
if selected == idx {
Content3View()
.environmentObject(model)
}
} label: {
Text("\(idx)")
}
}
}
}
}
struct Content3View: View {
@EnvironmentObject private var model: ContentModel
var body: some View {
Text("duration: \(model.playbackDuration)")
.onAppear() {
model.load()
}
}
}
■ Investigation
The sample code has been tested on the iPhone 17.0 simulator, 15.2 simulator, and an iPhone 17.1 real device, but the issue only appears on the 17.2 beta. Also, when replacing NavigationStack with NavigationView in the sample code, the issue does not seem to occur on iOS 17.2.
I'm not sure about the relationship between the back navigation and toolbar inside NavigationStack, but it might be related to the following content in the iOS 17.2 Release Notes.
Resolved Issues
* Fixed: Resolved a possible Swift access conflict crash that could occur with toolbar items. (113992797)
This issue also brings to mind the randomness associated with NavigationView / NavigationStack that I've observed.
- iOS 16.4 NavigationStack Behavior Unstable https://developer.apple.com/forums/thread/727282
- SwiftUI NavigationView pops back when updating observableObject https://developers.apple.com/forums/thread/693137
■ if anyone has found a workaround, please let me know.
I have not been able to confirm whether this issue occurs only on the Simulator, but it is preventing me from continuing to test on iOS 17.2 beta since the app is completely non-functional. If this is an issue with iOS 17.2 beta, I hope for a resolution before the official release of iOS 17.2.