Skip to content

[RN 0.80] NullpointException occurs occasionally in TextInput on Android #53046

Description

@appa-gomi

Description

When there are multiple TextInputs in KeyboardAvoidingView and ScrollView, if Navigate.goBack is called while the second or more TextInputs have focus (SoftKeyboard is displayed), a NullpointException occurs.

This phenomenon occurs because host.getChildAt(0) in the findNextFocusableView method in ReactScrollViewHelper.kt can be null.

Therefore, host.getChildAt(0) must be null-checked.

Steps to reproduce

I create multiple TextInputs within a KeyboardAvoidingView and ScrollView, and then focus on the second TextInput and display the SoftKeyboard.
Executing navigate.goBack() in this state occasionally results in a NullPointerException.

React Native Version

0.80.2

Affected Platforms

Runtime - Android

Output of npx @react-native-community/cli info

System:
  OS: macOS 15.5
  CPU: (16) arm64 Apple M4 Max
  Memory: 2.61 GB / 64.00 GB
  Shell:
    version: "5.9"
    path: /bin/zsh
Binaries:
  Node:
    version: 22.16.0
    path: ~/.nvm/versions/node/v22.16.0/bin/node
  Yarn:
    version: 1.22.22
    path: ~/.nvm/versions/node/v22.16.0/bin/yarn
  npm:
    version: 10.9.2
    path: ~/.nvm/versions/node/v22.16.0/bin/npm
  Watchman:
    version: 2025.05.26.00
    path: /opt/homebrew/bin/watchman
Managers:
  CocoaPods:
    version: 1.16.2
    path: /Users/sunkim/.rbenv/shims/pod
SDKs:
  iOS SDK:
    Platforms:
      - DriverKit 24.5
      - iOS 18.5
      - macOS 15.5
      - tvOS 18.5
      - visionOS 2.5
      - watchOS 11.5
  Android SDK:
    API Levels:
      - "31"
      - "34"
      - "35"
      - "36"
    Build Tools:
      - 33.0.0
      - 34.0.0
      - 35.0.0
      - 35.0.1
      - 36.0.0
    System Images:
      - android-27 | Google APIs ARM 64 v8a
      - android-27 | Google Play Intel x86 Atom
      - android-34 | ARM 64 v8a
      - android-34 | Google APIs ARM 64 v8a
      - android-34 | Google Play ARM 64 v8a
      - android-35 | Google APIs ARM 64 v8a
      - android-35 | Google Play ARM 64 v8a
      - android-36 | Google APIs ARM 64 v8a
    Android NDK: Not Found
IDEs:
  Android Studio: 2025.1 AI-251.26094.121.2512.13840223
  Xcode:
    version: 16.4/16F6
    path: /usr/bin/xcodebuild
Languages:
  Java:
    version: 17.0.15
    path: /usr/bin/javac
  Ruby:
    version: 3.3.8
    path: /Users/sunkim/.rbenv/shims/ruby
npmPackages:
  "@react-native-community/cli":
    installed: 19.1.1
    wanted: 19.1.1
  react:
    installed: 19.1.0
    wanted: 19.1.0
  react-native:
    installed: 0.80.2
    wanted: 0.80.2
  react-native-macos: Not Found
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: true
  newArchEnabled: true
iOS:
  hermesEnabled: true
  newArchEnabled: true

Stacktrace or Logs

java.lang.NullPointerException: Attempt to invoke virtual method 'int android.view.View.getId()' on a null object reference
                                                                                                    	at com.facebook.react.views.scroll.ReactScrollViewHelper.findNextFocusableView(ReactScrollViewHelper.kt:500)
                                                                                                    	at com.facebook.react.views.scroll.ReactScrollView.focusSearch(ReactScrollView.java:369)
                                                                                                    	at android.view.ViewGroup.focusSearch(ViewGroup.java:1089)
                                                                                                    	at android.view.View.focusSearch(View.java:14957)
                                                                                                    	at android.widget.TextView.hasEditorInFocusSearchDirection(TextView.java:10639)
                                                                                                    	at android.widget.TextView.onCreateInputConnection(TextView.java:10662)
                                                                                                    	at androidx.appcompat.widget.AppCompatEditText.onCreateInputConnection(AppCompatEditText.java:270)
                                                                                                    	at com.facebook.react.views.textinput.ReactEditText.onCreateInputConnection(ReactEditText.kt:341)
                                                                                                    	at android.view.inputmethod.InputMethodManager.createInputConnection(InputMethodManager.java:5318)
                                                                                                    	at android.view.inputmethod.InputMethodManager.startInputInner(InputMethodManager.java:3377)
                                                                                                    	at android.view.inputmethod.InputMethodManager.startInputOnWindowFocusGainInternal(InputMethodManager.java:1098)
                                                                                                    	at android.view.inputmethod.InputMethodManager.checkFocus(InputMethodManager.java:3716)
                                                                                                    	at android.view.inputmethod.InputMethodManager.updateCursorAnchorInfo(InputMethodManager.java:4169)
                                                                                                    	at android.widget.Editor$CursorAnchorInfoNotifier.updatePosition(Editor.java:5711)
                                                                                                    	at android.widget.Editor$PositionListener.onPreDraw(Editor.java:4244)
                                                                                                    	at android.view.ViewTreeObserver.dispatchOnPreDraw(ViewTreeObserver.java:1226)
                                                                                                    	at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:5198)
                                                                                                    	at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:3708)
                                                                                                    	at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:12542)
                                                                                                    	at android.view.Choreographer$CallbackRecord.run(Choreographer.java:1751)
                                                                                                    	at android.view.Choreographer$CallbackRecord.run(Choreographer.java:1760)
                                                                                                    	at android.view.Choreographer.doCallbacks(Choreographer.java:1216)
                                                                                                    	at android.view.Choreographer.doFrame(Choreographer.java:1142)
                                                                                                    	at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:1707)
                                                                                                    	at android.os.Handler.handleCallback(Handler.java:959)
                                                                                                    	at android.os.Handler.dispatchMessage(Handler.java:100)
                                                                                                    	at android.os.Looper.loopOnce(Looper.java:257)
                                                                                                    	at android.os.Looper.loop(Looper.java:342)
                                                                                                    	at android.app.ActivityThread.main(ActivityThread.java:9634)
                                                                                                    	at java.lang.reflect.Method.invoke(Native Method)
                                                                                                    	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:619)
                                                                                                    	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:929)

MANDATORY Reproducer

no

Screenshots and Videos

No response

Metadata

Metadata

Assignees

Labels

Component: TextInputRelated to the TextInput component.Needs: AttentionIssues where the author has responded to feedback.Needs: ReproThis issue could be improved with a clear list of steps to reproduce the issue.Platform: AndroidAndroid applications.StaleThere has been a lack of activity on this issue and it may be closed soon.

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions