我正在实现键盘扩展。但有时它在启动时会遇到 SIGQUIT 信号。
情况如下:
- 点击textView,出现键盘
- 点击任意位置并隐藏键盘
- 更改为另一个应用
- 点击textView并等待键盘出现
崩溃!!! SIGQUIT
Exception Type: EXC_CRASH (SIGQUIT)
Exception Codes: 0x0000000000000000, 0x0000000000000000
Exception Note: EXC_CORPSE_NOTIFY
Termination Signal: Quit: 3
Termination Reason: Namespace SIGNAL, Code 0x3
Terminating Process: launchd [1]
Triggered by Thread: 0
Thread 0 name: Dispatch queue: com.apple.main-thread
Thread 0 Crashed:
0 libsystem_kernel.dylib 0x000000018819b260 semaphore_wait_trap + 8
1 libdispatch.dylib 0x00000001880895e8 _os_semaphore_wait + 24
2 libdispatch.dylib 0x0000000188088ca0 _dispatch_semaphore_wait_slow + 140
3 DTXConnectionServices 0x00000001012a9ec4 0x10129c000 + 57028
4 DTXConnectionServices 0x00000001012a95ec 0x10129c000 + 54764
5 libfsmonitor_interpose.dylib 0x000000010128a040 0x101288000 + 8256
6 libfsmonitor_interpose.dylib 0x000000010128a3b4 0x101288000 + 9140
7 dyld 0x00000001013326b0 ImageLoaderMachO::doModInitFunctions(ImageLoader::LinkContext const&) + 356
8 dyld 0x00000001013328e0 ImageLoaderMachO::doInitialization(ImageLoader::LinkContext const&) + 36
9 dyld 0x000000010132db44 ImageLoader::recursiveInitialization(ImageLoader::LinkContext const&, unsigned int, char const*, ImageLoader::InitializerTimingList&, ImageLoader::UninitedUpwards&) + 368
10 dyld 0x000000010132cb74 ImageLoader::processInitializers(ImageLoader::LinkContext const&, unsigned int, ImageLoader::InitializerTimingList&, ImageLoader::UninitedUpwards&) + 136
11 dyld 0x000000010132cc30 ImageLoader::runInitializers(ImageLoader::LinkContext const&, ImageLoader::InitializerTimingList&) + 84
12 dyld 0x000000010131e440 dyld::initializeMainExecutable() + 140
13 dyld 0x00000001013226bc dyld::_main(macho_header const*, unsigned long, int, char const**, char const**, char const**, unsigned long*) + 3640
14 dyld 0x000000010131d044 _dyld_start + 68
在Backtrace中,都是系统调用。扩展代码并没有真正运行! 而且每次崩溃的时候,断点都不一样。
我尝试了很多东西,但没有一个有帮助。
有人知道解决方案吗?
最佳答案
通常,这意味着 iOS 的 launchd 进程由于某些“行为不当”的原因终止了您的键盘 (some info here)。它通常与启动时间有关,因此请确保您的键盘快速启动(最好少于一秒)。您可以将 Instruments 与时间分析器一起使用:打开一个带有两个文本字段的应用程序并在它们之间切换多次以获得足够的数据。请注意,在这种情况下,崩溃日志中的回溯是无用的,并且不会显示崩溃的任何原因(因为这不是崩溃 - 它只是发送了我的 launchd 的信号,这使得你的应用退出)
此外,自从 iOS11 发布以来,这种行为开始越来越频繁地发生,我假设它与此检查程序的逻辑问题有关。
关于iOS 键盘扩展 SIGQUIT 启动时,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45138178/