stefan-niedermann / nextcloud-deck

📋 Android client for nextcloud deck app
https://play.google.com/store/apps/details?id=it.niedermann.nextcloud.deck.play
GNU General Public License v3.0
499 stars 53 forks source link

Crash after starting to type in search bar #1511

Open eliasp opened 1 year ago

eliasp commented 1 year ago

Please use GitHub reactions 👍 to show that you are affected by the same issue. Please don't comment if you have no relevant information to add!

Describe the bug

Steps to reproduce the behavior:

  1. Focus the search field
  2. Start typing
  3. App crashes

The setSpan range varies but seems to be constant in regard to the input causing the crash:

a, b, c, e, f, … don't cause a crash.

Expected behavior The app doesn't crash when typing in the search field.

Versions

Smartphone (please complete the following information):

Stacktrace

Full Crash:

App Version: 1.23.3
App Version Code: 1023003
App Flavor: fdroid

Files App Version Code: 30250090 (PROD)
Files App Version Code: 20230721 (DEV)

---
OS Version: 4.19.113-perf+(2108251343)
OS API Level: 30
Device: Nord
Manufacturer: OnePlus
Model (and Product): AC2003 (Nord_EEA)

---

java.lang.IndexOutOfBoundsException: setSpan (635 ... 571) has end before start
    at android.text.SpannableStringInternal.checkRange(SpannableStringInternal.java:483)
    at android.text.SpannableStringInternal.setSpan(SpannableStringInternal.java:197)
    at android.text.SpannableStringInternal.setSpan(SpannableStringInternal.java:184)
    at android.text.SpannableString.setSpan(SpannableString.java:60)
    at com.nextcloud.android.common.ui.theme.utils.AndroidViewThemeUtils.spanText(AndroidViewThemeUtils.kt:584)
    at com.nextcloud.android.common.ui.theme.utils.AndroidViewThemeUtils.highlightText(AndroidViewThemeUtils.kt:562)
    at com.nextcloud.android.common.ui.theme.utils.AndroidViewThemeUtils.access$highlightText(AndroidViewThemeUtils.kt:75)
    at com.nextcloud.android.common.ui.theme.utils.AndroidViewThemeUtils$highlightText$1.invoke(AndroidViewThemeUtils.kt:548)
    at com.nextcloud.android.common.ui.theme.utils.AndroidViewThemeUtils$highlightText$1.invoke(AndroidViewThemeUtils.kt:547)
    at com.nextcloud.android.common.ui.theme.ViewThemeUtilsBase.withScheme(ViewThemeUtilsBase.kt:49)
    at com.nextcloud.android.common.ui.theme.utils.AndroidViewThemeUtils.highlightText(AndroidViewThemeUtils.kt:547)
    at com.nextcloud.android.common.ui.theme.utils.AndroidViewThemeUtils.highlightText$default(AndroidViewThemeUtils.kt:541)
    at com.nextcloud.android.common.ui.theme.utils.AndroidViewThemeUtils.highlightText(Unknown Source:24)
    at it.niedermann.nextcloud.deck.ui.main.search.SearchCardViewHolder.applyTheme(SearchCardViewHolder.java:110)
    at it.niedermann.nextcloud.deck.ui.main.search.SearchAdapter.lambda$onBindViewHolder$7$it-niedermann-nextcloud-deck-ui-main-search-SearchAdapter(SearchAdapter.java:99)
    at it.niedermann.nextcloud.deck.ui.main.search.SearchAdapter$$ExternalSyntheticLambda7.accept(Unknown Source:6)
    at java.util.Optional.ifPresent(Optional.java:155)
    at it.niedermann.nextcloud.deck.ui.main.search.SearchAdapter.onBindViewHolder(SearchAdapter.java:96)
    at it.niedermann.nextcloud.deck.ui.main.search.SearchAdapter.onBindViewHolder(SearchAdapter.java:27)
    at androidx.recyclerview.widget.RecyclerView$Adapter.onBindViewHolder(RecyclerView.java:7065)
    at androidx.recyclerview.widget.RecyclerView$Adapter.bindViewHolder(RecyclerView.java:7107)
    at androidx.recyclerview.widget.RecyclerView$Recycler.tryBindViewHolderByDeadline(RecyclerView.java:6012)
    at androidx.recyclerview.widget.RecyclerView$Recycler.tryGetViewHolderForPositionByDeadline(RecyclerView.java:6279)
    at androidx.recyclerview.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:6118)
    at androidx.recyclerview.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:6114)
    at androidx.recyclerview.widget.LinearLayoutManager$LayoutState.next(LinearLayoutManager.java:2303)
    at androidx.recyclerview.widget.LinearLayoutManager.layoutChunk(LinearLayoutManager.java:1627)
    at androidx.recyclerview.widget.LinearLayoutManager.fill(LinearLayoutManager.java:1587)
    at androidx.recyclerview.widget.LinearLayoutManager.onLayoutChildren(LinearLayoutManager.java:665)
    at androidx.recyclerview.widget.RecyclerView.dispatchLayoutStep2(RecyclerView.java:4134)
    at androidx.recyclerview.widget.RecyclerView.dispatchLayout(RecyclerView.java:3851)
    at androidx.recyclerview.widget.RecyclerView.onLayout(RecyclerView.java:4404)
    at android.view.View.layout(View.java:23042)
    at android.view.ViewGroup.layout(ViewGroup.java:6419)
    at android.widget.FrameLayout.layoutChildren(FrameLayout.java:332)
    at android.widget.FrameLayout.onLayout(FrameLayout.java:270)
    at android.view.View.layout(View.java:23042)
    at android.view.ViewGroup.layout(ViewGroup.java:6419)
    at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1829)
    at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1673)
    at android.widget.LinearLayout.onLayout(LinearLayout.java:1582)
    at android.view.View.layout(View.java:23042)
    at android.view.ViewGroup.layout(ViewGroup.java:6419)
    at android.widget.FrameLayout.layoutChildren(FrameLayout.java:332)
    at android.widget.FrameLayout.onLayout(FrameLayout.java:270)
    at android.view.View.layout(View.java:23042)
    at android.view.ViewGroup.layout(ViewGroup.java:6419)
    at android.widget.FrameLayout.layoutChildren(FrameLayout.java:332)
    at android.widget.FrameLayout.onLayout(FrameLayout.java:270)
    at android.view.View.layout(View.java:23042)
    at android.view.ViewGroup.layout(ViewGroup.java:6419)
    at androidx.coordinatorlayout.widget.CoordinatorLayout.layoutChildWithAnchor(CoordinatorLayout.java:1111)
    at androidx.coordinatorlayout.widget.CoordinatorLayout.onLayoutChild(CoordinatorLayout.java:895)
    at androidx.coordinatorlayout.widget.CoordinatorLayout.onLayout(CoordinatorLayout.java:919)
    at android.view.View.layout(View.java:23042)
    at android.view.ViewGroup.layout(ViewGroup.java:6419)
    at androidx.drawerlayout.widget.DrawerLayout.onLayout(DrawerLayout.java:1263)
    at android.view.View.layout(View.java:23042)
    at android.view.ViewGroup.layout(ViewGroup.java:6419)
    at android.widget.FrameLayout.layoutChildren(FrameLayout.java:332)
    at android.widget.FrameLayout.onLayout(FrameLayout.java:270)
    at android.view.View.layout(View.java:23042)
    at android.view.ViewGroup.layout(ViewGroup.java:6419)
    at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1829)
    at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1673)
    at android.widget.LinearLayout.onLayout(LinearLayout.java:1582)
    at android.view.View.layout(View.java:23042)
    at android.view.ViewGroup.layout(ViewGroup.java:6419)
    at android.widget.FrameLayout.layoutChildren(FrameLayout.java:332)
    at android.widget.FrameLayout.onLayout(FrameLayout.java:270)
    at android.view.View.layout(View.java:23042)
    at android.view.ViewGroup.layout(ViewGroup.java:6419)
    at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1829)
    at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1673)
    at android.widget.LinearLayout.onLayout(LinearLayout.java:1582)
    at android.view.View.layout(View.java:23042)
    at android.view.ViewGroup.layout(ViewGroup.java:6419)
    at android.widget.FrameLayout.layoutChildren(FrameLayout.java:332)
    at android.widget.FrameLayout.onLayout(FrameLayout.java:270)
    at com.android.internal.policy.DecorView.onLayout(DecorView.java:790)
    at android.view.View.layout(View.java:23042)
    at android.view.ViewGroup.layout(ViewGroup.java:6419)
    at android.view.ViewRootImpl.performLayout(ViewRootImpl.java:3776)
    at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:3223)
    at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:2178)
    at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:8712)
    at android.view.Choreographer$CallbackRecord.run(Choreographer.java:1352)
    at android.view.Choreographer.doCallbacks(Choreographer.java:1149)
    at android.view.Choreographer.doFrame(Choreographer.java:1049)
    at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:1333)
    at android.os.Handler.handleCallback(Handler.java:938)
    at android.os.Handler.dispatchMessage(Handler.java:99)
    at android.os.Looper.loop(Looper.java:245)
    at android.app.ActivityThread.main(ActivityThread.java:8004)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:631)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:978)
stefan-niedermann commented 1 year ago

Thank you for the report, this upstream issue has been fixed recently (https://github.com/nextcloud/android-common/pull/155). This fix will be shipped with the next version of the Deck Android app.