OneSignal-Android-SDK icon indicating copy to clipboard operation
OneSignal-Android-SDK copied to clipboard

[Bug]: When the app is in background - On received push notification click - it crashes the app.

Open tanveer-noknok opened this issue 2 years ago • 8 comments

What happened?

The application crashes whenever it receives a notification when it is in the background.

Steps to reproduce?

1. Launch the application.
2. Minimize the application.
3. Send a notification to the application.
4. Click on the notification.
5. Observe the application crash.

What did you expect to happen?

I expect the app not to crash whenever it receives a notification in the background.

OneSignal Android SDK version

Release 5.0.5

Android version

13, 12, 11, 10, 9

Specific Android models

Galaxy A53 5G
Galaxy A32
Galaxy S22 Ultra
Galaxy S23 Ultra
Galaxy Note20 Ultra 5G
Huawei Y9 2019
Nova 3
Honor 8X
Tecno Spark 8C
Camon
Poco X3 NFC

Relevant log output

Fatal Exception: java.lang.RuntimeException: Unable to start receiver com.onesignal.notifications.receivers.FCMBroadcastReceiver: java.lang.NullPointerException
       at android.app.ActivityThread.handleReceiver(ActivityThread.java:4362)
       at android.app.ActivityThread.access$1700(ActivityThread.java:293)
       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2166)
       at android.os.Handler.dispatchMessage(Handler.java:106)
       at android.os.Looper.loop(Looper.java:263)
       at android.app.ActivityThread.main(ActivityThread.java:8292)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:612)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1006)
----------------------------------------------------------------------------------------------------------------------------

Fatal Exception: java.lang.RuntimeException: Unable to start receiver com.onesignal.notifications.receivers.NotificationDismissReceiver: java.lang.NullPointerException
       at android.app.ActivityThread.handleReceiver(ActivityThread.java:4905)
       at android.app.ActivityThread.-$$Nest$mhandleReceiver()
       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2498)
       at android.os.Handler.dispatchMessage(Handler.java:106)
       at android.os.Looper.loopOnce(Looper.java:230)
       at android.os.Looper.loop(Looper.java:319)
       at android.app.ActivityThread.main(ActivityThread.java:8893)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:608)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1103)
----------------------------------------------------------------------------------------------------------------------------
Fatal Exception: java.lang.RuntimeException: Unable to start receiver com.onesignal.notifications.receivers.NotificationDismissReceiver: java.lang.reflect.InvocationTargetException
       at android.app.ActivityThread.handleReceiver(ActivityThread.java:4905)
       at android.app.ActivityThread.-$$Nest$mhandleReceiver()
       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2498)
       at android.os.Handler.dispatchMessage(Handler.java:106)
       at android.os.Looper.loopOnce(Looper.java:230)
       at android.os.Looper.loop(Looper.java:319)
       at android.app.ActivityThread.main(ActivityThread.java:8893)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:608)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1103)

----------------------------------------------------------------------------------------------------------------------------

Caused by java.lang.NullPointerException:
       at com.onesignal.core.internal.application.impl.ApplicationService.getAppContext(ApplicationService.kt:39)
       at com.onesignal.core.internal.device.impl.DeviceService.packageInstalledAndEnabled(DeviceService.kt:106)
       at com.onesignal.core.internal.device.impl.DeviceService.isGMSInstalledAndEnabled(DeviceService.kt:101)
       at com.onesignal.core.internal.device.impl.DeviceService.supportsGooglePush(DeviceService.kt:84)
       at com.onesignal.core.internal.device.impl.DeviceService.getDeviceType(DeviceService.kt:41)
       at com.onesignal.core.internal.device.impl.DeviceService.isAndroidDeviceType(DeviceService.kt:18)
       at com.onesignal.location.LocationModule$register$1.invoke(LocationModule.kt:31)
       at com.onesignal.location.LocationModule$register$1.invoke(LocationModule.kt:28)
       at com.onesignal.common.services.ServiceRegistrationLambda.resolve(ServiceRegistration.kt:164)
       at com.onesignal.common.services.ServiceProvider.getServiceOrNull(ServiceProvider.kt:79)
       at com.onesignal.common.services.ServiceProvider.getService(ServiceProvider.kt:67)
       at com.onesignal.common.services.ServiceRegistrationReflection.resolve(ServiceRegistration.kt:82)
       at com.onesignal.common.services.ServiceProvider.getServiceOrNull(ServiceProvider.kt:79)
       at com.onesignal.common.services.ServiceProvider.getService(ServiceProvider.kt:67)
       at com.onesignal.common.services.ServiceRegistrationReflection.resolve(ServiceRegistration.kt:82)
       at com.onesignal.common.services.ServiceProvider.getServiceOrNull(ServiceProvider.kt:79)
       at com.onesignal.common.services.ServiceProvider.getService(ServiceProvider.kt:67)
       at com.onesignal.common.services.ServiceProvider.getService$com_onesignal_core(ServiceProvider.kt:39)
       at com.onesignal.internal.OneSignalImp.initWithContext(OneSignalImp.kt:234)
       at com.onesignal.OneSignal.initWithContext(OneSignal.kt:208)
       at com.onesignal.notifications.receivers.FCMBroadcastReceiver.onReceive(FCMBroadcastReceiver.kt:26)
       at android.app.ActivityThread.handleReceiver(ActivityThread.java:4346)
       at android.app.ActivityThread.access$1700(ActivityThread.java:293)
       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2166)
       at android.os.Handler.dispatchMessage(Handler.java:106)
       at android.os.Looper.loop(Looper.java:263)
       at android.app.ActivityThread.main(ActivityThread.java:8292)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:612)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1006)


