Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NullPointerException android.widget.ScrollView in onTouchEvent #46260

Open
gurbela opened this issue Aug 29, 2024 · 9 comments
Open

NullPointerException android.widget.ScrollView in onTouchEvent #46260

gurbela opened this issue Aug 29, 2024 · 9 comments
Labels
Component: ScrollView Needs: Attention Issues where the author has responded to feedback. Needs: Repro This issue could be improved with a clear list of steps to reproduce the issue. Platform: Android Android applications.

Comments

@gurbela
Copy link

gurbela commented Aug 29, 2024

Description

Attempt to invoke virtual method 'void android.view.VelocityTracker.clear()' on a null object reference

Steps to reproduce

  1. Install the application with yarn android
  2. I started scrolling up and down
  3. Notice the crash

React Native Version

0.75.2

Affected Platforms

Runtime - Android

Output of npx react-native info

info Fetching system and libraries information...
System:
  OS: macOS 14.6.1
  CPU: (10) arm64 Apple M1 Pro
  Memory: 93.86 MB / 16.00 GB
  Shell:
    version: "5.9"
    path: /bin/zsh
Binaries:
  Node:
    version: 20.10.0
    path: ~/.nvm/versions/node/v20.10.0/bin/node
  Yarn:
    version: 3.6.4
    path: ~/.nvm/versions/node/v20.10.0/bin/yarn
  npm:
    version: 10.2.3
    path: ~/.nvm/versions/node/v20.10.0/bin/npm
  Watchman:
    version: 2024.08.19.00
    path: /opt/homebrew/bin/watchman
Managers:
  CocoaPods:
    version: 1.15.2
    path: /usr/local/bin/pod
SDKs:
  iOS SDK:
    Platforms:
      - DriverKit 23.5
      - iOS 17.5
      - macOS 14.5
      - tvOS 17.5
      - visionOS 1.2
      - watchOS 10.5
  Android SDK:
    API Levels:
      - "31"
      - "33"
      - "34"
    Build Tools:
      - 30.0.3
      - 31.0.0
      - 32.0.0
      - 33.0.0
      - 33.0.1
      - 33.0.2
      - 34.0.0
    System Images:
      - android-33 | Google APIs ARM 64 v8a
      - android-34 | Google APIs ARM 64 v8a
    Android NDK: Not Found
IDEs:
  Android Studio: 2024.1 AI-241.18034.62.2411.12169540
  Xcode:
    version: 15.4/15F31d
    path: /usr/bin/xcodebuild
Languages:
  Java:
    version: 17.0.12
    path: /opt/homebrew/opt/openjdk@17/bin/javac
  Ruby:
    version: 2.6.10
    path: /usr/bin/ruby
npmPackages:
  "@react-native-community/cli": Not Found
  react:
    installed: 18.3.1
    wanted: 18.3.1
  react-native:
    installed: 0.75.2
    wanted: 0.75.2
  react-native-macos: Not Found
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: true
  newArchEnabled: true
iOS:
  hermesEnabled: true
  newArchEnabled: false

Stacktrace or Logs

