2017-08-02 99 views
0

我有一個自定義鍵盤,圖像分爲類別。 Rigth現在我在每個類別中都有12張圖像。如果我有20個圖像的類別,例如鍵盤崩潰。我一直在尋找一個解決方案很長一段時間沒有運氣。 當我調試在我的iPhone的鍵盤,我收到了SIGQUIT信號:自定義鍵盤崩潰共享庫事件(內存泄漏?)

dyld`_dyld_start: 
-> 0x10014d000 <+0>: mov x28, sp 
    0x10014d004 <+4>: and sp, x28, #0xfffffffffffffff0 
    0x10014d008 <+8>: mov x0, #0x0 
    0x10014d00c <+12>: mov x1, #0x0 
    0x10014d010 <+16>: stp x1, x0, [sp, #-0x10]! 
    0x10014d014 <+20>: mov x29, sp 
    0x10014d018 <+24>: sub sp, sp, #0x10    ; =0x10 
    0x10014d01c <+28>: ldr x0, [x28] 
    0x10014d020 <+32>: ldr x1, [x28, #0x8] 
    0x10014d024 <+36>: add x2, x28, #0x10   ; =0x10 
    0x10014d028 <+40>: adrp x4, -1 
    0x10014d02c <+44>: add x4, x4, #0x0    ; =0x0 
    0x10014d030 <+48>: adrp x3, 52 
    0x10014d034 <+52>: ldr x3, [x3, #0xd90] 
    0x10014d038 <+56>: sub x3, x4, x3 
    0x10014d03c <+60>: mov x5, sp 
    0x10014d040 <+64>: bl  0x10014d088    ; dyldbootstrap::start(macho_header const*, int, char const**, long, macho_header const*, unsigned long*) 
    0x10014d044 <+68>: mov x16, x0 
    0x10014d048 <+72>: ldr x1, [sp] 
    0x10014d04c <+76>: cmp x1, #0x0     ; =0x0 
    0x10014d050 <+80>: b.ne 0x10014d05c    ; <+92> 
    0x10014d054 <+84>: add sp, x28, #0x8    ; =0x8 
    0x10014d058 <+88>: br  x16 
    0x10014d05c <+92>: mov x30, x1 
    0x10014d060 <+96>: ldr x0, [x28, #0x8] 
    0x10014d064 <+100>: add x1, x28, #0x10   ; =0x10 
    0x10014d068 <+104>: add x2, x1, x0, lsl #3 
    0x10014d06c <+108>: add x2, x2, #0x8    ; =0x8 
    0x10014d070 <+112>: mov x3, x2 
    0x10014d074 <+116>: ldr x4, [x3] 
    0x10014d078 <+120>: add x3, x3, #0x8    ; =0x8 
    0x10014d07c <+124>: cmp x4, #0x0     ; =0x0 
    0x10014d080 <+128>: b.ne 0x10014d074    ; <+116> 
    0x10014d084 <+132>: br  x16 

如果我點擊繼續,我得到。主題1:共享庫事件:

dyld`_dyld_debugger_notification: 
-> 0x10022cdc4 <+0>: ret  

做 'BT' 在控制檯中我得到:

* thread #1, stop reason = shared-library-event 
    * frame #0: 0x000000010022cdc4 dyld`_dyld_debugger_notification 
    frame #1: 0x000000010022c9a4 dyld`gdb_image_notifier(dyld_image_mode, unsigned int, dyld_image_info const*) + 112 
    frame #2: 0x000000010022c5f0 dyld`notifyGDB(dyld_image_states, unsigned int, dyld_image_info const*) + 60 
    frame #3: 0x0000000100224b4c dyld`dyld::notifyBatchPartial(dyld_image_states, bool, char const* (*)(dyld_image_states, unsigned int, dyld_image_info const*), bool, bool) + 1040 
    frame #4: 0x000000010023035c dyld`ImageLoader::link(ImageLoader::LinkContext const&, bool, bool, bool, ImageLoader::RPathChain const&, char const*) + 140 
    frame #5: 0x0000000100225214 dyld`dyld::link(ImageLoader*, bool, bool, ImageLoader::RPathChain const&, unsigned int) + 228 
    frame #6: 0x0000000100226274 dyld`dyld::_main(macho_header const*, unsigned long, int, char const**, char const**, char const**, unsigned long*) + 2544 
    frame #7: 0x0000000100221044 dyld`_dyld_start + 68 