Code of Conduct

  • [X] I agree to follow this project's Code of Conduct

tanveer-noknok avatar Jan 19 '24 11:01 tanveer-noknok

@tanveer-noknok thank you for the report! We're looking into this.

jennantilla avatar Jan 24 '24 02:01 jennantilla

Any update on this? We have experienced around 100 crashes so far on Firebase.

tanveer-noknok avatar Jan 29 '24 06:01 tanveer-noknok

So did I

M2dL1fe avatar Jan 29 '24 06:01 M2dL1fe

Hi @tanveer-noknok and @M2dL1fe

  • Is this something you are able to reproduce?
  • Can you share the Android devices and Android versions experiencing this crash?
  • What percent of devices appear to be affected?

nan-li avatar Jan 29 '24 06:01 nan-li

  • We (Developers , QA) did our best to reproduce this issue but all in vain.
  • It is only logged to firebase as single crash having multiple variants.
  • 95% crashes are in background.
  • 64% affected devices are android 13 and this starts from android 9 to 14

Affected Devices. Samsung Devices 79% of total crashes

Galaxy A71 7% Galaxy A52s 5G 7% Galaxy A52 7%

Galaxy A33 5G 7%

Galaxy A72 5%

Galaxy A32 5%

Galaxy A22 5G 5%

Galaxy Tab A7 Lite 3%

Galaxy S23 Ultra 3%

Galaxy S22+ 3%

Galaxy Note20 Ultra 3%

Galaxy Note20 5G 3%

Galaxy Note203%

Galaxy S21 Ultra 5G 2%

Galaxy S20+ 2%

Galaxy S9+ 2%

Galaxy A73 5G 2%

Galaxy A51 2%

Galaxy A34 5G 2%

Galaxy A23 2%

Galaxy A14 2%

Galaxy A13 2%


Huawei 19%

Nova 3 5% Nova 3i 5% Huawei Y9 Prime 2019 2% Honor 8X 3% Huawei Y9 2019 2% P20 Pro 2%


Google 2% Pixel 6


Others Tecno Spark 8C Camon Poco X3 NFC

tanveer-noknok avatar Jan 29 '24 07:01 tanveer-noknok

@nan-li any comments please !

tanveer-noknok avatar Feb 02 '24 12:02 tanveer-noknok

Hi @tanveer-noknok, In your original post you shared these steps to reproduce, but you were not able to reproduce it yourselves, correct?

1. Launch the application.
2. Minimize the application.
3. Send a notification to the application.
4. Click on the notification.
5. Observe the application crash.

These reproduction steps are information you figured out from the Firebase crash logs only? I am trying to confirm these reproduction steps are accurate for this crash.

nan-li avatar Feb 02 '24 18:02 nan-li

These reproduction steps are information you figured out from the Firebase crash logs only?

yes we are unable to reproduce it and the steps are from the crash logs only.

tanveer-noknok avatar Feb 03 '24 15:02 tanveer-noknok

@tanveer-noknok A potential fix related to getting a null pointer exception by calling getAppContext has been released in version 5.1.6. Please let us know if the crash still occurs after upgrading to 5.1.6, and we will investigate further.

jinliu9508 avatar Mar 11 '24 20:03 jinliu9508

https://github.com/OneSignal/OneSignal-Android-SDK/releases/tag/5.1.6

jinliu9508 avatar Mar 11 '24 20:03 jinliu9508