Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Doing Select All + Cut crashes the editor #728

Closed
daniloercoli opened this issue Jun 21, 2018 · 5 comments
Closed

Doing Select All + Cut crashes the editor #728

daniloercoli opened this issue Jun 21, 2018 · 5 comments

Comments

@daniloercoli
Copy link
Contributor

  • Start the demo app
  • Tap long, and select all
  • Select Cut
  • The app crashes with the stack trace below:
E/AndroidRuntime: FATAL EXCEPTION: main
                  Process: org.wordpress.aztec, PID: 7055
                  java.lang.IndexOutOfBoundsException: getChars (0 ... 1) ends beyond length 0
                      at android.text.SpannableStringBuilder.checkRange(SpannableStringBuilder.java:1309)
                      at android.text.SpannableStringBuilder.getChars(SpannableStringBuilder.java:1191)
                      at android.text.TextUtils.getChars(TextUtils.java:98)
                      at android.text.SpannableStringBuilder.<init>(SpannableStringBuilder.java:67)
                      at android.text.SpannableStringBuilder.subSequence(SpannableStringBuilder.java:1183)
                      at org.wordpress.aztec.handlers.BlockHandler.handleTextChanged(BlockHandler.kt:35)
                      at org.wordpress.aztec.watchers.BlockElementWatcher.onTextChanged(BlockElementWatcher.kt:73)
                      at android.widget.TextView.sendOnTextChanged(TextView.java:9359)
                      at android.widget.TextView.handleTextChanged(TextView.java:9446)
                      at android.widget.TextView$ChangeWatcher.onTextChanged(TextView.java:11904)
                      at android.text.SpannableStringBuilder.sendTextChanged(SpannableStringBuilder.java:1252)
                      at android.text.SpannableStringBuilder.replace(SpannableStringBuilder.java:573)
                      at android.text.SpannableStringBuilder.append(SpannableStringBuilder.java:269)
                      at android.text.SpannableStringBuilder.append(SpannableStringBuilder.java:295)
                      at android.text.SpannableStringBuilder.append(SpannableStringBuilder.java:293)
                      at org.wordpress.aztec.watchers.EndOfBufferMarkerAdder$Companion.ensureEndOfTextMarker(EndOfBufferMarkerAdder.kt:47)
                      at org.wordpress.aztec.watchers.EndOfBufferMarkerAdder.afterTextChanged(EndOfBufferMarkerAdder.kt:29)
                      at android.widget.TextView.sendAfterTextChanged(TextView.java:9375)
                      at android.widget.TextView$ChangeWatcher.afterTextChanged(TextView.java:11917)
                      at android.text.SpannableStringBuilder.sendAfterTextChanged(SpannableStringBuilder.java:1262)
                      at android.text.SpannableStringBuilder.replace(SpannableStringBuilder.java:574)
                      at android.text.SpannableStringBuilder.delete(SpannableStringBuilder.java:229)
                      at android.text.SpannableStringBuilder.delete(SpannableStringBuilder.java:227)
                      at org.wordpress.aztec.AztecText.onTextContextMenuItem(AztecText.kt:1319)
                      at android.widget.Editor$TextActionModeCallback.onActionItemClicked(Editor.java:3963)
                      at com.android.internal.policy.DecorView$ActionModeCallback2Wrapper.onActionItemClicked(DecorView.java:2427)
                      at com.android.internal.view.FloatingActionMode$3.onMenuItemSelected(FloatingActionMode.java:96)
                      at com.android.internal.view.menu.MenuBuilder.dispatchMenuItemSelected(MenuBuilder.java:761)
                      at com.android.internal.view.menu.MenuItemImpl.invoke(MenuItemImpl.java:167)
                      at com.android.internal.view.menu.MenuBuilder.performItemAction(MenuBuilder.java:908)
                      at com.android.internal.view.menu.MenuBuilder.performItemAction(MenuBuilder.java:898)
                      at com.android.internal.view.FloatingActionMode.lambda$-com_android_internal_view_FloatingActionMode_4856(FloatingActionMode.java:121)
                      at com.android.internal.view.-$Lambda$IoKM3AcgDw3Ok5aFi0zlym2p3IA.$m$0(Unknown Source:4)
                      at com.android.internal.view.-$Lambda$IoKM3AcgDw3Ok5aFi0zlym2p3IA.onMenuItemClick(Unknown Source:0)
                      at com.android.internal.widget.FloatingToolbar$FloatingToolbarPopup$2.onClick(FloatingToolbar.java:423)
                      at android.view.View.performClick(View.java:6256)
                      at android.view.View$PerformClick.run(View.java:24697)
                      at android.os.Handler.handleCallback(Handler.java:789)
                      at android.os.Handler.dispatchMessage(Handler.java:98)
                      at android.os.Looper.loop(Looper.java:164)
                      at android.app.ActivityThread.main(ActivityThread.java:6541)
                      at java.lang.reflect.Method.invoke(Native Method)
                      at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
                      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)

Tested on develop by running Android 8.0 on emulators.

E/WordPress-EDITOR: HTML content of Aztec Editor before the crash:
D/WordPress-EDITOR: Below are the details of the content in the editor:
D/WordPress-EDITOR: length = 0
x 000 -> 000 : ChangeWatcher
x 000 -> 000 : ChangeWatcher
> 000 -> 000 : AztecVisualLinebreak
> 000 -> 000 : AztecVisualLinebreak
> 000 -> 000 : AztecVisualLinebreak
> 000 -> 000 : AztecVisualLinebreak
> 000 -> 000 : AztecVisualLinebreak
> 000 -> 000 : AztecVisualLinebreak
> 000 -> 000 : AztecVisualLinebreak
> 000 -> 000 : AztecVisualLinebreak
> 000 -> 000 : AztecVisualLinebreak
> 000 -> 000 : AztecVisualLinebreak
> 000 -> 000 : AztecVisualLinebreak
> 000 -> 000 : AztecVisualLinebreak
> 000 -> 000 : AztecVisualLinebreak
> 000 -> 000 : AztecVisualLinebreak
> 000 -> 000 : AztecVisualLinebreak
> 000 -> 000 : AztecVisualLinebreak
> 000 -> 000 : AztecVisualLinebreak
> 000 -> 000 : AztecVisualLinebreak
> 000 -> 000 : AztecVisualLinebreak
> 000 -> 000 : AztecVisualLinebreak
x 000 -> 000 : TextKeyListener
x 000 -> 000 : SpanController
< 000 -> 000 : START
< 000 -> 000 : END
> 000 -> 000 : DragState

@koke
Copy link
Member

koke commented Jun 21, 2018

Tested on a Nexus 5 with 10.1 and it didn't crash, maybe it depends on the content?

@daniloercoli
Copy link
Contributor Author

I had already tested production. The bug report is actually on develop.

@hypest
Copy link
Contributor

hypest commented Jun 21, 2018

Reproduced on Nexus 5X, Android v7.1.2, develop (555df8b)

@daniloercoli
Copy link
Contributor Author

daniloercoli commented Jun 21, 2018

Also be able to reproduce this crash on Aztec 1.3.6 (5400bf9).

@mzorz
Copy link
Contributor

mzorz commented Apr 16, 2019

Tested, doesn't seem to be happening anymore as of 1.3.24 (40cde2f).

Closing

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants