From 005e0984de73631d5e41507303b9265b604faabb Mon Sep 17 00:00:00 2001 From: Reactorcoremeltdown Date: Sat, 14 Nov 2026 21:10:05 +0100 Subject: [PATCH] iOS 0.1.2: plugin check can't crash on a stale registration after an update Co-Authored-By: Claude Opus 5.5 --- ios/CHANGELOG.md | 7 +++++++ ios/app/Host/PluginCheck.swift | 33 ++++++++++++++++++++++++++++++++- versions.properties | 4 ++-- 3 files changed, 41 insertions(+), 3 deletions(-) diff --git a/ios/CHANGELOG.md b/ios/CHANGELOG.md index 8c39d91..e05f5c5 100644 --- a/ios/CHANGELOG.md +++ b/ios/CHANGELOG.md @@ -3,6 +3,13 @@ Sizzle for iOS/iPadOS (`cc.tiredsysadmin.ios.sizzle`). One entry per version in `../versions.properties` (`ios.versionName` / `ios.versionCode`). +## 0.1.2 (build 3) + +- Fix: **Check all plugins** crashed the app right after an update. iOS can still + list the old plugin registration while the new one isn't loadable yet, and + loading it then raised an exception instead of returning an error. The check + now skips such plugins with "not registered (yet)" and catches the exception. + ## 0.1.1 (build 2) - Fix: the effects were silent in real hosts (and 0/8 in the app's check). When a diff --git a/ios/app/Host/PluginCheck.swift b/ios/app/Host/PluginCheck.swift index 7df1781..d40ea2a 100644 --- a/ios/app/Host/PluginCheck.swift +++ b/ios/app/Host/PluginCheck.swift @@ -40,6 +40,26 @@ final class PluginCheck: ObservableObject { lines.append("\(ok)/\(comps.count) passed") } + /// Loads a plugin out of process without ever crashing the app. Right after an + /// update, iOS may still list the old registration while the new one isn't + /// resolvable yet; AVAudioUnit.instantiate then raises an Objective-C + /// exception ("comp != NULL") instead of returning an error. + private func instantiate(_ desc: AudioComponentDescription) async throws -> AVAudioUnit { + var d = desc + guard AudioComponentFindNext(nil, &d) != nil else { throw CheckError.notRegistered } + return try await withCheckedThrowingContinuation { cont in + var resumed = false + let ex = SPKTry { + AVAudioUnit.instantiate(with: d, options: .loadOutOfProcess) { unit, error in + if let unit = unit { cont.resume(returning: unit) } + else { cont.resume(throwing: error ?? CheckError.notRegistered) } + } + resumed = true + } + if let ex = ex, !resumed { cont.resume(throwing: CheckError.exception(ex)) } + } + } + /// 1 s at 44.1 kHz stereo: a decaying saw burst, then noise, then silence. private func testBuffer(format: AVAudioFormat) -> AVAudioPCMBuffer { let n = AVAudioFrameCount(format.sampleRate) @@ -58,7 +78,7 @@ final class PluginCheck: ObservableObject { private func check(_ comp: AVAudioUnitComponent) async -> String { do { - let unit = try await AVAudioUnit.instantiate(with: comp.audioComponentDescription, options: .loadOutOfProcess) + let unit = try await instantiate(comp.audioComponentDescription) let engine = AVAudioEngine() let format = AVAudioFormat(standardFormatWithSampleRate: 44_100, channels: 2)! let player = AVAudioPlayerNode() @@ -95,3 +115,14 @@ final class PluginCheck: ObservableObject { } } } + +enum CheckError: LocalizedError { + case notRegistered + case exception(String) + var errorDescription: String? { + switch self { + case .notRegistered: return "not registered (yet): reopen the app, or restart the iPad after an update" + case .exception(let e): return "exception \(e)" + } + } +} diff --git a/versions.properties b/versions.properties index 9e906d5..1472af3 100644 --- a/versions.properties +++ b/versions.properties @@ -17,8 +17,8 @@ android.versionCode = 70 # iOS/iPadOS (cc.tiredsysadmin.ios.sizzle): the AUv3 plugin app in ios/app; the # Makefile there passes these to Xcode and names the .ipa by versionCode. (The # TrollStore spike in ios/spike keeps its own version in its project.yml.) -ios.versionName = 0.1.1 -ios.versionCode = 2 +ios.versionName = 0.1.2 +ios.versionCode = 3 macos.versionName = - linux.versionName = - bsd.versionName = -