有什麼想法? UPDATE 我創建了一個期望斷點,我得到了加載nib文件的斷點。

- (void)arrangeXib{ 

    self.keyboard = [[[NSBundle mainBundle]loadNibNamed:@"iPhone" owner:nil options:nil] objectAtIndex:0]; 

    self.inputView = (UIInputView *)self.keyboard; 
} 

例外:

* thread #1, queue = 'com.apple.main-thread', stop reason = signal SIGQUIT 
    frame #0: 0x00000001847b3224 libsystem_kernel.dylib`mach_msg_trap + 8 
    frame #1: 0x00000001847b309c libsystem_kernel.dylib`mach_msg + 72 
    frame #2: 0x00000001846a4ee4 libdispatch.dylib`_dispatch_mach_send_and_wait_for_reply + 540 
    frame #3: 0x00000001846a52e8 libdispatch.dylib`dispatch_mach_send_with_result_and_wait_for_reply + 56 
    frame #4: 0x00000001848ccee0 libxpc.dylib`xpc_connection_send_message_with_reply_sync + 196 
    frame #5: 0x0000000185754368 CoreFoundation`__78-[CFPrefsPlistSource sendRequestNewDataMessage:toConnection:retryCount:error:]_block_invoke + 24 
    frame #6: 0x00000001857797a8 CoreFoundation`CFPREFERENCES_IS_WAITING_FOR_SYSTEM_CFPREFSD + 48 
    frame #7: 0x00000001857542ac CoreFoundation`-[CFPrefsPlistSource sendRequestNewDataMessage:toConnection:retryCount:error:] + 264 
    frame #8: 0x000000018575348c CoreFoundation`__50-[CFPrefsPlistSource alreadylocked_requestNewData]_block_invoke + 92 
    frame #9: 0x0000000185819d90 CoreFoundation`-[_CFXPreferences withConnectionForRole:performBlock:] + 48 
    frame #10: 0x00000001857533e4 CoreFoundation`-[CFPrefsPlistSource alreadylocked_requestNewData] + 288 
    frame #11: 0x0000000185750be4 CoreFoundation`_copyValueForKey + 548 
    frame #12: 0x00000001857511f0 CoreFoundation`-[CFPrefsPlistSource copyValueForKey:] + 60 
    frame #13: 0x0000000185818418 CoreFoundation`__66-[_CFXPreferences copyValueForKey:identifier:user:host:container:]_block_invoke + 40 
    frame #14: 0x0000000185813758 CoreFoundation`-[_CFXPreferences(SourceAdditions) withSourceForIdentifier:user:byHost:container:cloud:perform:] + 748 
    frame #15: 0x000000018577af20 CoreFoundation`-[_CFXPreferences(SearchListAdditions) with23930198HackSourceForIdentifier:user:byHost:container:cloud:perform:] + 360 
    frame #16: 0x0000000185818378 CoreFoundation`-[_CFXPreferences copyValueForKey:identifier:user:host:container:] + 336 
    frame #17: 0x000000018754b3d0 ImageIO`IOPreferencesGetBoolean + 196 
    frame #18: 0x000000018754c14c ImageIO`InitDebugFlags + 3136 
    frame #19: 0x000000018468e9a0 libdispatch.dylib`_dispatch_client_callout + 16 
    frame #20: 0x000000018468f6cc libdispatch.dylib`dispatch_once_f + 56 
    frame #21: 0x0000000187462ad8 ImageIO`CGImageSourceCreateWithFile + 364 
    frame #22: 0x000000018b96c178 UIKit`ImageRefAtPath + 300 
    frame #23: 0x000000018b96bff0 UIKit`GetImageAtPath + 36 
    frame #24: 0x000000018b96bc60 UIKit`_UIImageAtPath + 396 
    frame #25: 0x000000018be10a1c UIKit`-[UIImageNibPlaceholder initWithCoder:] + 524 
    frame #26: 0x000000018bf5da50 UIKit`UINibDecoderDecodeObjectForValue + 680 
    frame #27: 0x000000018bf5d790 UIKit`-[UINibDecoder decodeObjectForKey:] + 104 
    frame #28: 0x000000018bca5ec4 UIKit`-[UIImageView initWithCoder:] + 132 
    frame #29: 0x000000018bf5da50 UIKit`UINibDecoderDecodeObjectForValue + 680 
    frame #30: 0x000000018bf5dbc8 UIKit`UINibDecoderDecodeObjectForValue + 1056 
    frame #31: 0x000000018bf5d790 UIKit`-[UINibDecoder decodeObjectForKey:] + 104 
    frame #32: 0x000000018bbed3ec UIKit`-[UIView initWithCoder:] + 652 
    frame #33: 0x000000018be0f8d8 UIKit`-[UIClassSwapper initWithCoder:] + 248 
    frame #34: 0x000000018bf5da50 UIKit`UINibDecoderDecodeObjectForValue + 680 
    frame #35: 0x000000018bf5d790 UIKit`-[UINibDecoder decodeObjectForKey:] + 104 
    frame #36: 0x000000018be0f548 UIKit`-[UIRuntimeConnection initWithCoder:] + 136 
    frame #37: 0x000000018bf5da50 UIKit`UINibDecoderDecodeObjectForValue + 680 
    frame #38: 0x000000018bf5dbc8 UIKit`UINibDecoderDecodeObjectForValue + 1056 
    frame #39: 0x000000018bf5d790 UIKit`-[UINibDecoder decodeObjectForKey:] + 104 
    frame #40: 0x000000018be0e8bc UIKit`-[UINib instantiateWithOwner:options:] + 1168 
    frame #41: 0x000000018be10d40 UIKit`-[NSBundle(UINSBundleAdditions) loadNibNamed:owner:options:] + 224 
    * frame #42: 0x00000001000b9698 Keyboard`-[KeyboardViewController arrangeXib](self=0x0000000121e058e0, _cmd="arrangeXib") at KeyboardViewController.m:346 
    frame #43: 0x00000001000bbbc4 Keyboard`-[KeyboardViewController viewDidLoad](self=0x0000000121e058e0, _cmd="viewDidLoad") at KeyboardViewController.m:514 
    frame #44: 0x000000018b907ec0 UIKit`-[UIViewController loadViewIfRequired] + 1036 
    frame #45: 0x000000018b907a9c UIKit`-[UIViewController view] + 28 
    frame #46: 0x000000018c1de298 UIKit`-[_UIViewServiceViewControllerOperator __createViewController:withContextToken:fbsDisplays:appearanceSerializedRepresentations:legacyAppearance:traitCollection:initialInterfaceOrientation:hostAccessibilityServerPort:canShowTextServices:replyHandler:] + 4172 
    frame #47: 0x00000001857dce80 CoreFoundation`__invoking___ + 144 
    frame #48: 0x00000001856d22c4 CoreFoundation`-[NSInvocation invoke] + 292 
    frame #49: 0x00000001856d6e9c CoreFoundation`-[NSInvocation invokeWithTarget:] + 60 
    frame #50: 0x000000018c2e0ce4 UIKit`-[_UIViewServiceImplicitAnimationDecodingProxy forwardInvocation:] + 108 
    frame #51: 0x00000001857dad54 CoreFoundation`___forwarding___ + 404 
    frame #52: 0x00000001856d6d4c CoreFoundation`_CF_forwarding_prep_0 + 92 
    frame #53: 0x00000001857dce80 CoreFoundation`__invoking___ + 144 
    frame #54: 0x00000001856d22c4 CoreFoundation`-[NSInvocation invoke] + 292 
    frame #55: 0x00000001856d6e9c CoreFoundation`-[NSInvocation invokeWithTarget:] + 60 
    frame #56: 0x000000018c232048 UIKit`-[_UIQueueingProxy forwardInvocation:] + 372 
    frame #57: 0x00000001857dad54 CoreFoundation`___forwarding___ + 404 
    frame #58: 0x00000001856d6d4c CoreFoundation`_CF_forwarding_prep_0 + 92 
    frame #59: 0x00000001857dce80 CoreFoundation`__invoking___ + 144 
    frame #60: 0x00000001856d22c4 CoreFoundation`-[NSInvocation invoke] + 292 
    frame #61: 0x00000001856d6e9c CoreFoundation`-[NSInvocation invokeWithTarget:] + 60 
    frame #62: 0x00000001857dad54 CoreFoundation`___forwarding___ + 404 
    frame #63: 0x00000001856d6d4c CoreFoundation`_CF_forwarding_prep_0 + 92 
    frame #64: 0x00000001857dce80 CoreFoundation`__invoking___ + 144 
    frame #65: 0x00000001856d22c4 CoreFoundation`-[NSInvocation invoke] + 292 
    frame #66: 0x000000018737f884 FrontBoardServices`__FBSSERIALQUEUE_IS_CALLING_OUT_TO_A_BLOCK__ + 36 
    frame #67: 0x000000018737f6f0 FrontBoardServices`-[FBSSerialQueue _performNext] + 176 
    frame #68: 0x000000018737faa0 FrontBoardServices`-[FBSSerialQueue _performNextFromRunLoopSource] + 56 
    frame #69: 0x000000018578542c CoreFoundation`__CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 24 
    frame #70: 0x0000000185784d9c CoreFoundation`__CFRunLoopDoSources0 + 540 
    frame #71: 0x00000001857829a8 CoreFoundation`__CFRunLoopRun + 744 
    frame #72: 0x00000001856b2da4 CoreFoundation`CFRunLoopRunSpecific + 424 
    frame #73: 0x000000018711c074 GraphicsServices`GSEventRunModal + 100 
    frame #74: 0x000000018b96d058 UIKit`UIApplicationMain + 208 
    frame #75: 0x00000001848d7cd0 libxpc.dylib`_xpc_objc_main + 788 
    frame #76: 0x00000001848d9984 libxpc.dylib`xpc_main + 200 
    frame #77: 0x00000001863dad90 Foundation`-[NSXPCListener resume] + 180 
    frame #78: 0x000000018e15712c PlugInKit`-[PKService run] + 752 
    frame #79: 0x000000018e156cf0 PlugInKit`+[PKService main] + 56 
    frame #80: 0x000000018e157150 PlugInKit`+[PKService _defaultRun:arguments:] + 20 
    frame #81: 0x00000001863c0ba4 Foundation`NSExtensionMain + 64 
    frame #82: 0x00000001846c159c libdyld.dylib`start + 4 

