danielsaidi / RichTextKit

RichTextKit is a Swift SDK that helps you use rich text in Swift and SwiftUI.
MIT License
950 stars 126 forks source link

Investigate and possibly fix warnings about _UITextMagnifiedLoupeView #127

Open DominikBucher12 opened 10 months ago

DominikBucher12 commented 10 months ago

When selecting current position in the rich text editor, there is this warning:

Error: this application, or a library it uses, has passed an invalid numeric value (NaN, or not-a-number) to CoreGraphics API and this value is being ignored. Please fix this problem.

When adding CG_NUMERICS_SHOW_BACKTRACE Environment variable to the scheme, we can see that _UITextMagnifiedLoupeView which is Apples private API for Showing the magnified loop when changing caret position, causes this break in layoutSubviews.

I strongly believe we do nothing wrong and this is Apple bug

This is just a warning, but it causes some performance issues, the only thing we can do in here is either call with Apple and do some swizzling magic, or swizzle magically on our own to try fix this :D

@danielsaidi do we actually care or is this freezer? :D

Backtrace:
  <CGPathAddLineToPoint+88>
   <+[UIBezierPath _continuousRoundedRectBezierPath:withRoundedCorners:cornerRadii:segments:smoothPillShapes:]+1140>
    <+[UIBezierPath _continuousRoundedRectBezierPath:withRoundedCorners:cornerRadius:segments:]+180>
     <+[UIBezierPath _roundedRectBezierPath:withRoundedCorners:cornerRadius:segments:legacyCorners:]+340>
      <-[_UITextMagnifiedLoupeView layoutSubviews]+1252>
       <-[UIView(CALayerDelegate) layoutSublayersOfLayer:]+1492>
        <_ZN2CA5Layer16layout_if_neededEPNS_11TransactionE+440>
         <_ZN2CA5Layer28layout_and_display_if_neededEPNS_11TransactionE+124>
          <_ZN2CA7Context18commit_transactionEPNS_11TransactionEdPd+460>
           <_ZN2CA11Transaction6commitEv+652>
            <_ZN2CA7Display11DisplayLink14dispatch_itemsEyyy+1296>
             <_ZN2CA7Display11DisplayLink8callbackEP15_CADisplayTimeryyybPv+632>
              <_ZL22display_timer_callbackP12__CFMachPortPvlS1_+336>
               <__CFMachPortPerform+172>
                <__CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__+56>
                 <__CFRunLoopDoSource1+496>
                  <__CFRunLoopRun+2176>
                   <CFRunLoopRunSpecific+572>
                    <GSEventRunModal+160>
                     <-[UIApplication _run]+868>
                      <UIApplicationMain+124>
                       <OUTLINED_FUNCTION_70+500>
                        <OUTLINED_FUNCTION_70+148>
                         <OUTLINED_FUNCTION_2+92>
                          <$s4Demo0A3AppV5$mainyyFZ+40>
                           <main+12>
                            104b85558
                             104572058                              dc75000000000000
danielsaidi commented 10 months ago

Great find! I mean, let's keep it and who knows, perhaps someone manages to find out how to fix it 🤞