OneSignal / OneSignal-Unity-SDK

OneSignal is a free push notification service for mobile apps. This plugin makes it easy to integrate your Unity app with OneSignal. https://onesignal.com
Other
222 stars 61 forks source link

[Bug]: ANR com.onesignal.OSSubscriptionObserver.onOSSubscriptionChanged #616

Open shefich opened 1 year ago

shefich commented 1 year ago

What happened?

Errors from the Google Play console. ANRs happen.

Steps to reproduce?

1. Install OneSignal SDK in Unity.

What did you expect to happen?

I expected not to see the ANRs.

Unity version

2021.3.26 2020.3.48

OneSignal Unity SDK version

3.0.10 3.0.11

Platform

Android

Relevant log output

#00  pc 0x00000000000bbb68  /apex/com.android.runtime/lib64/bionic/libc.so (nanosleep+8)
  #01  pc 0x00000000004b210c  /data/app/com.xxx.xxx-QEcGqZDCNiW86MdL-cVT1w==/lib/arm64/libil2cpp.so
  #02  pc 0x00000000004bed5c  /data/app/com.xxx.xxx-QEcGqZDCNiW86MdL-cVT1w==/lib/arm64/libil2cpp.so
  #03  pc 0x00000000004d5130  /data/app/com.xxx.xxx-QEcGqZDCNiW86MdL-cVT1w==/lib/arm64/libil2cpp.so
  #04  pc 0x000000000048214c  /data/app/com.xxx.xxx-QEcGqZDCNiW86MdL-cVT1w==/lib/arm64/libil2cpp.so
  #05  pc 0x000000000029c824  /data/app/com.xxx.xxx-QEcGqZDCNiW86MdL-cVT1w==/lib/arm64/libunity.so
  #06  pc 0x0000000000156d1c  /data/app/com.xxx.xxx-QEcGqZDCNiW86MdL-cVT1w==/lib/arm64/libunity.so
  #07  pc 0x0000000000156c34  /data/app/com.xxx.xxx-QEcGqZDCNiW86MdL-cVT1w==/lib/arm64/libunity.so
  at com.unity3d.player.ReflectionHelper.nativeProxyInvoke (Native method)
  at com.unity3d.player.ReflectionHelper.a (unavailable)
  at com.unity3d.player.ReflectionHelper$1.invoke (unavailable)
  at java.lang.reflect.Proxy.invoke (Proxy.java:1006)
  at com.onesignal.OSSubscriptionObserver.onOSSubscriptionChanged (OSSubscriptionObserver.java)
  at java.lang.reflect.Method.invoke (Native method)
  at com.onesignal.OSObservable$1.run (OSObservable.java:87)
  at android.os.Handler.handleCallback (Handler.java:900)
  at android.os.Handler.dispatchMessage (Handler.java:103)
  at android.os.Looper.loop (Looper.java:219)
  at android.app.ActivityThread.main (ActivityThread.java:8668)
  at java.lang.reflect.Method.invoke (Native method)
  at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:513)
  at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1109)

Code of Conduct

shefich commented 1 year ago

Any news? Too many ANRs!

shepherd-l commented 1 year ago

Sorry for the late response

What is your code in your push subscription changed callback? It might be causing the issue

shefich commented 1 year ago

Don't have any callbacks for subscription. So the issue could be with the code/logic in your code or native code. The only my code is the code which asks for push permission:

var currentStatus = OneSignal.Default.NotificationPermission;
if (currentStatus == NotificationPermission.NotDetermined) {
    var response = await OneSignal.Default.PromptForPushNotificationsWithUserResponse();
    if (response == NotificationPermission.Authorized) {
        // user accepted push notifications
        if (PlayerPrefs.GetInt("postPushes", 1) == 1) StartCoroutine(SetDailyReminder());
    }
} else
{
    if (PlayerPrefs.GetInt("postPushes", 1) == 1) StartCoroutine(SetDailyReminder());
}
shepherd-l commented 1 year ago

Thanks for the info!

I was unable to reproduce this issue myself Are you able to reproduce the issue?

Can you provide the devices the issue occurs on and what version of Android they are on

shefich commented 1 year ago

Android 11. Samsung devices A20, A01. These devices are from Crashlytics. Can't find the Google Play devices (time passed and there's no such filters as "key" in Crashlytics).

shefich commented 1 year ago

More devices: HUAWEI HWMAR, HONOR HWKSA-M, HONOR HWSTK-HF, HUAWEI HWPOT-H, HUAWEI HWSTK-HF. Android OSs 9 and 10. And full stacktrace attached. stacktrace.log