更新2: 我敢肯定它是與內存問題...如果我在單元格中顯示只是一個彩色背景它的工作原理好。現在,如果我顯示imgages,如果它們小於10-15有沒有問題,但如果我有更多的將與不同的錯誤崩潰,像那些高於或:

libz.1.dylib`inflate: 
libsystem_kernel.dylib`_kernelrpc_mach_vm_deallocate_trap: 

起初,我有一個滾動視圖和我認爲問題在於它直接加載了所有圖像,所以我嘗試使用collectionView,但結果相同。我試圖用相同的結果加載圖像3種不同的方式:

UIImage imageWithContentsOfFile: 
UIImage imageWithData: 
UIImage imageNamed: 
+0

嘗試創建[異常斷點](https://stackoverflow.com/questions/17802662/exception-breakpoint-in-xcode)並重現崩潰;你可能會得到你的代碼崩潰的地方。 – the4kman

+0

@ the4kman嘗試並獲得它加載nib文件的位置。我將用代碼 – emiliomarin

+0

更新問題你能告訴我們什麼是實際例外嗎? –

回答

0

明白了它的工作。這個問題與我的預期一致。對於我讀的第三方鍵盤,蘋果將內存限制在30Mb。

Memory limits for running app extensions are significantly lower than the memory limits imposed on a foreground app. On both platforms, the system may aggressively terminate extensions because users want to return to their main goal in the host app. Some extensions may have lower memory limits than others: For example, widgets must be especially efficient because users are likely to have several widgets open at the same time.

我不得不PNG圖像周圍60KB每個但它有這使得每個圖像周圍5-6Mb在內存中,當我裝他們的24bit色彩位圖。我的解決方案是使用jpeg圖像,我不能使用透明背景,但至少我會有一個工作的應用程序。