stefanceriu / SCXcodeMiniMap

Sublime Text like Minimap for Xcode
GNU General Public License v3.0
1.03k stars 91 forks source link

Crashes Xcode 7 when using autocomplete #71

Open virusman opened 8 years ago

virusman commented 8 years ago

It appears that this bug described here is caused by SCXcodeMiniMap: https://github.com/FuzzyAutocomplete/FuzzyAutocompletePlugin/issues/92 Removing SCXcodeMiniMap fixes the issue, as well as installing SCXcodeMiniMap without FuzzyAutocomplete casues Xcode 7 to crash again.

ghost commented 8 years ago

Is alsow reproducable in Xcode 7.1 beta 1 removing the plugin solved this issue for me.

https://forums.developer.apple.com/message/62713#62713

stefanceriu commented 8 years ago

Looking at that crash report there is no mention of the minimap or any of the methods involved in getting it to work. I have been running both of them in parallel for the last couple of day but, unfortunately, I wasn't able to reproduce the crash. Either way, it looks like the minimap serves in finding unexpected behavior in the fuzzy autocomplete plugin or even Xcode itself easier and not the other way around.

designatednerd commented 8 years ago

This is definitely happening on my end in 7.0 and 7.1b2 - removing plugins one by one (and I'd removed fuzzy autocomplete days ago as the most obvious possible cause), SCXcodeMiniMap is definitely the culprit.

You're quite correct that the stack trace doesn't mention SCXcodeMiniMap, but it's possible an underlying implementation detail of one of the DVT* classes has changed, and is causing SCXMM to exhibit different behavior. My instinct is something's reloading way too often as the user types, but I have nothing to back that up other than watching behavior over 80+ crashes. :stuck_out_tongue_closed_eyes:

Here's an example stack trace of the crashed thread - hope it helps you figure out what might be happening!

Exception Type:        EXC_CRASH (SIGABRT)
Exception Codes:       0x0000000000000000, 0x0000000000000000

Application Specific Information:
ProductBuildVersion: 7B75
UNCAUGHT EXCEPTION (NSRangeException): NSMutableRLEArray objectAtIndex:effectiveRange:runIndex:: Out of bounds
UserInfo: (null)
Hints: None
Backtrace:
  0  0x00007fff9274a024 __exceptionPreprocess (in CoreFoundation)
  1  0x0000000107f77c94 DVTFailureHintExceptionPreprocessor (in DVTFoundation)
  2  0x00007fff946d976e objc_exception_throw (in libobjc.A.dylib)
  3  0x00007fff92749eed +[NSException raise:format:] (in CoreFoundation)
  4  0x00007fff89de02f8 -[NSRLEArray objectAtIndex:effectiveRange:runIndex:] (in Foundation)
  5  0x00007fff89de00ab -[NSConcreteMutableAttributedString attribute:atIndex:longestEffectiveRange:inRange:] (in Foundation)
  6  0x00000001085e5873 -[DVTTextStorage(DVTTextStorageMRR) attribute:atIndex:longestEffectiveRange:inRange:] (in DVTKit)
  7  0x00007fff973ffef0 -[NSLayoutManager(NSPrivate) _drawBackgroundForGlyphRange:atPoint:] (in UIFoundation)
  8  0x000000010846a477 -[DVTLayoutManager drawBackgroundForGlyphRange:atPoint:] (in DVTKit)
  9  0x00007fff8b7e26b5 -[NSTextView drawRect:] (in AppKit)
 10  0x0000000108469100 -[DVTCompletingTextView drawRect:] (in DVTKit)
 11  0x0000000108468da0 -[DVTSourceTextView drawRect:] (in DVTKit)
 12  0x00007fff8b79c749 -[NSView(NSInternal) _recursive:displayRectIgnoringOpacity:inGraphicsContext:CGContext:topView:shouldChangeFontReferenceColor:] (in AppKit)
 13  0x00007fff8b79c168 __46-[NSView(NSLayerKitGlue) drawLayer:inContext:]_block_invoke (in AppKit)
 14  0x00007fff8b79be11 -[NSView(NSLayerKitGlue) _drawViewBackingLayer:inContext:drawingHandler:] (in AppKit)
 15  0x00007fff8b79b493 -[NSView(NSLayerKitGlue) drawLayer:inContext:] (in AppKit)
 16  0x00007fff8ba19c42 -[NSTextView drawLayer:inContext:] (in AppKit)
 17  0x00007fff8a47b3c7 CABackingStoreUpdate_ (in QuartzCore)
 18  0x00007fff8a47a6d7 ___ZN2CA5Layer8display_Ev_block_invoke (in QuartzCore)
 19  0x00007fff8a47a694 x_blame_allocations (in QuartzCore)
 20  0x00007fff8a46e43c CA::Layer::display_() (in QuartzCore)
 21  0x00007fff8b70742b _NSBackingLayerDisplay (in AppKit)
 22  0x00007fff8b704026 -[_NSViewBackingLayer display] (in AppKit)
 23  0x00007fff8ba19b85 -[_NSTextViewBackingLayer display] (in AppKit)
 24  0x00007fff8a46c7fd CA::Layer::display_if_needed(CA::Transaction*) (in QuartzCore)
 25  0x00007fff8a46be81 CA::Layer::layout_and_display_if_needed(CA::Transaction*) (in QuartzCore)
 26  0x00007fff8a46b612 CA::Context::commit_transaction(CA::Transaction*) (in QuartzCore)
 27  0x00007fff8a46b3ae CA::Transaction::commit() (in QuartzCore)
 28  0x00007fff8b7749d6 -[NSWindow _setFrameCommon:display:stashSize:] (in AppKit)
 29  0x000000010862aaad -[DVTTextCompletionListWindowController _updateCurrentDisplayState] (in DVTKit)
 30  0x0000000108627c83 __82-[DVTTextCompletionListWindowController showWindowForTextFrame:explicitAnimation:]_block_invoke (in DVTKit)
 31  0x0000000107f8a014 __95-[NSObject(DVTObservingConvenience) _dvt_newObserverForKeyPath:options:owner:withHandlerBlock:]_block_invoke (in DVTFoundation)
 32  0x0000000107f892d6 __73-[DVTObservingBlockToken observeValueForKeyPath:ofObject:change:context:]_block_invoke183 (in DVTFoundation)
 33  0x0000000107ef2867 DVTInvokeWithStrongOwnership (in DVTFoundation)
 34  0x0000000107d5801f -[DVTObservingBlockToken observeValueForKeyPath:ofObject:change:context:] (in DVTFoundation)
 35  0x00007fff89de81c3 NSKeyValueNotifyObserver (in Foundation)
 36  0x00007fff89df4e38 NSKeyValueDidChange (in Foundation)
 37  0x00007fff89dada4d -[NSObject(NSKeyValueObserverNotification) didChangeValueForKey:] (in Foundation)
 38  0x00000001085539f3 -[DVTTextCompletionSession _setFilteringPrefix:forceFilter:] (in DVTKit)
 39  0x00000001084960b2 -[DVTTextCompletionSession setCursorLocation:] (in DVTKit)
 40  0x0000000108434599 -[DVTTextCompletionController textViewSelectionChanging] (in DVTKit)
 41  0x00000001084344c2 -[DVTCompletingTextView setSelectedRanges:affinity:stillSelecting:] (in DVTKit)
 42  0x000000010845acc7 -[DVTSourceTextView setSelectedRanges:affinity:stillSelecting:] (in DVTKit)
 43  0x00000001084343b2 -[DVTCompletingTextView setSelectedRange:] (in DVTKit)
 44  0x000000010845ab54 -[DVTSourceTextView setSelectedRange:] (in DVTKit)
 45  0x00007fff89f01174 _NSSetRangeValueAndNotify (in Foundation)
 46  0x00007fff973473af -[NSLayoutManager textStorage:edited:range:changeInLength:invalidatedRange:] (in UIFoundation)
 47  0x00000001085bcaba -[DVTFoldingLayoutManager textStorage:edited:range:changeInLength:invalidatedRange:] (in DVTKit)
 48  0x00007fff97369291 -[NSTextStorage _notifyEdited:range:changeInLength:invalidatedRange:] (in UIFoundation)
 49  0x00007fff97368d93 -[NSTextStorage processEditing] (in UIFoundation)
 50  0x000000010843f46c -[DVTTextStorage processEditing] (in DVTKit)
 51  0x00007fff97368a61 -[NSTextStorage endEditing] (in UIFoundation)
 52  0x000000010843f12e -[DVTTextStorage endEditing] (in DVTKit)
 53  0x000000010857cef2 -[DVTTextStorage replaceCharactersInRange:withString:evenIfNotEditable:] (in DVTKit)
 54  0x00007fff8ba4daf1 -[NSTextView(NSPrivate) _userReplaceRange:withString:] (in AppKit)
 55  0x00007fff8ba4d48b _NSDoUserReplaceForCharRange (in AppKit)
 56  0x00007fff8ba4d2a6 _NSDoUserDeleteForCharRange (in AppKit)
 57  0x00007fff8bad1c36 -[NSTextView(NSKeyBindingCommands) deleteBackward:] (in AppKit)
 58  0x000000010868a809 -[DVTCompletingTextView deleteBackward:] (in DVTKit)
 59  0x00000001084a09b2 -[DVTSourceTextView deleteBackward:] (in DVTKit)
 60  0x00007fff8b99cef1 -[NSTextView doCommandBySelector:] (in AppKit)
 61  0x000000010849cc64 -[DVTCompletingTextView doCommandBySelector:] (in DVTKit)
 62  0x00007fff8b99ce01 -[NSTextInputContext(NSInputContext_WithCompletion) doCommandBySelector:completionHandler:] (in AppKit)
 63  0x00007fff8b982c23 -[NSKeyBindingManager(NSKeyBindingManager_MultiClients) interpretEventAsCommand:forClient:] (in AppKit)
 64  0x00007fff8bf49272 __61-[NSTextInputContext _handleEvent:options:completionHandler:]_block_invoke972 (in AppKit)
 65  0x00007fff8b984bff -[NSTextInputContext(NSInputContext_WithCompletion) hasMarkedTextWithCompletionHandler:] (in AppKit)
 66  0x00007fff8b99cd03 __61-[NSTextInputContext _handleEvent:options:completionHandler:]_block_invoke_3 (in AppKit)
 67  0x00007fff8b995ed8 -[NSTextInputContext tryHandleEvent_HasMarkedText_withDispatchCondition:dispatchWork:continuation:] (in AppKit)
 68  0x00007fff8bf49074 __61-[NSTextInputContext _handleEvent:options:completionHandler:]_block_invoke960 (in AppKit)
 69  0x00007fff974e4d4f __TSMProcessRawKeyEventWithOptionsAndCompletionHandler_block_invoke_5 (in HIToolbox)
 70  0x00007fff974e3c45 ___ZL23DispatchEventToHandlersP14EventTargetRecP14OpaqueEventRefP14HandlerCallRec_block_invoke (in HIToolbox)
 71  0x00007fff8b985606 __55-[NSTextInputContext handleTSMEvent:completionHandler:]_block_invoke174 (in AppKit)
 72  0x00007fff8b984bff -[NSTextInputContext(NSInputContext_WithCompletion) hasMarkedTextWithCompletionHandler:] (in AppKit)
 73  0x00007fff8b984ba0 __55-[NSTextInputContext handleTSMEvent:completionHandler:]_block_invoke_2 (in AppKit)
 74  0x00007fff8b984b18 -[NSTextInputContext tryHandleTSMEvent_HasMarkedText_withDispatchCondition:dispatchWork:continuation:] (in AppKit)
 75  0x00007fff8b9847d5 -[NSTextInputContext handleTSMEvent:completionHandler:] (in AppKit)
 76  0x00007fff8b983b2e _NSTSMEventHandler (in AppKit)
 77  0x00007fff9747db6c DispatchEventToHandlers(EventTargetRec*, OpaqueEventRef*, HandlerCallRec*) (in HIToolbox)
 78  0x00007fff9747cfae SendEventToEventTargetInternal(OpaqueEventRef*, OpaqueEventTargetRef*, HandlerCallRec*) (in HIToolbox)
 79  0x00007fff9747ce22 SendEventToEventTargetWithOptions (in HIToolbox)
 80  0x00007fff974e126c SendTSMEvent_WithCompletionHandler (in HIToolbox)
 81  0x00007fff974e176c __SendUnicodeTextAEToUnicodeDoc_WithCompletionHandler_block_invoke (in HIToolbox)
 82  0x00007fff974e15a6 __SendFilterTextEvent_WithCompletionHandler_block_invoke (in HIToolbox)
 83  0x00007fff974e12c0 SendTSMEvent_WithCompletionHandler (in HIToolbox)
 84  0x00007fff974e108f SendFilterTextEvent_WithCompletionHandler (in HIToolbox)
 85  0x00007fff974e0d51 SendUnicodeTextAEToUnicodeDoc_WithCompletionHandler (in HIToolbox)
 86  0x00007fff974e0ae9 __utDeliverTSMEvent_WithCompletionHandler_block_invoke_2 (in HIToolbox)
 87  0x00007fff974e0988 __utDeliverTSMEvent_WithCompletionHandler_block_invoke (in HIToolbox)
 88  0x00007fff974e07cd TSMKeyEvent_WithCompletionHandler (in HIToolbox)
 89  0x00007fff974e04d0 __TSMProcessRawKeyEventWithOptionsAndCompletionHandler_block_invoke_4 (in HIToolbox)
 90  0x00007fff974e0386 __TSMProcessRawKeyEventWithOptionsAndCompletionHandler_block_invoke_3 (in HIToolbox)
 91  0x00007fff974e0112 __TSMProcessRawKeyEventWithOptionsAndCompletionHandler_block_invoke_2 (in HIToolbox)
 92  0x00007fff974dff25 __TSMProcessRawKeyEventWithOptionsAndCompletionHandler_block_invoke (in HIToolbox)
 93  0x00007fff974c476f TSMProcessRawKeyEventWithOptionsAndCompletionHandler (in HIToolbox)
 94  0x00007fff8bf48e86 __61-[NSTextInputContext _handleEvent:options:completionHandler:]_block_invoke949 (in AppKit)
 95  0x00007fff8b982352 -[NSTextInputContext tryTSMProcessRawKeyEvent:dispatchCondition:setupForDispatch:furtherCondition:dispatchWork:continuation:] (in AppKit)
 96  0x00007fff8b982085 -[NSTextInputContext _handleEvent:options:completionHandler:] (in AppKit)
 97  0x00007fff8b981b4e -[NSTextInputContext handleEvent:] (in AppKit)
 98  0x00007fff8b981a54 -[NSView interpretKeyEvents:] (in AppKit)
 99  0x00007fff8b98186a -[NSTextView keyDown:] (in AppKit)
100  0x00007fff8be710fb -[NSWindow _reallySendEvent:isDelayedEvent:] (in AppKit)
101  0x00007fff8b802c86 -[NSWindow sendEvent:] (in AppKit)
102  0x00000001093e53b6 -[IDEWorkspaceWindow sendEvent:] (in IDEKit)
103  0x00007fff8b7ff8b1 -[NSApplication sendEvent:] (in AppKit)
104  0x000000010919c205 -[IDEApplication sendEvent:] (in IDEKit)
105  0x00007fff8b728b68 -[NSApplication run] (in AppKit)
106  0x00007fff8b6a5244 NSApplicationMain (in AppKit)
107  0x00007fff8ac195c9 start (in libdyld.dylib)

abort() called

Application Specific Signatures:
NSRangeException
ccrsno1 commented 8 years ago

The crash is easy to reproduce. First, type some words when autocomplete appears, then just hit delete on keyboard several times, that's it. It crashes XCode7.1.

ccrsno1 commented 8 years ago

Hope that helps.

youssman commented 8 years ago

+1 @ccrsno1 ! This is the way to reproduce.

When I remove SCXcodeMiniMap I can't reproduce the crash ...

yangchao0033 commented 8 years ago

When I remove SCXcodeMiniMap crash about code autocomplete is gone. hope someOne can resolve it.

zcgong commented 8 years ago

+1 @ccrsno1 !

dzenbot commented 8 years ago

Same here. Hiding the MiniMap fixes it, but I miss it already :(

StephenGao commented 8 years ago

yes ,it crash a lot in Xcode 7. Hope somebody can fix it.

piniondna commented 8 years ago

I'm also getting this crash. It's consistently reproducible whenever I hit backspace during code complete. I've isolated the MiniMap plugin, and I still get the crash, so it definitely is the cause.

This sucks because I really like the MiniMap for code navigation. Hope this can be resolved soon.

stefanceriu commented 8 years ago

I've been running the 2 plugins side by side for the past couple of months and I've received zero crashes. That being said, I've got absolutely nothing to go on. If anybody manages to pin point it to a particular location please help me out and create a pull request or attach more details to this issue..

piniondna commented 8 years ago

I did a little testing and I think what might be going on is based on Xcode version. The crash I was getting was in Xcode 7.0.1 on Yosemite. I also don't think its a conflict with another plugin (FuzzyAutocomplete) since in my testing I can remove all plugins except SCXcodeMiniMap and still get the crash.

I tested it on a clean install of Xcode 7.2 on El Capitan and I was not seeing the same issue. However, I did get a crash upon first restarting Xcode with the SCXcodeMinimap plugin installed (attached file). I'm not sure if SCXcodeMiniMap is the cause, but its referenced in the crash report. After this initial crash, I didn't get any more crashing in the testing that I did. The only plugins I had installed were Alcatraz and SCXcodeMiniMap.

I'm not sure if this is still something that you are willing to track down and fix since its most likely only happening in older versions of Xcode, but for many of us on older code bases upgrading isn't an option (as much as I'd like to). At least I know that when I do upgrade it will be safe to run the MiniMap plugin.

I'm also including the crash under Xcode 7.0.1 in case there's anything useful in that.

Thanks for your work on this plugin... its a really nice feature addition to Xcode.

SCXcodeMiniMap-crash-report-xcode7.0.1.txt

SCXcodeMiniMap-crash-report.txt

stefanceriu commented 8 years ago

Right, thank you for the detailed description. I followed that second crash report and the the commit above should fix it.

As for the first one (7.0.1 on Yosemite), I'm a bit confused.. you said that you removed all other plugins while testing but I can see references to DVTTextCompletionSession(FuzzyAutocomplete) and DVTTextCompletionListWindowController(FuzzyAutocomplete) in the crash backtrace.

Can you have another look at it, please ? Maybe even try getting it to crash with only FuzzyAutocompletePlugin installed.

piniondna commented 8 years ago

ok, this time I made sure the plugins were completely removed. Before I was just removing the bundles.

This time the crash report looks to be a bit more isolated.

SCXcodeMiniMap-crash-report-xcode7.0.1-isolated.txt

stefanceriu commented 8 years ago

Perfect, thank you for looking into it. Now we're back to the original problem and we assume it's only happening on Yosemite. Can somebody please confirm if that is indeed the case ?

micnguyen commented 8 years ago

I can confirm that I'm getting crashes on Yosemite on XCode 7.2 w/ FuzzyAutoComplete installed. Tried using the latest version + latest pre-release. Have yet to try with El Capitan.

znafets commented 8 years ago

Still getting the crash on Yosemite, without any FuzzyAutoComplete plugin installed ... crash is gone when I uninstall SCXCodeMiniMap ... This seems to be relevant:

(NSInternalInconsistencyException): -[DVTLayoutManager 
_fillLayoutHoleForCharacterRange:desiredNumberOfLines:isSoft:] *** attempted layout while textStorage
 is editing.  It is not valid to cause the layoutManager to do layout while the textStorage is editing (i.e. the
 textStorage has been sent a beginEditing message without a matching endEditing.)