mathew-kurian / TextJustify-Android

:page_facing_up: Android Text Full Jusiftication / Wrapping / Justify / Hyphenate - V2.0
https://github.com/bluejamesbond/TextJustify-Android/wiki
Apache License 2.0
1.86k stars 369 forks source link

IndexOutOfBoundsException in Styled.drawUniformRun on 5.1 #76

Open ahmedre opened 9 years ago

ahmedre commented 9 years ago

@khalid-hussain asked me to help him with khalid-hussain/HisnulMuslim#35 - i looked into it and the reason there's an IndexOutOfBoundsException is that tmpstart and tmpend are wrong (they extend beyond the string's length (in his specific case, tmpstart is 327, tmpend is 337, and the length of the string is 331).

i (unfortunately) didn't have time to investigate the root cause, but according to @khalid-hussain, this only happens on 5.1. i was able to repro 100% on his app on a 5.1.0 emulator.

06-05 00:48:26.116  16045-16045/? E/AndroidRuntime﹕ FATAL EXCEPTION: main
    Process: com.khalid.hisnulmuslim, PID: 16045
    java.lang.IndexOutOfBoundsException
            at android.view.GLES20Canvas.drawText(GLES20Canvas.java:888)
            at com.bluejamesbond.text.Styled.drawUniformRun(Styled.java:156)
            at com.bluejamesbond.text.Styled.drawDirectionalRun(Styled.java:319)
            at com.bluejamesbond.text.Styled.drawText(Styled.java:383)
            at com.bluejamesbond.text.SpannableDocumentLayout.onDraw(SpannableDocumentLayout.java:512)
            at com.bluejamesbond.text.IDocumentLayout.draw(IDocumentLayout.java:143)
            at com.bluejamesbond.text.DocumentView.drawLayout(DocumentView.java:184)
            at com.bluejamesbond.text.DocumentView.onDraw(DocumentView.java:620)
            at android.view.View.draw(View.java:15239)
            at android.widget.FrameLayout.draw(FrameLayout.java:598)
            at android.widget.ScrollView.draw(ScrollView.java:1689)
            at android.view.View.updateDisplayListIfDirty(View.java:14175)
            at android.view.View.getDisplayList(View.java:14197)
            at android.view.View.draw(View.java:14967)
            at android.view.ViewGroup.drawChild(ViewGroup.java:3406)
            at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3199)
            at android.view.View.updateDisplayListIfDirty(View.java:14170)
            at android.view.View.getDisplayList(View.java:14197)
            at android.view.View.draw(View.java:14967)
            at android.view.ViewGroup.drawChild(ViewGroup.java:3406)
            at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3199)
            at android.view.View.draw(View.java:15242)
            at android.widget.FrameLayout.draw(FrameLayout.java:598)
            at android.view.View.updateDisplayListIfDirty(View.java:14175)
            at android.view.View.getDisplayList(View.java:14197)
            at android.view.View.draw(View.java:14967)
            at android.view.ViewGroup.drawChild(ViewGroup.java:3406)
            at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3199)
            at android.view.View.updateDisplayListIfDirty(View.java:14170)
            at android.view.View.getDisplayList(View.java:14197)
            at android.view.View.draw(View.java:14967)
            at android.view.ViewGroup.drawChild(ViewGroup.java:3406)
            at android.widget.ListView.drawChild(ListView.java:3396)
            at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3199)
            at android.widget.AbsListView.dispatchDraw(AbsListView.java:2605)
            at android.widget.ListView.dispatchDraw(ListView.java:3391)
            at android.view.View.draw(View.java:15242)
            at android.widget.AbsListView.draw(AbsListView.java:4116)
            at android.view.View.updateDisplayListIfDirty(View.java:14175)
            at android.view.View.getDisplayList(View.java:14197)
            at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3390)
            at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3369)
            at android.view.View.updateDisplayListIfDirty(View.java:14135)
            at android.view.View.getDisplayList(View.java:14197)
            at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3390)
            at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3369)
            at android.view.View.updateDisplayListIfDirty(View.java:14135)
            at android.view.View.getDisplayList(View.java:14197)
            at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3390)
            at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3369)
            at android.view.View.updateDisplayListIfDirty(View.java:14135)
            at android.view.View.getDisplayList(View.java:14197)
            at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3390)
            at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3369)
            at android.view.View.updateDisplayListIfDirty(View.java:14135)
            at android.view.View.getDisplayList(View.java:14197)
            at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3390)
            at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3369)
            at android.view.View.updateDisplayListIfDirty(View.java:14135)
            at android.view.View.getDisplayList(View.java:14197)
            at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3390)
            at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3369)
            at android.view.View.updateDisplayListIfDirty(View.java:14135)
            at android.view.View.getDisplayList(View.java:14197)
Shuhrat-java commented 7 years ago

Is there any solution for this? I have same problem