Notes: crash when writing title of # heading

Using the Notes widget for Android.

When typing the title of a “#”/H1 heading at the bottom of the note: crash.

If changes to “##”/H2 heading - no crash.

Text:

# GranngĂĄrden
[ ] Ängsfrön 20×30m
[ ] baljor
[ ] tank dagvatten
# Swedol
Olja växellåda traktor SAE 90
# Jula
Stöveltork

# Traktorn
Hudraulplugg
Backspegel
Trattar bensik o olja
# Teknik
Kylpasta
# 



App Version: 3.4.18
App Version Code: 3004018
App Flavor: play

Files App Version Code: 30190190

---

OS Version: 4.19.111-23350288(G525FXXS5AVB3)
OS API Level: 30
Device: xcover5
Manufacturer: samsung
Model (and Product): SM-G525F (xcover5eea)

---

java.lang.RuntimeException: java.lang.IndexOutOfBoundsException: setSpan (203 ... 205) ends beyond length 203
	at io.noties.markwon.editor.MarkwonEditorTextWatcher$WithPreRender$2$2.run(MarkwonEditorTextWatcher.java:168)
	at android.os.Handler.handleCallback(Handler.java:938)
	at android.os.Handler.dispatchMessage(Handler.java:99)
	at android.os.Looper.loop(Looper.java:246)
	at android.app.ActivityThread.main(ActivityThread.java:8653)
	at java.lang.reflect.Method.invoke(Native Method)
	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:602)
	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1130)
Caused by: java.lang.IndexOutOfBoundsException: setSpan (203 ... 205) ends beyond length 203
	at android.text.SpannableStringBuilder.checkRange(SpannableStringBuilder.java:1335)
	at android.text.SpannableStringBuilder.setSpan(SpannableStringBuilder.java:694)
	at android.text.SpannableStringBuilder.setSpan(SpannableStringBuilder.java:686)
	at io.noties.markwon.editor.MarkwonEditorImpl$RecordingSpannableStringBuilder.setSpan(MarkwonEditorImpl.java:203)
	at it.niedermann.android.markdown.markwon.handler.HeadingEditHandler.handleMarkdownSpan(HeadingEditHandler.java:69)
	at it.niedermann.android.markdown.markwon.handler.HeadingEditHandler.handleMarkdownSpan(HeadingEditHandler.java:14)
	at io.noties.markwon.editor.MarkwonEditor$SpansHandlerImpl.handle(MarkwonEditor.java:185)
	at io.noties.markwon.editor.MarkwonEditorImpl.process(MarkwonEditorImpl.java:85)
	at io.noties.markwon.editor.MarkwonEditorImpl.preRender(MarkwonEditorImpl.java:157)
	at io.noties.markwon.editor.MarkwonEditorTextWatcher$WithPreRender$2.run(MarkwonEditorTextWatcher.java:137)
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:462)
	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
	at java.lang.Thread.run(Thread.java:923)

It would probably be better to open an issue directly on GitHub if none exists yet… GitHub - nextcloud/android: 📱 Nextcloud Android app

I already saw this post, let me figure out, what possibly might be wrong here…

I have troubles reproducing the issue.

  • Are you able to reproduce the issue constantly or does it sometimes happen, sometimes not?
  • Can you provide a more minimal sample where the issue occurs?
  • Does the speed of you key strokes influence the happening of the bug? (e. g. happens only when typing fast or slow)

I am having trouble reproducing it now, unfortunately.

When I first encountered the crash, it happened several times in a row when typing at the exact same position. I don’t think it has anything to do with the speed of typing - I think I typed at different speeds.

Yesterday I succeeded reproducing it once with a different text, but the note disappeard after the crash.

Now I succeeded reproducing it once after copy-past the text and fixing the layout with headers. But the text disappeard (was not saved). When trying again I cannot reproduce it - I guess I did something slightly different when trying to layout the text again after copy-paste into a new note.

I will see if I manage to reproduce it.

Thanks for taking your time.

I’ll check whether i am able to finde the cause of the issue in the stacktrace error message you pisted above :slight_smile: Thanks for the update.

Since I have unfortunately not yet been able to reproduce the problem, we’ll keep track of this issue in the corresponding GitHub repository, so it won’t get lost (marking this topic as :white_check_mark: solved here, because from the point of the community help forum other contributors won’t be able to do anything more here).

Please feel free to simply post further information if you found some kind of rule that leads to the error (here or at the linked issue).

In case we find a solution, I will post a comment here too, of course, so you will get notified.