simonbs / Runestone

📝 Performant plain text editor for iOS with syntax highlighting, line numbers, invisible characters and much more.
MIT License
2.62k stars 145 forks source link

Crash due to Modifications to the layout engine from background thread. #334

Closed esahmed21 closed 4 months ago

esahmed21 commented 6 months ago

What happened?

Hi 👋

There is a crash happens when the app is in the background while editing files. Not 100% repro but it happens quite often specially when in debug mode it's so much easier to reproduce..

What are the steps to reproduce?

You can try this some more times.

I'm attaching some of the crash reports, but it has so other occurences.

Stacktrace 1 ``` Fatal Exception: NSInternalInconsistencyException 0 CoreFoundation 0xec69c __exceptionPreprocess 1 libobjc.A.dylib 0x2bc80 objc_exception_throw 2 CoreAutoLayout 0x56c8 NSISSparseVectorAddTermWithPlaceValueCoefficientStartingIndex 3 CoreAutoLayout 0xbadc -[NSISEngine _optimizeWithoutRebuilding] 4 CoreAutoLayout 0xb7f0 -[NSISEngine optimize] 5 CoreAutoLayout 0xb57c -[NSISEngine performPendingChangeNotifications] 6 UIKitCore 0x32c4c -[UIView(CALayerDelegate) layoutSublayersOfLayer:] 7 QuartzCore 0x66aa8 CA::Layer::layout_if_needed(CA::Transaction*) 8 QuartzCore 0x66630 CA::Layer::layout_and_display_if_needed(CA::Transaction*) 9 QuartzCore 0x6cb60 CA::Context::commit_transaction(CA::Transaction*, double, double*) 10 QuartzCore 0x65e3c CA::Transaction::commit() 11 QuartzCore 0x24c1dc CAImageProviderThread(unsigned int*, bool) 12 libdispatch.dylib 0x4300 _dispatch_client_callout 13 libdispatch.dylib 0x77b8 _dispatch_continuation_pop 14 libdispatch.dylib 0x6dd4 _dispatch_async_redirect_invoke 15 libdispatch.dylib 0x15be4 _dispatch_root_queue_drain 16 libdispatch.dylib 0x163ec _dispatch_worker_thread2 17 libsystem_pthread.dylib 0x1928 _pthread_wqthread 18 libsystem_pthread.dylib 0x1a04 start_wqthread com.apple.main-thread 0 libicucore.A.dylib 0xb6598 uhash_compareUnicodeString + 116 1 libicucore.A.dylib 0xdeaf4 icu::UVector::indexOf(UElement, int, signed char) const + 72 2 libicucore.A.dylib 0xdeaf4 icu::UVector::indexOf(UElement, int, signed char) const + 72 3 libicucore.A.dylib 0x11238 icu::FilteredBreakIteratorBuilder::FilteredBreakIteratorBuilder() + 876 4 libicucore.A.dylib 0x11120 icu::FilteredBreakIteratorBuilder::FilteredBreakIteratorBuilder() + 596 5 libicucore.A.dylib 0x11934 icu::FilteredBreakIteratorBuilder::createInstance(icu::Locale const&, UErrorCode&) + 76 6 libicucore.A.dylib 0x3174 icu::BreakIterator::makeInstance(icu::Locale const&, int, UErrorCode&) + 952 7 libicucore.A.dylib 0x624a0 ubrk_open + 300 8 CoreNLP 0x6550 CoreNLP::ICUTextBreakWithBuiltInRules::ICUTextBreakWithBuiltInRules(CoreNLP::TaggerContext const&, UBreakIteratorType, char const*) + 100 9 CoreNLP 0x6718 CoreNLP::SentenceTagger::resetICUSentenceBreak(__CFLocale const*) + 172 10 CoreNLP 0x6638 CoreNLP::SentenceTagger::SentenceTagger(CoreNLP::TaggerContext&) + 80 11 CoreNLP 0x65c4 CoreNLP::SentenceTagger::createSentenceTagger(CoreNLP::TaggerContext&) + 56 12 CoreNLP 0x589c NLTokenizerCreate + 148 13 CoreNLP 0x5764 NLStringTokenizerCreate + 372 14 CoreFoundation 0xf122c CFStringTokenizerCreate + 144 15 UIKitCore 0xd21000 -[UITextInputStringTokenizer _closestTokenSubrangeForPosition:granularity:downstream:] + 592 16 UIKitCore 0xd2128c -[UITextInputStringTokenizer positionFromPosition:toBoundary:inDirection:] + 84 17 Runic 0x46790 @objc TextInputStringTokenizer.position(from:toBoundary:inDirection:) + 41 (TextInputStringTokenizer.swift:41) 18 UIKitCore 0xcb147c -[UIKBRTIPartner _queryUIKitDocumentRequest:completion:] + 648 19 UIKitCore 0xcafdb8 -[UIKBRTIPartner _queryDocumentRequest:completion:] + 120 20 UIKitCore 0xca86bc -[UIKBRTIPartner _updateRTIStateWithCompletion:] + 576 21 UIKitCore 0xca834c -[UIKBRTIPartner updateStateWithCompletion:updateTraits:] + 144 22 UIKitCore 0xca490c -[UIKBRTIPartner documentStateChanged:] + 176 23 UIKitCore 0xc23d7c __37-[UIKeyboardImpl selectionDidChange:]_block_invoke_3 + 52 24 UIKitCore 0x310220 -[UIKeyboardTaskEntry execute:] + 208 25 UIKitCore 0x310104 -[UIKeyboardTaskQueue continueExecutionOnMainThread] + 324 26 UIKitCore 0xc6c0e0 -[UIKeyboardTaskQueue addTask:] + 96 27 UIKitCore 0xc23a3c -[UIKeyboardImpl selectionDidChange:] + 728 28 UIKitCore 0x1073010 -[UITextInteractionInputDelegate selectionDidChange:] + 128 29 Runic 0x4b118 TextInputView.layoutSubviews() + 696 (TextInputView.swift:696) 30 Runic 0x4b310 @objc TextInputView.layoutSubviews() + 4442092304 (:4442092304) 31 UIKitCore 0x3297c -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 1528 32 QuartzCore 0x66aa8 CA::Layer::layout_if_needed(CA::Transaction*) + 500 33 QuartzCore 0x66630 CA::Layer::layout_and_display_if_needed(CA::Transaction*) + 144 34 QuartzCore 0x6cb60 CA::Context::commit_transaction(CA::Transaction*, double, double*) + 464 35 QuartzCore 0x65e3c CA::Transaction::commit() + 648 36 QuartzCore 0x65ae4 CA::Transaction::flush_as_runloop_observer(bool) + 88 37 UIKitCore 0xaaccc _UIApplicationFlushCATransaction + 52 38 UIKitCore 0xaa7e4 _UIUpdateSequenceRun + 84 39 UIKitCore 0xa9ed4 schedulerStepScheduledMainSection + 144 40 UIKitCore 0xa9f90 runloopSourceCallback + 92 41 CoreFoundation 0x3712c __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 28 42 CoreFoundation 0x363a8 __CFRunLoopDoSource0 + 176 43 CoreFoundation 0x34b5c __CFRunLoopDoSources0 + 244 44 CoreFoundation 0x33898 __CFRunLoopRun + 828 45 CoreFoundation 0x33478 CFRunLoopRunSpecific + 608 46 GraphicsServices 0x34f8 GSEventRunModal + 164 47 UIKitCore 0x22c62c -[UIApplication _run] + 888 48 UIKitCore 0x22bc68 UIApplicationMain + 340 49 GitHub 0x7660 main + 18 (AppDelegate.swift:18) 50 ??? 0x1c3552dcc (Missing) ```
Stacktrace 2 ``` Fatal Exception: NSInternalInconsistencyException 0 CoreFoundation 0xec69c __exceptionPreprocess 1 libobjc.A.dylib 0x2bc80 objc_exception_throw 2 CoreAutoLayout 0x56c8 NSISSparseVectorAddTermWithPlaceValueCoefficientStartingIndex 3 CoreAutoLayout 0xbadc -[NSISEngine _optimizeWithoutRebuilding] 4 CoreAutoLayout 0xb7f0 -[NSISEngine optimize] 5 CoreAutoLayout 0xb57c -[NSISEngine performPendingChangeNotifications] 6 UIKitCore 0x34220 -[UIView(Hierarchy) layoutSubviews] 7 UIKitCore 0x3297c -[UIView(CALayerDelegate) layoutSublayersOfLayer:] 8 QuartzCore 0x66aa8 CA::Layer::layout_if_needed(CA::Transaction*) 9 QuartzCore 0x66630 CA::Layer::layout_and_display_if_needed(CA::Transaction*) 10 QuartzCore 0x6cb60 CA::Context::commit_transaction(CA::Transaction*, double, double*) 11 QuartzCore 0x65e3c CA::Transaction::commit() 12 QuartzCore 0x24c1dc CAImageProviderThread(unsigned int*, bool) 13 libdispatch.dylib 0x4300 _dispatch_client_callout 14 libdispatch.dylib 0x77b8 _dispatch_continuation_pop 15 libdispatch.dylib 0x6dd4 _dispatch_async_redirect_invoke 16 libdispatch.dylib 0x15be4 _dispatch_root_queue_drain 17 libdispatch.dylib 0x163ec _dispatch_worker_thread2 18 libsystem_pthread.dylib 0x1928 _pthread_wqthread 19 libsystem_pthread.dylib 0x1a04 start_wqthread com.apple.main-thread 0 QuartzCore 0xdf500 CA::Layer::sublayers() + 406 1 UIKitCore 0x70fe8 -[UIView _recursivelySetHiddenForBackdropMaskViews:] + 236 2 UIKitCore 0x7103c -[UIView _recursivelySetHiddenForBackdropMaskViews:] + 320 3 UIKitCore 0x7103c -[UIView _recursivelySetHiddenForBackdropMaskViews:] + 320 4 UIKitCore 0x7103c -[UIView _recursivelySetHiddenForBackdropMaskViews:] + 320 5 UIKitCore 0x7103c -[UIView _recursivelySetHiddenForBackdropMaskViews:] + 320 6 UIKitCore 0x7103c -[UIView _recursivelySetHiddenForBackdropMaskViews:] + 320 7 UIKitCore 0x7103c -[UIView _recursivelySetHiddenForBackdropMaskViews:] + 320 8 UIKitCore 0x7103c -[UIView _recursivelySetHiddenForBackdropMaskViews:] + 320 9 UIKitCore 0x7103c -[UIView _recursivelySetHiddenForBackdropMaskViews:] + 320 10 UIKitCore 0x7103c -[UIView _recursivelySetHiddenForBackdropMaskViews:] + 320 11 UIKitCore 0x7103c -[UIView _recursivelySetHiddenForBackdropMaskViews:] + 320 12 UIKitCore 0x70d88 -[UIView(Rendering) setHidden:] + 336 13 UIKit 0x14471c -[UIViewAccessibility setHidden:] + 152 14 UIKitCore 0x1ab3c4 -[UIInputWindowController updateInputAssistantViewForInputViewSet:] + 656 15 UIKit 0x83178 -[UIInputWindowControllerAccessibility updateInputAssistantViewForInputViewSet:] + 84 16 UIKitCore 0xbe761c -[UIInputWindowController updateForKeyplaneChangeWithContext:] + 216 17 UIKitCore 0xbf32b4 -[UIInputWindowControllerHostingItem updateForKeyplaneChangeWithContext:] + 80 18 UIKitCore 0xc9d52c -[_UIRemoteKeyboards performOnControllers:] + 256 19 UIKitCore 0xbe4088 -[UIInputSetHostView _didChangeKeyplaneWithContext:] + 140 20 UIKitCore 0x313dc8 -[UIView(UIKB_UIViewExtras) _didChangeKeyplaneWithContext:] + 56 21 UIKitCore 0xaae0f0 -[_UIKBCompatInputView _didChangeKeyplaneWithContext:] + 80 22 UIKitCore 0x313dc8 -[UIView(UIKB_UIViewExtras) _didChangeKeyplaneWithContext:] + 56 23 UIKitCore 0xbfdbf8 -[UIKeyboard _didChangeKeyplaneWithContext:] + 300 24 UIKitCore 0x313dc8 -[UIView(UIKB_UIViewExtras) _didChangeKeyplaneWithContext:] + 56 25 UIKitCore 0x312c60 -[UIKeyboardImpl _didChangeKeyplaneWithContext:] + 500 26 UIKitCore 0x312a48 -[UIKeyboardImpl updateAssistantView] + 88 27 UIKitCore 0x311d80 -[UIKeyboardImpl clearInputWithCandidatesCleared:] + 392 28 UIKitCore 0x3110b4 -[UIKeyboardImpl updateForChangedSelectionWithExecutionContext:] + 280 29 UIKitCore 0xc232a4 __43-[UIKeyboardImpl updateForChangedSelection]_block_invoke + 52 30 UIKitCore 0x310220 -[UIKeyboardTaskEntry execute:] + 208 31 UIKitCore 0x310104 -[UIKeyboardTaskQueue continueExecutionOnMainThread] + 324 32 UIKitCore 0xc6c430 -[UIKeyboardTaskQueue waitUntilTaskIsFinished:] + 140 33 UIKitCore 0x30fed8 -[UIKeyboardTaskQueue performSingleTask:] + 112 34 UIKitCore 0xc2325c -[UIKeyboardImpl updateForChangedSelection] + 116 35 UIKitCore 0xc23914 -[UIKeyboardImpl selectionDidChange:] + 432 36 UIKitCore 0x1073010 -[UITextInteractionInputDelegate selectionDidChange:] + 128 37 Runic 0x4b118 TextInputView.layoutSubviews() + 696 (TextInputView.swift:696) 38 Runic 0x4b310 @objc TextInputView.layoutSubviews() + 4457509648 (:4457509648) 39 UIKitCore 0x3297c -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 1528 40 QuartzCore 0x66aa8 CA::Layer::layout_if_needed(CA::Transaction*) + 500 41 QuartzCore 0x66630 CA::Layer::layout_and_display_if_needed(CA::Transaction*) + 144 42 QuartzCore 0x6cb60 CA::Context::commit_transaction(CA::Transaction*, double, double*) + 464 43 QuartzCore 0x65e3c CA::Transaction::commit() + 648 44 QuartzCore 0x65ae4 CA::Transaction::flush_as_runloop_observer(bool) + 88 45 CoreFoundation 0x3583c __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 36 46 CoreFoundation 0x34244 __CFRunLoopDoObservers + 548 47 CoreFoundation 0x33960 __CFRunLoopRun + 1028 48 CoreFoundation 0x33478 CFRunLoopRunSpecific + 608 49 GraphicsServices 0x34f8 GSEventRunModal + 164 50 UIKitCore 0x22c62c -[UIApplication _run] + 888 51 UIKitCore 0x22bc68 UIApplicationMain + 340 52 GitHub 0x66b8 main + 18 (AppDelegate.swift:18) 53 ??? 0x1c9272dcc (Missing) ```

What is the expected behavior?

No crash

simonbs commented 6 months ago

@esahmed21 Which app is this from? Can you share a sample file to reproduce this issue?

simonbs commented 4 months ago

Closing due to inactivity.