android.widget.ScrollView in onTouchEvent at line 831
com.facebook.react.views.scroll.c in onTouchEvent at line 70
android.view.View in dispatchTouchEvent at line 15050
android.view.ViewGroup in dispatchTransformedTouchEvent at line 3115
android.view.ViewGroup in dispatchTouchEvent at line 2788
android.view.ViewGroup in dispatchTransformedTouchEvent at line 3121
android.view.ViewGroup in dispatchTouchEvent at line 2802
android.view.ViewGroup in dispatchTransformedTouchEvent at line 3121
android.view.ViewGroup in dispatchTouchEvent at line 2802
android.view.ViewGroup in dispatchTransformedTouchEvent at line 3121
android.view.ViewGroup in dispatchTouchEvent at line 2802
android.view.ViewGroup in dispatchTransformedTouchEvent at line 3121
android.view.ViewGroup in dispatchTouchEvent at line 2802
android.view.ViewGroup in dispatchTransformedTouchEvent at line 3121
android.view.ViewGroup in dispatchTouchEvent at line 2802
android.view.ViewGroup in dispatchTransformedTouchEvent at line 3121
android.view.ViewGroup in dispatchTouchEvent at line 2802
android.view.ViewGroup in dispatchTransformedTouchEvent at line 3121
android.view.ViewGroup in dispatchTouchEvent at line 2802
android.view.ViewGroup in dispatchTransformedTouchEvent at line 3121
android.view.ViewGroup in dispatchTouchEvent at line 2802
com.microsoft.clarity.c6.i in dispatchTouchEvent at line 22
android.view.ViewGroup in dispatchTransformedTouchEvent at line 3121
android.view.ViewGroup in dispatchTouchEvent at line 2802
android.view.ViewGroup in dispatchTransformedTouchEvent at line 3121
android.view.ViewGroup in dispatchTouchEvent at line 2802
android.view.ViewGroup in dispatchTransformedTouchEvent at line 3121
android.view.ViewGroup in dispatchTouchEvent at line 2802
android.view.ViewGroup in dispatchTransformedTouchEvent at line 3121
android.view.ViewGroup in dispatchTouchEvent at line 2802
android.view.ViewGroup in dispatchTransformedTouchEvent at line 3121
android.view.ViewGroup in dispatchTouchEvent at line 2802
android.view.ViewGroup in dispatchTransformedTouchEvent at line 3121
android.view.ViewGroup in dispatchTouchEvent at line 2802
android.view.ViewGroup in dispatchTransformedTouchEvent at line 3121
android.view.ViewGroup in dispatchTouchEvent at line 2802
android.view.ViewGroup in dispatchTransformedTouchEvent at line 3121
android.view.ViewGroup in dispatchTouchEvent at line 2802
android.view.ViewGroup in dispatchTransformedTouchEvent at line 3121
android.view.ViewGroup in dispatchTouchEvent at line 2802
com.microsoft.clarity.c6.i in dispatchTouchEvent at line 22
android.view.ViewGroup in dispatchTransformedTouchEvent at line 3121
android.view.ViewGroup in dispatchTouchEvent at line 2802
android.view.ViewGroup in dispatchTransformedTouchEvent at line 3121
android.view.ViewGroup in dispatchTouchEvent at line 2802
android.view.ViewGroup in dispatchTransformedTouchEvent at line 3121
android.view.ViewGroup in dispatchTouchEvent at line 2802
android.view.ViewGroup in dispatchTransformedTouchEvent at line 3121
android.view.ViewGroup in dispatchTouchEvent at line 2802
android.view.ViewGroup in dispatchTransformedTouchEvent at line 3121
android.view.ViewGroup in dispatchTouchEvent at line 2802
android.view.ViewGroup in dispatchTransformedTouchEvent at line 3121
android.view.ViewGroup in dispatchTouchEvent at line 2802
android.view.ViewGroup in dispatchTransformedTouchEvent at line 3121
android.view.ViewGroup in dispatchTouchEvent at line 2802
android.view.ViewGroup in dispatchTransformedTouchEvent at line 3121
android.view.ViewGroup in dispatchTouchEvent at line 2802
com.microsoft.clarity.c6.i in dispatchTouchEvent at line 22
android.view.ViewGroup in dispatchTransformedTouchEvent at line 3121
android.view.ViewGroup in dispatchTouchEvent at line 2802
android.view.ViewGroup in dispatchTransformedTouchEvent at line 3121
android.view.ViewGroup in dispatchTouchEvent at line 2802
com.microsoft.clarity.c6.i in dispatchTouchEvent at line 22
android.view.ViewGroup in dispatchTransformedTouchEvent at line 3121
android.view.ViewGroup in dispatchTouchEvent at line 2802
android.view.ViewGroup in dispatchTransformedTouchEvent at line 3121
android.view.ViewGroup in dispatchTouchEvent at line 2802
android.view.ViewGroup in dispatchTransformedTouchEvent at line 3121
android.view.ViewGroup in dispatchTouchEvent at line 2802
android.view.ViewGroup in dispatchTransformedTouchEvent at line 3121
android.view.ViewGroup in dispatchTouchEvent at line 2802
android.view.ViewGroup in dispatchTransformedTouchEvent at line 3121
android.view.ViewGroup in dispatchTouchEvent at line 2802
android.view.ViewGroup in dispatchTransformedTouchEvent at line 3121
android.view.ViewGroup in dispatchTouchEvent at line 2802
com.android.internal.policy.DecorView in superDispatchTouchEvent at line 500
com.android.internal.policy.PhoneWindow in superDispatchTouchEvent at line 1912
android.app.Activity in dispatchTouchEvent at line 4299
com.microsoft.clarity.m.i in dispatchTouchEvent at line 2
com.microsoft.clarity.C5.i$b in dispatchTouchEvent at line 31
com.android.internal.policy.DecorView in dispatchTouchEvent at line 458
android.view.View in dispatchPointerEvent at line 15309
android.view.ViewRootImpl$ViewPostImeInputStage in processPointerEvent at line 6778
android.view.ViewRootImpl$ViewPostImeInputStage in onProcess at line 6578
android.view.ViewRootImpl$InputStage in deliver at line 6034
android.view.ViewRootImpl$InputStage in onDeliverToNext at line 6091
android.view.ViewRootImpl$InputStage in forward at line 6057
android.view.ViewRootImpl$AsyncInputStage in forward at line 6222
android.view.ViewRootImpl$InputStage in apply at line 6065
android.view.ViewRootImpl$AsyncInputStage in apply at line 6279
android.view.ViewRootImpl$InputStage in deliver at line 6038
android.view.ViewRootImpl$InputStage in onDeliverToNext at line 6091
android.view.ViewRootImpl$InputStage in forward at line 6057
android.view.ViewRootImpl$InputStage in apply at line 6065
android.view.ViewRootImpl$InputStage in deliver at line 6038
android.view.ViewRootImpl in deliverInputEvent at line 9206
android.view.ViewRootImpl in doProcessInputEvents at line 9157
android.view.ViewRootImpl in enqueueInputEvent at line 9126
android.view.ViewRootImpl$WindowInputEventReceiver in onInputEvent at line 9329
android.view.InputEventReceiver in dispatchInputEvent at line 267

