facebook / react-native

A framework for building native applications using React
https://reactnative.dev
MIT License
118.01k stars 24.18k forks source link

NullPointerException: Attempt to invoke virtual method 'void android.view.View.dispatchCancelPendingInputEvents() #41077

Open edstbbz opened 10 months ago

edstbbz commented 10 months ago

Description

[Android] An exception is thrown periodically when requesting permissions: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.view.View.dispatchCancelPendingInputEvents()' on a null object reference at android.view.ViewGroup.dispatchCancelPendingInputEvents(ViewGroup.java:3893) at android.view.ViewGroup.dispatchCancelPendingInputEvents(ViewGroup.java:3893) at android.view.ViewGroup.dispatchCancelPendingInputEvents(ViewGroup.java:3893) at android.view.ViewGroup.dispatchCancelPendingInputEvents(ViewGroup.java:3893) at android.view.ViewGroup.dispatchCancelPendingInputEvents(ViewGroup.java:3893) at android.view.ViewGroup.dispatchCancelPendingInputEvents(ViewGroup.java:3893) at android.view.ViewGroup.dispatchCancelPendingInputEvents(ViewGroup.java:3893) at android.view.ViewGroup.dispatchCancelPendingInputEvents(ViewGroup.java:3893) at android.view.ViewGroup.dispatchCancelPendingInputEvents(ViewGroup.java:3893) at android.view.ViewGroup.dispatchCancelPendingInputEvents(ViewGroup.java:3893) at android.view.ViewGroup.dispatchCancelPendingInputEvents(ViewGroup.java:3893) at android.view.ViewGroup.dispatchCancelPendingInputEvents(ViewGroup.java:3893) at android.view.ViewGroup.dispatchCancelPendingInputEvents(ViewGroup.java:3893) at android.view.ViewGroup.dispatchCancelPendingInputEvents(ViewGroup.java:3893) at android.view.ViewGroup.dispatchCancelPendingInputEvents(ViewGroup.java:3893) at android.view.ViewGroup.dispatchCancelPendingInputEvents(ViewGroup.java:3893) at android.view.ViewGroup.dispatchCancelPendingInputEvents(ViewGroup.java:3893) at android.view.ViewGroup.dispatchCancelPendingInputEvents(ViewGroup.java:3893) at android.view.ViewGroup.dispatchCancelPendingInputEvents(ViewGroup.java:3893) at android.view.ViewGroup.dispatchCancelPendingInputEvents(ViewGroup.java:3893) at android.view.ViewGroup.dispatchCancelPendingInputEvents(ViewGroup.java:3893) at android.view.View.cancelPendingInputEvents(View.java:15729) at android.app.Activity.cancelInputsAndStartExitTransition(Activity.java:4337) at android.app.Activity.startActivityForResult(Activity.java:4956) at android.app.Activity.requestPermissions(Activity.java:4193) at com.facebook.react.ReactActivityDelegate.requestPermissions(ReactActivityDelegate.java:191) at com.facebook.react.ReactActivity.requestPermissions(ReactActivity.java:110) at com.facebook.react.modules.permissions.PermissionsModule.requestPermission(PermissionsModule.java:126) at java.lang.reflect.Method.invoke(Method.java) at com.facebook.react.bridge.JavaMethodWrapper.invoke(JavaMethodWrapper.java:372) at com.facebook.react.bridge.JavaModuleWrapper.invoke(JavaModuleWrapper.java:188) at com.facebook.jni.NativeRunnable.run(NativeRunnable.java) at android.os.Handler.handleCallback(Handler.java:751) at android.os.Handler.dispatchMessage(Handler.java:95) at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:27) at android.os.Looper.loop(Looper.java:154) at com.facebook.react.bridge.queue.MessageQueueThreadImpl$4.run(MessageQueueThreadImpl.java:228) at java.lang.Thread.run(Thread.java:761)

React Native Version

0.72.5

Output of npx react-native info

System: OS: macOS 13.5.2 CPU: (16) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz Memory: 50.72 MB / 16.00 GB Shell: version: "5.9" path: /bin/zsh Binaries: Node: version: 18.17.1 path: /private/var/folders/7m/rj94pv291918l94_rmpgg9jm0000gn/T/xfs-7be70c02/node Yarn: version: 3.2.1 path: /private/var/folders/7m/rj94pv291918l94_rmpgg9jm0000gn/T/xfs-7be70c02/yarn npm: version: 9.6.7 path: /usr/local/bin/npm Watchman: version: 2023.10.09.00 path: /usr/local/bin/watchman Managers: CocoaPods: Not Found SDKs: iOS SDK: Platforms:

Steps to reproduce

call https://reactnative.dev/docs/next/permissionsandroid#request

Snack, screenshot, or link to a repository

-

github-actions[bot] commented 10 months ago
:warning: Missing Reproducible Example
:information_source: 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.
github-actions[bot] commented 10 months ago
:warning: Newer Version of React Native is Available!
:information_source: You are on a supported minor version, but it looks like there's a newer patch available - 0.72.6. Please upgrade to the highest patch for your minor or latest and verify if the issue persists (alternatively, create a new project and repro the issue in it). If it does not repro, please let us know so we can close out this issue. This helps us ensure we are looking at issues that still exist in the most recent releases.
cortinico commented 10 months ago

