invertase / notifee

⚛️ A feature rich notifications library for React Native.
https://notifee.app
Apache License 2.0
1.86k stars 226 forks source link

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

Closed Willham12 closed 1 week ago

Willham12 commented 3 months ago

Refer to https://github.com/facebook/react-native/issues/41077

"@notifee/react-native": "7.8.2" "react-native": "0.74.3",


       Fatal Exception: 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:4744)
       at android.view.ViewGroup.dispatchCancelPendingInputEvents(ViewGroup.java:4744)
       at android.view.ViewGroup.dispatchCancelPendingInputEvents(ViewGroup.java:4744)
       at android.view.ViewGroup.dispatchCancelPendingInputEvents(ViewGroup.java:4744)
       at android.view.ViewGroup.dispatchCancelPendingInputEvents(ViewGroup.java:4744)
       at android.view.ViewGroup.dispatchCancelPendingInputEvents(ViewGroup.java:4744)
       at android.view.ViewGroup.dispatchCancelPendingInputEvents(ViewGroup.java:4744)
       at android.view.ViewGroup.dispatchCancelPendingInputEvents(ViewGroup.java:4744)
       at android.view.ViewGroup.dispatchCancelPendingInputEvents(ViewGroup.java:4744)
       at android.view.ViewGroup.dispatchCancelPendingInputEvents(ViewGroup.java:4744)
       at android.view.ViewGroup.dispatchCancelPendingInputEvents(ViewGroup.java:4744)
       at android.view.ViewGroup.dispatchCancelPendingInputEvents(ViewGroup.java:4744)
       at android.view.ViewGroup.dispatchCancelPendingInputEvents(ViewGroup.java:4744)
       at android.view.ViewGroup.dispatchCancelPendingInputEvents(ViewGroup.java:4744)
       at android.view.View.cancelPendingInputEvents(View.java:22787)
       at android.app.Activity.cancelInputsAndStartExitTransition(Activity.java:5880)
       at android.app.Activity.startActivityForResult(Activity.java:6683)
       at android.app.Activity.requestPermissions(Activity.java:5699)
       at android.app.Activity.requestPermissions(Activity.java:5604)
       at com.facebook.react.ReactActivityDelegate.requestPermissions(ReactActivityDelegate.java:185)
       at com.facebook.react.ReactActivity.requestPermissions(ReactActivity.java:115)
       at io.invertase.notifee.NotifeeApiModule.requestPermission(NotifeeApiModule.java:267)
       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:146)
       at com.facebook.jni.NativeRunnable.run(NativeRunnable.java)
       at android.os.Handler.handleCallback(Handler.java:959)
       at android.os.Handler.dispatchMessage(Handler.java:100)
       at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java)
       at android.os.Looper.loopOnce(Looper.java:232)
       at android.os.Looper.loop(Looper.java:317)
       at com.facebook.react.bridge.queue.MessageQueueThreadImpl$4.run(MessageQueueThreadImpl.java:233)
       at java.lang.Thread.run(Thread.java:1012)
sanduluca commented 3 months ago

We also have this issue.

github-actions[bot] commented 2 months ago

Hello 👋, to help manage issues we automatically close stale issues.

This issue has been automatically marked as stale because it has not had activity for quite some time.Has this issue been fixed, or does it still require attention?

This issue will be closed in 15 days if no further activity occurs.

Thank you for your contributions.

Hejleh-Ejada commented 2 months ago

@sanduluca did you solve the issue ?

github-actions[bot] commented 1 month ago

Hello 👋, to help manage issues we automatically close stale issues.

This issue has been automatically marked as stale because it has not had activity for quite some time.Has this issue been fixed, or does it still require attention?

This issue will be closed in 15 days if no further activity occurs.

Thank you for your contributions.

sanduluca commented 1 month ago

@sanduluca did you solve the issue ?

No. We still have the crashes. Seems that it comes from react native itself

github-actions[bot] commented 1 week ago

Hello 👋, to help manage issues we automatically close stale issues.

This issue has been automatically marked as stale because it has not had activity for quite some time.Has this issue been fixed, or does it still require attention?

This issue will be closed in 15 days if no further activity occurs.

Thank you for your contributions.

mikehardy commented 1 week ago

This is probably related to the View / Activity going away via some sort of user dismiss or not being ready in time - both (in this hypothesis) in a race with the code trying to access the View / Activity, such that when the code finally gets to the point where it wants to do something with the View / Activity it is null and causes the crash

This stack frame is the only place we have the ability to affect what happens next:

   at io.invertase.notifee.NotifeeApiModule.requestPermission(NotifeeApiModule.java:267)

...if that line of code were wrapped in a try/catch and caught Exception it would be possible to at least not crash, and if the API of the requestPermission call allowed for promise rejection then we could reject and expose the problem to your app calling code so you could handle it

A PR to do at least the catch + native log of the problem would be most welcome, if the API was already async with Promise going in then a reject of the promise would be fantastic as part of the PR as well.