Reproducer

test

Screenshots and Videos

No response

@react-native-bot
Copy link
Collaborator

⚠️ Missing Reproducible Example
ℹ️ We could not detect a reproducible example in your issue report. Please provide either:
  • If your bug is UI related: a Snack
  • If your bug is build/update related: use our Reproducer Template. A reproducer needs to be in a GitHub repository under your username.

@react-native-bot react-native-bot added Needs: Author Feedback Needs: Repro This issue could be improved with a clear list of steps to reproduce the issue. Component: ScrollView Platform: Android Android applications. labels Aug 29, 2024
@react-native-bot
Copy link
Collaborator

⚠️ Missing Reproducible Example
ℹ️ We could not detect a reproducible example in your issue report. Please provide either:

@shubhamguptadream11
Copy link
Collaborator

shubhamguptadream11 commented Aug 29, 2024

It will be great if you provide a repro using this template: https://github.com/react-native-community/reproducer-react-native

@gurbela
Copy link
Author

gurbela commented Aug 29, 2024

It will be great if you provide a repro using this template: https://github.com/react-native-community/reproducer-react-native

I have simple scrolling, I use ScrollView, I started scrolling up and down and then the application on Android is crashed,
I using React Native 75.2 version, New architect of react native enabled.

@github-actions github-actions bot added Needs: Attention Issues where the author has responded to feedback. and removed Needs: Author Feedback labels Aug 29, 2024
@shubhamguptadream11
Copy link
Collaborator

@gurbela Not able to repro it on latest version. I am using a scrollView with lots of items.
Can you share your App.tsx file?

@gurbela
Copy link
Author

gurbela commented Aug 29, 2024

@gurbela Not able to repro it on latest version. I am using a scrollView with lots of items. Can you share your App.tsx file?



import 'react-native-gesture-handler';
import React, { useEffect, useLayoutEffect, } from 'react';
import { Provider } from 'react-redux';
import { PersistGate } from 'redux-persist/lib/integration/react';
import { store, persistor } from 'store';
import { Navigation } from 'navigation';

