OStack程序员社区-中国程序员成长平台

标题: iOS App不会死机,退出后写入控制台并播放声音 [打印本页]

作者: 菜鸟教程小白    时间: 2022-12-12 20:39
标题: iOS App不会死机,退出后写入控制台并播放声音

我的应用存在某种僵尸问题。 (不是 NSZombie 问题。就像是死而复生的问题。)

我首先注意到,在调试 session 之后,当我去运行时,iPhone 上的音乐会每隔约 7 分钟暂停一次,当我解锁设备时,应用名称会在状态栏中闪烁红色就好像它刚刚坠毁一样。有时应用程序甚至会发出幻音,就像它仍在后台运行一样。

手动退出应用,继续。 即使该应用不再出现在我正在运行的应用列表中,仍然会出现间歇性音频伪影。

当我重新插入时,每次应用程序僵尸化并自行重新启动时,它都会出现在控制台中。它看起来就像应用程序的正常启动!什么?什么会触发我的应用自行重启?

控制台:

Apr 26 12:10:01 unknown Breakout[2658] <Warning>: cocos2d: cocos2d v1.1.0-beta2b
Apr 26 12:10:01 unknown Breakout[2658] <Warning>: cocos2d: Using Director Type:CCDirectorDisplayLink
Apr 26 12:10:01 unknown Breakout[2658] <Warning>: cocos2d: OS version: 5.1 (0x05010000)
Apr 26 12:10:01 unknown Breakout[2658] <Warning>: cocos2d: GL_VENDOR:   Imagination Technologies
Apr 26 12:10:01 unknown Breakout[2658] <Warning>: cocos2d: GL_RENDERER: PowerVR SGX 535
Apr 26 12:10:01 unknown Breakout[2658] <Warning>: cocos2d: GL_VERSION:  OpenGL ES-CM 1.1 IMGSGX535-63.24
Apr 26 12:10:01 unknown Breakout[2658] <Warning>: cocos2d: GL_MAX_TEXTURE_SIZE: 2048
Apr 26 12:10:01 unknown Breakout[2658] <Warning>: cocos2d: GL_MAX_MODELVIEW_STACK_DEPTH: 16
// etc //
Apr 26 12:10:01 unknown kernel[0] <Debug>: launchd[2658] Builtin profile: container (sandbox)
Apr 26 12:10:01 unknown kernel[0] <Debug>: launchd[2658] Container: /private/var/mobile/Applications/FFEB0A26-06D1-4C46-8AE5-C60582D09A1D [69] (sandbox)
Apr 26 12:10:01 unknown Breakout[2658] <Warning>: Audio session details
Apr 26 12:10:01 unknown Breakout[2658] <Warning>: Audio Input Available? YES 
Apr 26 12:10:01 unknown mediaserverd[32] <Warning>: 12:10:01.641 <SystemSoundServer> WARNING translating HAL error: 561214578 
Apr 26 12:10:01 unknown Breakout[2658] <Warning>: Max Possible Inputs 15151420 
Apr 26 12:10:01 unknown Breakout[2658] <Warning>: Outputs 2 
Apr 26 12:10:01 unknown Breakout[2658] <Warning>: Device sample rate 44100.000000 
Apr 26 12:10:01 unknown Breakout[2658] <Warning>: Hardware buffer size 0.023220 
// etc //
Apr 26 12:10:33 unknown SpringBoard[52] <Notice>: Posting 'com.apple.iokit.hid.displayStatus' notifyState=1
Apr 26 12:10:33 unknown UserEventAgent[12] <Warning>: DEBUG: Changing screen blanked state: 0
Apr 26 12:10:33 unknown SpringBoard[52] <Notice>: MultitouchHID: detection mode: 255->0 (deferring until bootloaded)
Apr 26 12:10:33 unknown SpringBoard[52] <Notice>: MultitouchHID: device bootloaded
Apr 26 12:10:33 unknown SpringBoard[52] <Notice>: MultitouchHID: detection mode: 0->0
Apr 26 12:10:34 unknown kernel[0] <Debug>: set_crc_notification_state 0
Apr 26 12:10:34 unknown ReportCrash[2659] <Notice>: Formulating crash report for process Breakout[2658]
> 
Apr 26 12:10:34 unknown SpringBoard[52] <Warning>: pid_suspend failed for [2658]: Unknown error: -1, Unknown error: -1
Apr 26 12:10:34 unknown SpringBoard[52] <Warning>: Could not set priority of [2658] to 4096, priority: No such process
Apr 26 12:10:34 unknown com.apple.launchd[1] <Warning>: (UIKitApplication:com.charliewilliams.Breakout[0xd5ad]) Job appears to have crashed: Trace/BPT trap: 5
Apr 26 12:10:34 unknown SpringBoard[52] <Warning>: Application 'Breakout' exited abnormally with signal 5: Trace/BPT trap: 5
Apr 26 12:10:35 unknown ReportCrash[2659] <Error>: libMobileGestalt computeUniqueDeviceID: total time for bb to return imei: 0
Apr 26 12:10:35 unknown ReportCrash[2659] <Notice>: Saved crashreport to /var/mobile/Library/Logs/CrashReporter/Breakout_2012-04-26-121033_Tortuga-Gigante.plist using uid: 0 gid: 0, synthetic_euid: 501 egid: 0

解决方案说明:结果很简单 - 1. 我在 dealloc 中关闭了我的 Audio Session ,但在 applicationDidEnterBackground 中没有>。而且由于我使用的是 kaudiosessioncategory_playandrecord,这似乎告诉 iOS 如果应用程序在后台崩溃,则重新启动它。

现在,为什么它会在后台崩溃? ...嗯,这是我的下一个任务。



Best Answer-推荐答案


应用程序可能设置了后台 voip 标志。如果是这样,如果应用程序异常退出(或设备重启时),操作系统将重新启动应用程序。

关于iOS App不会死机,退出后写入控制台并播放声音,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10332422/






欢迎光临 OStack程序员社区-中国程序员成长平台 (https://ostack.cn/) Powered by Discuz! X3.4