Can you provide a repro?

edstbbz commented 10 months ago

I don't know what kind of reproduction can be provided, since this happens when calling "PermissionsAndroid.request" and it can't be reproduced on purpose, I see that there are errors in production

cortinico commented 10 months ago

I don't know what kind of reproduction can be provided, since this happens when calling "PermissionsAndroid.request" and it can't be reproduced on purpose, I see that there are errors in production

As the bot suggested, you should use either a Snack or this template: https://github.com/new?template_name=reproducer-react-native&template_owner=react-native-community And create a project where the app crashes by invoking the function you mentioned

pe1ros commented 10 months ago

@edstbbz you have problem with implementation permission method but not react native( dont create issue before read docs...))) ) 1) add pemission to AndroidManifest 2) use someth ike that

import { isAndroid } from '@app/constants/Device';
import { PermissionsAndroid } from 'react-native';

export const requestPermissions = async () => {
  try {
    if (isAndroid) {
      return await PermissionsAndroid.request(PermissionsAndroid.PERMISSIONS.POST_NOTIFICATIONS);
    } else {
      return Promise.resolve();
    }
  } catch (error) {
    console.error('requestPermissions: [ERROR] =>', error);
  }
};

3) You can use also this library https://github.com/zoontek/react-native-permissions

edstbbz commented 10 months ago

@pe1ros What kind of nonsense did you write? I know perfectly well how to write code, the problem is that some users have a crash in production ,not that I can't write code.

edstbbz commented 10 months ago

@cortinico https://snack.expo.dev/@edstubbz/great-blue-peanut It's all about the usual request for permission, how to reproduce it 100% I do not know, since the problem occurs for users with a normal request for permissions (this can be seen by the exception), I was not able to reproduce it on purpose

edstbbz commented 10 months ago

On sentry im catch:

screen
pe1ros commented 10 months ago

@edstbbz Let me your code please, it will be faster that "pick finger to the sky" If you request more than one permissions, provide all code place where it is. I will try to help...

edstbbz commented 10 months ago

@pe1ros how can I give you the code? This is not an open source project with a huge code base. And most importantly, I don't understand what you want, because the permission request is used the same everywhere, according to the official api ( const status = await PermissionsAndroid.request(PermissionsAndroid.PERMISSIONS.CAMERA) ). An exception occurs on the native api side

DylanTet commented 10 months ago

So if im reading this right @edstbbz, you're saying that the exception isn't being thrown 100% of the time for you?

ziphr commented 8 months ago

@edstbbz Did you manage to find the issue in the end? I'm facing this exact same problem.

SwhiteMHC commented 7 months ago

I am also experiencing this same problem.

Im using "react-native-vision-camera": "3.1.0"

System:
  OS: macOS 14.2.1
  CPU: (10) arm64 Apple M2 Pro
  Memory: 73.28 MB / 16.00 GB
  Shell:
    version: "5.9"
    path: /bin/zsh
Binaries:
  Node:
    version: 20.8.1
    path: /opt/homebrew/bin/node
  Yarn:
    version: 1.22.19
    path: /opt/homebrew/bin/yarn
  npm:
    version: 10.1.0
    path: /opt/homebrew/bin/npm
  Watchman:
    version: 2023.10.09.00
    path: /opt/homebrew/bin/watchman
Managers:
  CocoaPods:
    version: 1.14.3
    path: /usr/local/bin/pod
SDKs:
  iOS SDK:
    Platforms:
      - DriverKit 23.2
      - iOS 17.2
      - macOS 14.2
      - tvOS 17.2
      - watchOS 10.2
  Android SDK: Not Found
IDEs:
  Android Studio: 2022.3 AI-223.8836.35.2231.10406996
  Xcode:
    version: 15.1/15C65
    path: /usr/bin/xcodebuild
Languages:
  Java:
    version: 11.0.20
    path: /usr/bin/javac
  Ruby:
    version: 2.6.10
    path: /usr/bin/ruby
npmPackages:
  "@react-native-community/cli": Not Found
  react:
    installed: 18.2.0
    wanted: 18.2.0
  react-native:
    installed: 0.72.6
    wanted: 0.72.6
  react-native-macos: Not Found
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: true
  newArchEnabled: false
iOS:
  hermesEnabled: true
  newArchEnabled: false

IMG_2809

mayank-gera commented 5 months ago

Hi Still facing the issues, any fix ?

rsainiWin commented 2 months ago

Facing the same

trucuit commented 2 months ago

same issue: RN 0.63.5 Screenshot 2024-06-20 at 18 15 26

sanduluca commented 1 month ago

We also have this issue using https://github.com/invertase/notifee "react-native": "0.74.3", image

EwaGuziejko commented 3 weeks ago

Same problem here on react-native 0.74.3 -permissions randomly crashes on Android devices

SKHRAPP commented 3 weeks ago

Any Update from this issue ?

rsainiWin commented 3 weeks ago

Same problem here on react-native 0.74.3

cblaze22 commented 3 weeks ago

Same problem here on react-native 0.74.3