You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

iOS 16.2升级后Flutter Audio_Service后台音频播放异常求助

iOS 16.2 升级后 Just Audio 后台播放失效问题排查与解决建议

问题描述

将iPhone升级至iOS 16.2后,原本支持后台播放的音频仅能在前台播放,使用Just Audio作为播放器。该问题仅出现在iOS 16.2设备上,iOS 14设备及Android设备均正常运行,推测问题由iOS 16.2更新导致,而非代码层面问题。

控制台相关报错日志

  1. 权限相关报错(此前存在但未影响功能):
[NowPlaying] [MRNowPlaying] Ignoring setPlaybackState because application does not contain entitlement com.apple.mediaremote.set-playback-state for platform
  1. 另一条权限日志:
[Entitlements] MSVEntitlementUtilities - Process Runner PID[572] - Group: (null) - Entitlement: com.apple.mediaremote.external-artwork-validation - Entitled: NO - Error: (null)
  1. 另一简化测试应用中出现的后台任务警告:
[BackgroundTask] Background Task 9 ("Flutter debug task"), was created over 30 seconds ago. In applications running in the background, this creates a risk of termination. Remember to call UIApplication.endBackgroundTask(_:) for your task in a timely manner to avoid this.

环境信息(flutter doctor -v输出)

[✓] Flutter (Channel stable, 3.3.10, on macOS 12.6.2 21G320 darwin-x64, locale it-IT)
• Flutter版本3.3.10(stable通道),路径:/Users/carlosacchetti/Developer/flutter
• 上游仓库:https://github.com/flutter/flutter.git
• Framework修订版本:135454af32(5周前,2022-12-15 07:36:55 -0800)
• Engine修订版本:3316dd8728
• Dart版本:2.18.6
• DevTools版本:2.15.0

[✓] Android工具链 - 开发Android设备(Android SDK版本33.0.0)
• Android SDK路径:/Users/carlosacchetti/Library/Android/sdk
• 平台:android-33,build-tools 33.0.0
• Java二进制文件路径:/Applications/Android Studio.app/Contents/jre/Contents/Home/bin/java
• Java版本:OpenJDK Runtime Environment (build 11.0.10+0-b96-7281165)
• 已接受所有Android许可证。

[✓] Xcode - 开发iOS和macOS应用(Xcode 14.2)
• Xcode路径:/Applications/Xcode.app/Contents/Developer
• Build版本:14C18
• CocoaPods版本:1.11.2

[✓] Chrome - 开发Web应用
• Chrome路径:/Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio(版本2020.3)
• Android Studio路径:/Applications/Android Studio.app/Contents
• Flutter插件可从以下地址安装:🔨 https://plugins.jetbrains.com/plugin/9212-flutter
• Dart插件可从以下地址安装:🔨 https://plugins.jetbrains.com/plugin/6351-dart
• Java版本:OpenJDK Runtime Environment (build 11.0.10+0-b96-7281165)

[✓] IntelliJ IDEA Community Edition(版本2021.1.1)
• IntelliJ路径:/Applications/IntelliJ IDEA CE.app
• Flutter插件可从以下地址安装:🔨 https://plugins.jetbrains.com/plugin/9212-flutter
• Dart插件可从以下地址安装:🔨 https://plugins.jetbrains.com/plugin/6351-dart

[✓] VS Code(版本1.74.3)
• VS Code路径:/Applications/Visual Studio Code.app/Contents
• Flutter扩展版本:3.56.0

[✓] 已连接设备(4台可用)
• SM G780G(移动设备) • RF8T30H0K2Y • android-arm64 • Android 13(API 33)
• iPhone CS(移动设备) • 00008110-000A5CD42682801E • ios • iOS 16.2 20C65
• macOS(桌面设备) • macos • darwin-x64 • macOS 12.6.2 21G320 darwin-x64
• Chrome(Web) • chrome • web-javascript • Google Chrome 108.0.5359.124
! 错误:iPhone CS正忙:正在获取iPhone CS的调试符号。完成后Xcode将继续。(代码-10)
! 错误:Apple Watch di Carlo需要连接以确认可用性。请检查设备与其配对iPhone的连接,以及iPhone与Xcode的连接。两台设备可能需要重启并解锁。(代码1)

[✓] HTTP主机可用性
• 所有必需的HTTP主机均可用

• 未发现问题!

排查方向与解决建议

  • 确认后台播放权限配置
    检查Xcode项目中是否开启Background Modes权限并勾选Audio, AirPlay, and Picture in Picture,同时验证Info.plist中是否添加UIBackgroundModes键,值包含audio。

  • 处理媒体权限 entitlement
    针对com.apple.mediaremote.set-playback-state权限,检查项目签名配置文件是否包含该权限。可在Apple开发者后台的App ID配置中添加权限,重新生成配置文件并导入Xcode测试。

  • 优化后台任务管理
    检查Flutter代码中是否存在未及时结束的后台任务,确保音频切换完成后调用相关API结束任务;尝试切换到Release模式运行应用,Debug模式的后台任务限制更严格。

  • 验证插件适配性
    升级Just Audio插件到最新版本,查看插件官方issues页面确认是否有iOS 16.2兼容问题反馈;测试官方示例项目,确认问题是否普遍存在。

  • 清除环境缓存
    重启iOS设备和Xcode,清除项目DerivedData后重新编译运行,排除环境缓存导致的异常。

内容的提问来源于stack exchange,提问作者csacchetti

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.04 09:00:56