Skip to content

Crash: IndexOutOfBoundsException in NumberPicker$SetSelectionCommand.run (setSpan ends beyond length) #917

Open
@Devangdevx

Description

@Devangdevx

Describe the bug

We are encountering a native Android crash in production caused by react-native-date-picker. The issue is reported through Firebase Crashlytics and originates from internal native code — we are not using any custom native modules ourselves.

This crash has not been reproducible in development or during internal QA testing, but it is affecting real users in production.

current version of "react-native-date-picker": "^5.0.8",

Crash log
Fatal Exception: java.lang.IndexOutOfBoundsException: setSpan (4 ... 4) ends beyond length 3 at android.text.SpannableStringBuilder.checkRange(SpannableStringBuilder.java:1325) at android.text.SpannableStringBuilder.setSpan(SpannableStringBuilder.java:684) at android.text.SpannableStringBuilder.setSpan(SpannableStringBuilder.java:676) at android.text.Selection.setSelection(Selection.java:94) at android.text.Selection.setSelection(Selection.java:78) at android.widget.EditText.setSelection(EditText.java:128) at com.henninghall.date_picker.generated.NumberPicker$SetSelectionCommand.run(NumberPicker.java:2377) at android.os.Handler.handleCallback(Handler.java:938) at android.os.Handler.dispatchMessage(Handler.java:99)

Expected behavior

The date picker should not crash when attempting to update selection on a NumberPicker. If the selection indices are out of bounds, they should be clamped to the valid range of the current text. The component should fail gracefully or ignore the invalid selection without throwing an exception.

Note: We have not been able to reproduce this issue in development or during internal QA testing. It has only been observed via Firebase Crashlytics in production.

Operating System

  • Android
  • iOS

React Native Version

0.76.7

Expo Version (if applicable)

No response

react-native-date-picker version

^5.0.8

React Native Architecture

  • Old Architecture (Paper)
  • New Architecture (Fabric)

Relevant log output

Fatal Exception: java.lang.IndexOutOfBoundsException: setSpan (4 ... 4) ends beyond length 3
       at android.text.SpannableStringBuilder.checkRange(SpannableStringBuilder.java:1325)
       at android.text.SpannableStringBuilder.setSpan(SpannableStringBuilder.java:684)
       at android.text.SpannableStringBuilder.setSpan(SpannableStringBuilder.java:676)
       at android.text.Selection.setSelection(Selection.java:94)
       at android.text.Selection.setSelection(Selection.java:78)
       at android.widget.EditText.setSelection(EditText.java:128)
       at com.henninghall.date_picker.generated.NumberPicker$SetSelectionCommand.run(NumberPicker.java:2377)
       at android.os.Handler.handleCallback(Handler.java:938)
       at android.os.Handler.dispatchMessage(Handler.java:99)
       at android.os.Looper.loop(Looper.java:233)
       at com.facebook.react.bridge.queue.MessageQueueThreadImpl.lambda$startNewBackgroundThread$2(MessageQueueThreadImpl.java:217)
       at com.facebook.react.bridge.queue.MessageQueueThreadImpl$$ExternalSyntheticLambda1.run(D8$$SyntheticClass)
       at java.lang.Thread.run(Thread.java:923)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions