Skip to content

Android: ScrollView crashes on mount with NoSuchKeyException: scrollAwayPaddingBottom when useTraitHiddenOnAndroid is on #59654

Open

Description

@YevheniiKotyrlo

Description

With the useTraitHiddenOnAndroid feature flag on, the first ScrollView a screen mounts on Android throws com.facebook.react.bridge.NoSuchKeyException: scrollAwayPaddingBottom, and the app closes.

ReactScrollViewManager.updateState calls ReactScrollViewHelper.loadFabricScrollState when enableViewCulling() or useTraitHiddenOnAndroid() is on (ReactScrollViewManager.kt L404-L407), and loadFabricScrollState reads stateData.getDouble(SCROLL_AWAY_PADDING_BOTTOM) (ReactScrollViewHelper.kt L435-L436). The C++ ScrollViewState reads and writes only contentOffsetLeft, contentOffsetTop and scrollAwayPaddingTop in its RN_SERIALIZABLE_STATE block (ScrollViewState.h L45-L56), so the state a new view receives has no scrollAwayPaddingBottom, and getDouble throws. updateFabricScrollState writes the key from Kotlin (ReactScrollViewHelper.kt L411-L414), but the C++ constructor that rebuilds the state from that data doesn't read it, so it's dropped.

Both flags are off by default, so an app that keeps the defaults never reaches the read. enableViewCulling takes the same path; I only ran useTraitHiddenOnAndroid.

Steps to reproduce

  1. Clone https://github.com/YevheniiKotyrlo/rn-scroll-away-padding-bottom and run yarn install in ReproducerApp. It runs react-native@0.89.0-nightly-20261029-25b05acd7. The change that matters is in MainApplication.kt: right after loadReactNative(this), ReactNativeFeatureFlags.dangerouslyForceOverride turns useTraitHiddenOnAndroid on. The other changes move the template to what the nightly needs: CLI 21.0.0-alpha.1, @react-native/community-cli-plugin, NDK 28.2 and MainActivity without fabricEnabled.
  2. Build and install a release build: cd android && ./gradlew assembleRelease, then adb install app/build/outputs/apk/release/app-release.apk.
  3. Open ReproducerApp on the device.

Expected: NewAppScreen shows.
Seen: the app closes as soon as the screen mounts, with the exception below. On 0.88.1, the template's own version with only the MainApplication.kt change (d2e468a), it crashes the same way. I ran both on a Galaxy S23 with Android 14.

React Native Version

0.88.1, and 0.89.0-nightly-20261029-25b05acd7

Affected Platforms

Runtime - Android, Build - Windows

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

System:
  OS: Windows 11 10.0.26300
  CPU: "(32) x64 AMD Ryzen 9 9950X3D 16-Core Processor          "
  Memory: 176.80 GB / 255.67 GB
Binaries:
  Node:
    version: 26.12.1
  Yarn:
    version: 1.22.22
  npm:
    version: 12.2.1
  Watchman: Not Found
SDKs:
  Android SDK:
    API Levels:
      - "33"
      - "35"
      - "35"
      - "35"
      - "36"
      - "37"
    Build Tools:
      - 35.0.0
      - 36.0.0
      - 36.1.0
      - 37.0.0
    Android NDK: Not Found
  Windows SDK: Not Found
IDEs:
  Android Studio: AI-262.9437.185.2621.16467767
  Visual Studio: Not Found
Languages:
  Java:
    version: 17.0.20.1
  Ruby: Not Found
npmPackages:
  "@react-native-community/cli":
    installed: 21.0.0-alpha.1
    wanted: 21.0.0-alpha.1
  react:
    installed: 19.3.0
    wanted: 19.3.0
  react-native:
    installed: 0.89.0-nightly-20261029-25b05acd7
    wanted: 0.89.0-nightly-20261029-25b05acd7
  react-native-windows: Not Found
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: true
  newArchEnabled: true
iOS:
  hermesEnabled: Not found
  newArchEnabled: Not found

Stacktrace or Logs

FATAL EXCEPTION: main
Process: com.reproducerapp, PID: 21564
com.facebook.react.bridge.NoSuchKeyException: scrollAwayPaddingBottom
	at com.facebook.react.bridge.ReadableNativeMap.getValue(ReadableNativeMap.kt:117)
	at com.facebook.react.bridge.ReadableNativeMap.getDouble(ReadableNativeMap.kt:239)
	at com.facebook.react.views.scroll.ReactScrollViewHelper.loadFabricScrollState$ReactAndroid(ReactScrollViewHelper.kt:436)
	at com.facebook.react.views.scroll.ReactScrollViewManager.updateState(ReactScrollViewManager.kt:407)
	at com.facebook.react.views.scroll.ReactScrollViewManager.updateState(ReactScrollViewManager.kt:54)
	at com.facebook.react.uimanager.ViewManager.createViewInstance(ViewManager.java:233)
	at com.facebook.react.uimanager.ViewManager.createView(ViewManager.java:147)
	at com.facebook.react.fabric.mounting.SurfaceMountingManager.createViewUnsafe(SurfaceMountingManager.kt:605)
	at com.facebook.react.fabric.mounting.SurfaceMountingManager.preallocateView(SurfaceMountingManager.kt:1123)
	at com.facebook.react.fabric.mounting.mountitems.PreAllocateViewMountItem.execute(PreAllocateViewMountItem.kt:39)
	at com.facebook.react.fabric.mounting.MountItemDispatcher.executeOrEnqueue(MountItemDispatcher.kt:438)
	at com.facebook.react.fabric.mounting.MountItemDispatcher.dispatchPreMountItemsImpl$lambda$0(MountItemDispatcher.kt:399)
	at com.facebook.react.fabric.mounting.MountItemDispatcher$$ExternalSyntheticLambda0.invoke(D8$$SyntheticClass:0)
	at com.facebook.react.internal.tracing.PerformanceTracer.trace(PerformanceTracer.kt:46)
	at com.facebook.react.internal.tracing.PerformanceTracer.trace(PerformanceTracer.kt:35)
	at com.facebook.react.fabric.mounting.MountItemDispatcher.dispatchPreMountItemsImpl(MountItemDispatcher.kt:378)
	at com.facebook.react.fabric.mounting.MountItemDispatcher.dispatchPreMountItems(MountItemDispatcher.kt:372)
	at com.facebook.react.fabric.FabricUIManager$DispatchUIFrameCallback.doFrameGuarded(FabricUIManager.java:1736)
	at com.facebook.react.uimanager.GuardedFrameCallback.doFrame(GuardedFrameCallback.kt:42)
	at com.facebook.react.modules.core.ReactChoreographer.frameCallback$lambda$0(ReactChoreographer.kt:59)
	at com.facebook.react.modules.core.ReactChoreographer$$ExternalSyntheticLambda0.doFrame(D8$$SyntheticClass:0)
	at android.view.Choreographer$CallbackRecord.run(Choreographer.java:1687)
	at android.view.Choreographer$CallbackRecord.run(Choreographer.java:1698)
	at android.view.Choreographer.doCallbacks(Choreographer.java:1153)
	at android.view.Choreographer.doFrame(Choreographer.java:1069)
	at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:1646)
	at android.os.Handler.handleCallback(Handler.java:958)
	at android.os.Handler.dispatchMessage(Handler.java:99)
	at android.os.Looper.loopOnce(Looper.java:230)
	at android.os.Looper.loop(Looper.java:319)
	at android.app.ActivityThread.main(ActivityThread.java:8919)
	at java.lang.reflect.Method.invoke(Native Method)
	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:578)
	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1103)

MANDATORY Reproducer

https://github.com/YevheniiKotyrlo/rn-scroll-away-padding-bottom

Screenshots and Videos

None: the app closes as soon as the screen mounts, and the stack trace above is the whole failure.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      ⌂ Proxy