-
-
Notifications
You must be signed in to change notification settings - Fork 186
Open
Labels
bugSomething isn't workingSomething isn't working
Description
What happened?
When a user enters search content, if the input is very short (e.g., 1 or 2 characters), it results in an enormous number of search results, causing excessively high CPU usage. This leads to the app freezing for several seconds or even tens of seconds.
The edited file is only a few dozen KB, but there may be 100,000+ hits in the search results. Instruments show the call stack.
2.90 s 99.9% 0 s UITextSearchingHelper.decorate(foundTextRange:document:usingStyle:)
2.89 s 99.6% 0 s TextView.highlightedRanges.modify
2.89 s 99.6% 0 s TextView.highlightedRanges.setter
2.89 s 99.6% 0 s TextInputView.highlightedRanges.setter
2.69 s 92.7% 0 s HighlightService.highlightedRanges.setter
2.69 s 92.7% 0 s HighlightService.highlightedRanges.didset
2.69 s 92.7% 0 s HighlightService.invalidateHighlightedRangeFragments()
2.68 s 92.2% 0 s HighlightService.createHighlightedRangeFragmentsPerLine()
1.76 s 60.6% 1.00 ms LineManager.lines(in:)
1.74 s 59.9% 0 s LineManager.line(containingCharacterAt:)
1.71 s 58.9% 5.00 ms RedBlackTree.node(containingLocation:)
885.00 ms 30.5% 26.00 ms RedBlackTree.node<A>(containingLocation:minimumValue:valueKeyPath:totalValueKeyPath:)
However, I tested the same file with Runestone.app and it seems that no similar issues occurred. Is it because the open-source version itself is not optimized in this regard, or is there a problem with the way I'm using it?
Thank you.
What are the steps to reproduce?
Use the search tool and enter only one character.
What is the expected behavior?
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working