Skip to content

[4.X] iOS 26: app freezes ~20s on every play of a live stream (main-thread hang in SwiftAudioEx chapter inspection) #2665

Description

@pke

Apps playing live streams (SHOUTcast/Icecast web radio) freeze completely for ~20 seconds on iOS 26 whenever playback starts — UI unresponsive, touches queued, audio delayed; backgrounding during the freeze gets the app watchdog-killed (0x8BADF00D). The simulator does not reproduce, and the freeze exists in both 4.0.0-rc and 4.1.2 (their bundled/pinned SwiftAudioEx versions both carry the affected code).

Root cause is in SwiftAudioEx: the asset's chapter/metadata inspection reads never-async-loaded AVAsset properties (duration, and on the rc-era vendored copy also availableChapterLocales/availableMetadataFormats) synchronously on the main thread; for indefinite-duration live streams, iOS 26's mediaserverd answers those XPC queries only after a ~20s timeout. Older iOS answered instantly, which is why long-working apps regressed after their users updated iOS.

Full analysis with the captured watchdog backtrace: doublesymmetry/SwiftAudioEx#105
Fix PR (async-load duration, skip chapter inspection for indefinite assets): doublesymmetry/SwiftAudioEx#106

Workaround for 4.x apps today (CocoaPods post_install) — strip the chapter inspection; live radio has no chapters and ICY timed metadata arrives via the player-item observer regardless:

['Sources/SwiftAudioEx', 'SwiftAudioEx/Classes'].each do |base|
  wrapper = File.join(__dir__, 'Pods', 'SwiftAudioEx', base,
                      'AVPlayerWrapper', 'AVPlayerWrapper.swift')
  next unless File.exist?(wrapper)
  contents = File.read(wrapper)
  fixed = contents.gsub(
    /^ +if pendingAsset\.availableChapterLocales\.count > 0 \{.*?\n +\}\n/m,
    "// patched: sync chapter/metadata inspection removed (20s main-thread hang on live streams under iOS 26)\n"
  )
  if contents != fixed
    File.chmod(0644, wrapper)
    File.write(wrapper, fixed)
  end
end

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions