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

[Bug]: ANR during SDK Initialization #2226

Open
1 task done
maximkir-fl opened this issue Dec 3, 2024 · 5 comments
Open
1 task done

[Bug]: ANR during SDK Initialization #2226

maximkir-fl opened this issue Dec 3, 2024 · 5 comments

Comments

@maximkir-fl
Copy link

maximkir-fl commented Dec 3, 2024

What happened?

My code follows the integration instructions and initializes the OneSignal SDK during Application.onCreate.
After upgrading to version 5.1.25, I saw the following ANR, originating from the initialization process.

main (runnable):tid=1 systid=22401 
at com.onesignal.common.events.EventProducer.access$getSubscribers$p(EventProducer.kt)
at com.onesignal.common.events.EventProducer.<init>(EventProducer.kt)
at com.onesignal.core.internal.application.impl.ApplicationService.<init>(ApplicationService.kt:31)
at java.lang.reflect.Constructor.newInstance0(Native method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:343)
at com.onesignal.common.services.ServiceRegistrationReflection.resolve(ServiceRegistration.kt:89)
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:35)
at com.onesignal.internal.OneSignalImp.initWithContext(OneSignalImp.kt:203)
at com.onesignal.OneSignal.initWithContext(OneSignal.java:135)
at com.myapp.app.Application.onCreate(Application.kt:17)

Steps to reproduce?

1. Follow integration instructions and run the application

What did you expect to happen?

Smooth background initialization.

OneSignal Android SDK version

5.1.25

Android version

14

Specific Android models

No response

Relevant log output

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct
@jinliu9508
Copy link
Contributor

Hello @maximkir-fl, thank you for reporting to us! To help us better understanding your issue, could you post the code where you call OneSignal.initWithContext?

@maximkir-fl
Copy link
Author

Sure, here it is:

import android.app.Application
import com.onesignal.OneSignal

open class Application : Application() {
    override fun onCreate() {
        super.onCreate()
        OneSignal.initWithContext(this, getString(R.string.one_signal_app_id))
    }
}

@jinliu9508
Copy link
Contributor

I don't see any issues with your code here, assuming the app ID is valid. Are you able to reliably reproduce this ANR? If not, have you noticed any specific pattern when this ANR occurs? Also, have you implemented any OneSignal lifecycle listener?

@maximkir-fl
Copy link
Author

I did not implement any lifecycle listeners.
My previous version was 5.1.22, where we experienced app crashes due to #2212

Once updated to 5.1.25 the ANRs started to show up.

@jinliu9508
Copy link
Contributor

@maximkir-fl The stack trace is from the runnable main thread and did not suggest what is blocking it. Could you paste the complete stack trace that shows where the thread has been blocked?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants