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]: NullPointerException at SessionService.getScheduleBackgroundRunIn #2183

Closed
fanwgwg opened this issue Aug 25, 2024 · 14 comments
Closed
Labels
Bug WIP Work In Progress

Comments

@fanwgwg
Copy link

fanwgwg commented Aug 25, 2024

What happened?

The app crashes in background

screenshot-20240825-152154
screenshot-20240825-152058

Steps to reproduce?

Caused by java.lang.NullPointerException:
       at com.onesignal.session.internal.session.impl.SessionService.getScheduleBackgroundRunIn(SessionService.kt:43)
       at com.onesignal.core.internal.background.impl.BackgroundManager.scheduleBackground(BackgroundManager.kt:86)
       at com.onesignal.core.internal.background.impl.BackgroundManager.onUnfocused(BackgroundManager.kt)
       at com.onesignal.core.internal.application.impl.ApplicationService$handleLostFocus$1.invoke(ApplicationService.kt:377)
       at com.onesignal.core.internal.application.impl.ApplicationService$handleLostFocus$1.invoke(ApplicationService.kt:377)
       at com.onesignal.common.events.EventProducer.fire(EventProducer.kt:50)
       at com.onesignal.core.internal.application.impl.ApplicationService.handleLostFocus(ApplicationService.kt:377)
       at com.onesignal.core.internal.application.impl.ApplicationService.onActivityStopped(ApplicationService.kt:198)
       at android.app.Application.dispatchActivityStopped(Application.java:258)
       at android.app.Activity.onStop(Activity.java:1950)
       at androidx.fragment.app.FragmentActivity.onStop(FragmentActivity.java)
       at androidx.appcompat.app.AppCompatActivity.onStop(AppCompatActivity.java)
       at android.app.Instrumentation.callActivityOnStop(Instrumentation.java:1383)
       at android.app.Activity.performStop(Activity.java:7568)
       at android.app.ActivityThread.performStopActivityInner(ActivityThread.java:4266)
       at android.app.ActivityThread.handleStopActivity(ActivityThread.java:4318)
       at android.app.ActivityThread.-wrap26()
       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1757)
       at android.os.Handler.dispatchMessage(Handler.java:106)
       at android.os.Looper.loop(Looper.java:164)
       at android.app.ActivityThread.main(ActivityThread.java:7000)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:441)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1408)


### What did you expect to happen?

The app shouldn't crash

### OneSignal Android SDK version

5.1.20

### Android version

14

### Specific Android models

_No response_

### Relevant log output

_No response_

### Code of Conduct

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

<!-- probot = {"onesignal-probot":{"response_time_in_business_days":5}} -->
@amrutkarsuraj
Copy link

Fatal Exception: java.lang.RuntimeException
Unable to stop activity {Package Name.MainActivity}: java.lang.NullPointerException

Caused by java.lang.NullPointerException
com.onesignal.session.internal.session.impl.SessionService.getScheduleBackgroundRunIn (SessionService.kt:43)
com.onesignal.core.internal.background.impl.BackgroundManager.scheduleBackground (BackgroundManager.kt:86)
com.onesignal.core.internal.background.impl.BackgroundManager.onUnfocused (BackgroundManager.kt:78)
com.onesignal.core.internal.application.impl.ApplicationService$handleLostFocus$1.invoke (ApplicationService.kt:377)
com.onesignal.core.internal.application.impl.ApplicationService$handleLostFocus$1.invoke (ApplicationService.kt:377)
com.onesignal.common.events.EventProducer.fire (EventProducer.kt:48)
com.onesignal.core.internal.application.impl.ApplicationService.handleLostFocus (ApplicationService.kt:377)
com.onesignal.core.internal.application.impl.ApplicationService.onActivityStopped (ApplicationService.kt:198)
android.app.Application.dispatchActivityStopped (Application.java:493)

OneSignal Android SDK version

onesignal_flutter: ^5.0.4

Android version

Android 12

Device

Brand:Vivo
Model:V2058

@michael-winkler
Copy link

Fatal Exception: java.lang.RuntimeException: Unable to stop activity {>>>HIDDEN_PACKAGNE_NAME<<</com.onesignal.notifications.activities.NotificationOpenedActivity}: java.lang.NullPointerException
       at android.app.ActivityThread.callActivityOnStop(ActivityThread.java:5906)
       at android.app.ActivityThread.performStopActivityInner(ActivityThread.java:5872)
       at android.app.ActivityThread.handleStopActivity(ActivityThread.java:5943)
       at android.app.servertransaction.TransactionExecutor.performLifecycleSequence(TransactionExecutor.java:240)
       at android.app.servertransaction.TransactionExecutor.cycleToPath(TransactionExecutor.java:205)
       at android.app.servertransaction.TransactionExecutor.executeLifecycleState(TransactionExecutor.java:177)
       at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:98)
       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2685)
       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:8919)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:578)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1103)
        
Caused by java.lang.NullPointerException:
       at com.onesignal.session.internal.session.impl.SessionService.getScheduleBackgroundRunIn(SessionService.kt:43)
       at com.onesignal.core.internal.background.impl.BackgroundManager.scheduleBackground(BackgroundManager.kt:86)
       at com.onesignal.core.internal.background.impl.BackgroundManager.onUnfocused(BackgroundManager.kt)
       at com.onesignal.core.internal.application.impl.ApplicationService$handleLostFocus$1.invoke(ApplicationService.kt:377)
       at com.onesignal.core.internal.application.impl.ApplicationService$handleLostFocus$1.invoke(ApplicationService.kt:377)
       at com.onesignal.common.events.EventProducer.fire(EventProducer.kt:50)
       at com.onesignal.core.internal.application.impl.ApplicationService.handleLostFocus(ApplicationService.kt:377)
       at com.onesignal.core.internal.application.impl.ApplicationService.onActivityStopped(ApplicationService.kt:198)
       at android.app.Application.dispatchActivityStopped(Application.java:510)
       at android.app.Activity.dispatchActivityStopped(Activity.java:1589)
       at android.app.Activity.onStop(Activity.java:2789)
       at android.app.Instrumentation.callActivityOnStop(Instrumentation.java:1623)
       at android.app.Activity.performStop(Activity.java:9236)
       at android.app.ActivityThread.callActivityOnStop(ActivityThread.java:5898)
       at android.app.ActivityThread.performStopActivityInner(ActivityThread.java:5872)
       at android.app.ActivityThread.handleStopActivity(ActivityThread.java:5943)
       at android.app.servertransaction.TransactionExecutor.performLifecycleSequence(TransactionExecutor.java:240)
       at android.app.servertransaction.TransactionExecutor.cycleToPath(TransactionExecutor.java:205)
       at android.app.servertransaction.TransactionExecutor.executeLifecycleState(TransactionExecutor.java:177)
       at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:98)
       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2685)
       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:8919)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:578)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1103)
        

OneSignal 5.1.20 - Android

@michael-winkler
Copy link

@jkasten2 Was this fixed in 5.1.20 ?

@jkasten2
Copy link
Member

jkasten2 commented Sep 6, 2024

@fanwgwg @amrutkarsuraj @michael-winkler Thanks for reporting, this looks to be a very rare bug introduced in 5.1.19.

Based on the stack traces it looks like this happens if the app is backgrounded very shortly (~10-100ms) after OneSignal.initWithContext is called.

  • SessionService.start() was moved to a background thread to prevent some ANRs, however this almost makes this rare race condition possible.

@michael-winkler
Copy link

A fix would be great @jkasten2
🙂

@aybarska
Copy link

any fixes yet ?

@Samin-roadsurfer
Copy link

we see the exact same. crash in our logs, although we are using the onesignal_flutter .
any update on when it is gonna fix?

@SimonFrandi
Copy link

We also received a lot of crash information, and the crash indicator suddenly went up. When will it be fixed?

@SimonFrandi
Copy link

We also received a lot of crash information, and the crash indicator suddenly went up. When will it be fixed?
Flutter:
onesignal_flutter: ^5.2.1
Android:
implementation 'com.onesignal:OneSignal:5.1.21'

@joaquinvaz
Copy link

We are having this crash in production too, please fix

@mtebele
Copy link

mtebele commented Oct 17, 2024

Same here in React Native SDK! Please fix it asap

@michael-winkler
Copy link

The Issue still exist..

@junaidalibacha
Copy link

Same issue in onesignal_flutter: ^5.2.6, need to fix please

@jinliu9508 jinliu9508 added WIP Work In Progress Bug labels Nov 6, 2024
@jinliu9508
Copy link
Contributor

This occurs in a rare case and is fixed in Android 5.1.25. Please upgrade to the latest SDK version and let us know if you see more of these.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug WIP Work In Progress
Projects
None yet
Development

No branches or pull requests

13 participants