import { closeToast, openToast, saveToastRef } from 'utils/toast';
import { SafeAreaProvider } from 'react-native-safe-area-context';
import { GestureHandlerRootView } from 'react-native-gesture-handler';
import { ErrorBoundary, Modal, ModalSheet, Toast } from 'components';
import { saveModalRef } from 'utils/modal';

import { LogBox, Platform, StatusBar } from 'react-native';
import { Colors } from 'theme/Variables';
import BootSplash from 'react-native-bootsplash';

import { useIsConnectionAlive } from 'hooks';
import { ApplicationErrorWrapper } from 'components';
import { useGlobalStyles } from 'theme/Global.styles';
import { modalSheetRef } from 'utils/modalSheet';
import { initSentry } from 'utils/sentry';
import { i18nInitializationPromise } from './translations';

LogBox.ignoreAllLogs();

const App = () => {
  const globalStyles = useGlobalStyles();

  useEffect(() => {
    const initializeApp = async () => {
      try {
        await i18nInitializationPromise;
      } catch (error) {
        console.warn('Failed to initialize i18n:', error);
      } finally {
        await BootSplash.hide({ fade: true });
      }
    };

    initializeApp();

    initSentry();

    return () => {
      closeToast();
    };
  }, []);

  //  We set statusbar custom color - only for android on the root level
  //   For IOS, we need to tweak the statusbar, so CustomStatusbar Component was created
  useLayoutEffect(() => {
    StatusBar.setBarStyle('dark-content');
    if (Platform.OS === 'android') {
      StatusBar.setBackgroundColor(Colors.dashboardBackground);
    }
  }, []);

  const { isConnectionAlive } = useIsConnectionAlive();

  useEffect(() => {
    if (!isConnectionAlive) {
      openToast('error.network_error', 'error');
    }

    return () => {
      closeToast();
    };
  }, [isConnectionAlive]);

  return (
    <ErrorBoundary>
      <GestureHandlerRootView style={globalStyles.fill}>
        <SafeAreaProvider>
          <Provider store={store}>
            <PersistGate loading={null} persistor={persistor}>
              <ApplicationErrorWrapper>
                <Navigation />
                <Modal ref={saveModalRef} />
                <ModalSheet ref={modalSheetRef} />
                <Toast ref={saveToastRef} />
              </ApplicationErrorWrapper>
            </PersistGate>
          </Provider>
        </SafeAreaProvider>
      </GestureHandlerRootView>
    </ErrorBoundary>
  );
};

export default App;

@shubhamguptadream11
Copy link
Collaborator

@gurbela Can you narrow down the issue to bare react native project?

@gurbela
Copy link
Author

gurbela commented Aug 29, 2024

@gurbela Can you narrow down the issue to bare react native project?

  const scrollHandler = useAnimatedScrollHandler({
    onScroll: event => {
      const y = event.contentOffset.y;
      translateY.value = y > 0 ? y : 0;
      scroll.value = y;
      shouldClose.value = y > 0;
    },
  });

<Animated.FlatList
        nestedScrollEnabled
        data={['']}
        ref={sectionListRef}
        refreshControl={<RefreshControl refreshing={refreshing} onRefresh={handleRefresh} />}
        onScroll={scrollHandler}
        contentContainerStyle={styles.sectionListContent}
        showsVerticalScrollIndicator={false}
        renderItem={renderLists}
        maxToRenderPerBatch={1}
        removeClippedSubviews={true}
      />

I'm using scrollHandler, and it causes this error (a crash)

@cipolleschi
Copy link
Contributor

@gurbela please create a reproducer using this template. We cannot look into issue if they are not created with it.

Also, it is unclear if this is related to The New Architecture or not. We have a template to collect New Architecture issues that should be used if that's the case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: ScrollView Needs: Attention Issues where the author has responded to feedback. Needs: Repro This issue could be improved with a clear list of steps to reproduce the issue. Platform: Android Android applications.
Projects
None yet
Development

No branches or pull requests

4 participants