Onesignal-android-sdk: Error - "Error updating the user record because of th enull user id" shown as a dialog randomly

Created on 7 May 2020  路  17Comments  路  Source: OneSignal/OneSignal-Android-SDK

Description:

Recently I see an issue in our application, this message is shown as a dialog randomly when I work with our app:
image

Environment

  • Android API Version: 29 and 28 tested
  • SDK Version: 3.13.2
  • Steps to Reproduce Issue:

    1. open your app
    2. work with your app
    3. this dialog shows randomly

    Anything else:

    (crash stacktraces, as well as any other information here)

    I see also this error appeared in the logcat also: "Error updating the user record because of th enull user id"

    Medium Priority

    Most helpful comment

    This is a misleading log and is fixed in Android SDK release 3.15.2

    All 17 comments

    Follow up to this with stacktrace:

    E/OneSignal: Error updating the user record because of th enull user id
    W/System.err: java.lang.InterruptedException
    W/System.err:     at java.util.concurrent.locks.AbstractQueuedSynchronizer.acquireInterruptibly(AbstractQueuedSynchronizer.java:1244)
    W/System.err:     at java.util.concurrent.locks.ReentrantLock.lockInterruptibly(ReentrantLock.java:336)
    W/System.err:     at java.util.concurrent.ArrayBlockingQueue.take(ArrayBlockingQueue.java:384)
    W/System.err:     at com.onesignal.OneSignalSyncServiceUtils$SyncRunnable.run(OneSignalSyncServiceUtils.java:236)
    W/System.err:     at java.lang.Thread.run(Thread.java:764)
    

    edit - Earlier stacktrace at app launch:

    W/System.err: java.lang.InterruptedException
    W/System.err:     at java.lang.Object.wait(Native Method)
    W/System.err:     at java.lang.Object.wait(Object.java:422)
    W/System.err:     at java.lang.Thread.join(Thread.java:1268)
    W/System.err:     at com.onesignal.OneSignalRestClient.makeRequest(OneSignalRestClient.java:118)
    W/System.err:     at com.onesignal.OneSignalRestClient.putSync(OneSignalRestClient.java:95)
    W/System.err:     at com.onesignal.UserStateSynchronizer.doPutSync(UserStateSynchronizer.java:315)
    W/System.err:     at com.onesignal.UserStateSynchronizer.internalSyncUserState(UserStateSynchronizer.java:245)
    W/System.err:     at com.onesignal.UserStateSynchronizer.syncUserState(UserStateSynchronizer.java:213)
    W/System.err:     at com.onesignal.OneSignalStateSynchronizer.syncUserState(OneSignalStateSynchronizer.java:98)
    W/System.err:     at com.onesignal.OneSignalSyncServiceUtils$SyncRunnable.run(OneSignalSyncServiceUtils.java:246)
    W/System.err:     at java.lang.Thread.run(Thread.java:764)
    E/OneSignal: Error updating the user record because of th enull user id
    

    Howdy,
    Could you please include your initialization code? Make sure it is the first thing you are calling from the OneSignal SDK.

    We have a wrapper around the OneSignal sdk, it's initialized as such:

    init {
        try {
            OneSignal.startInit(context)
                    .unsubscribeWhenNotificationsAreDisabled(true)
                    .inFocusDisplaying(OneSignal.OSInFocusDisplayOption.Notification)
                    .setNotificationReceivedHandler(this)
                    .setNotificationOpenedHandler(this)
                    .init()
            OneSignal.idsAvailable { userId: String?, registrationId: String? ->
                Timber.v { "idsAvailable, user: $userId reg: $registrationId" }
                if (userId != null) {
                    sharedPrefs.edit().putString("playerId", userId).apply()
                    Sentry.setExtra("playerId", userId)
                }
            }
            OneSignal.addSubscriptionObserver(this)
        } catch (e: Exception) {
            Timber.e(e)
        }
    }
    

    context is passed in by Dagger as the ApplicationContext. The class is annotated with @Singleton

    This is called in application onCreate:

    OneSignal.startInit(this)
                .setNotificationOpenedHandler(NotificationClickHandler(applicationContext))
                .inFocusDisplaying(OneSignal.OSInFocusDisplayOption.None)
                .unsubscribeWhenNotificationsAreDisabled(true)
                .init()
    

    I also disable this error by this code
    if (BuildConfig.DEBUG) { OneSignal.setLogLevel(OneSignal.LOG_LEVEL.NONE, OneSignal.LOG_LEVEL.NONE) }
    Which previously set to LOG_LEVEL.ERROR

    This is still occurring with the latest 3.14.0

    W/System.err: java.lang.InterruptedException
    W/System.err:     at java.lang.Object.wait(Native Method)
    W/System.err:     at java.lang.Object.wait(Object.java:422)
    W/System.err:     at java.lang.Thread.join(Thread.java:1268)
    W/System.err:     at com.onesignal.OneSignalRestClient.makeRequest(OneSignalRestClient.java:118)
    W/System.err:     at com.onesignal.OneSignalRestClient.putSync(OneSignalRestClient.java:95)
    W/System.err:     at com.onesignal.UserStateSynchronizer.doPutSync(UserStateSynchronizer.java:315)
    W/System.err:     at com.onesignal.UserStateSynchronizer.internalSyncUserState(UserStateSynchronizer.java:245)
    W/System.err:     at com.onesignal.UserStateSynchronizer.syncUserState(UserStateSynchronizer.java:213)
    W/System.err:     at com.onesignal.OneSignalStateSynchronizer.syncUserState(OneSignalStateSynchronizer.java:98)
    W/System.err:     at com.onesignal.OneSignalSyncServiceUtils$SyncRunnable.run(OneSignalSyncServiceUtils.java:246)
    W/System.err:     at java.lang.Thread.run(Thread.java:764)
    E/OneSignal: Error updating the user record because of the null user id
    

    This happens after app shutdown, and the service restarts the application process in the background. At the time this error is thrown, the application has successfully started, OneSignal has successfully initialized, and the idsAvailable callback has been called with both userId and registrationId set.

    3 1/2 minutes later with the app still closed, the following is output in the logcat:

    W/System.err: java.lang.InterruptedException
    W/System.err:     at java.util.concurrent.locks.AbstractQueuedSynchronizer.acquireInterruptibly(AbstractQueuedSynchronizer.java:1244)
    W/System.err:     at java.util.concurrent.locks.ReentrantLock.lockInterruptibly(ReentrantLock.java:336)
    W/System.err:     at java.util.concurrent.ArrayBlockingQueue.take(ArrayBlockingQueue.java:384)
    W/System.err:     at com.onesignal.OneSignalSyncServiceUtils$SyncRunnable.run(OneSignalSyncServiceUtils.java:236)
    W/System.err:     at java.lang.Thread.run(Thread.java:764)
    E/OneSignal: Error updating the user record because of the null user id
    

    still experiencing this issue, Please has anyone soled it ?

    I am seeing in my logcat. I just updated all the dependencies with latest versions but still

    java.lang.InterruptedException
    at java.lang.Object.wait(Native Method)
    at java.lang.Object.wait(Object.java:422)
    at java.lang.Thread.join(Thread.java:1290)
    at com.onesignal.OneSignalRestClient.makeRequest(OneSignalRestClient.java:118)
    at com.onesignal.OneSignalRestClient.putSync(OneSignalRestClient.java:95)
    at com.onesignal.UserStateSynchronizer.doPutSync(UserStateSynchronizer.java:315)
    at com.onesignal.UserStateSynchronizer.internalSyncUserState(UserStateSynchronizer.java:245)
    at com.onesignal.UserStateSynchronizer.syncUserState(UserStateSynchronizer.java:213)
    at com.onesignal.OneSignalStateSynchronizer.syncUserState(OneSignalStateSynchronizer.java:98)
    at com.onesignal.OneSignalSyncServiceUtils$SyncRunnable.run(OneSignalSyncServiceUtils.java:246)
    at java.lang.Thread.run(Thread.java:784)
    
    

    I am using

    dependencies {
            classpath 'gradle.plugin.com.onesignal:onesignal-gradle-plugin:[0.12.7, 0.99.99]'
        }
    

    and

    implementation "com.onesignal:OneSignal:3.14.0"

    I have the same problem, but with latest Xamarin SDK 3.8.2. Im not receiving notifications with the closed app and NotificationExtender implemented for Android

    Is there an update? My company is about to go live with OneSignal and this is an issue. Can this be worked around by setLogLevel() to OneSignal.LOG_LEVEL.NONE (for visualLevel)? Seeking confirmation that the rendering of this dialog is caused by setting the visualLevel LOG_LEVEL to ERROR or lower

    @cgsbanno ,
    setLogLevel is useful for debugging. But even then in most cases the visualLevel should be set to none since it is much easier to capture the output in a connected device's logcat. Are you setting the log level in production?

    In either case, the error is an issue on its own that we are investigating.

    Thank you everyone for your patience.

    @rgomezp Yes I've already done that, I was just looking for confirmation that this error dialog was being rendered on devices due to visualLevel and not for some other reason (which you've confirmed). And yes visualLevel was only set to non-NONE on our debug builds.

    In either case, the error is an issue on its own that we are investigating.

    Per previous reports, it's my understanding that the underlying issue under some circumstances is preventing users from receiving push notifications, is this correct?

    @cgsbanno ,
    After further investigation, it seems this issue is related to location and not push at all so this shouldn't be preventing users from receiving push notifications. We are currently working to resolve it. Cheers

    @rgomezp I am using unity SDK and my app haven't got any noti too, cannot even send test noti (it sent and delivered but not being shown in device, ios is fine with the same noti)

    There was this same log message from my android. Is this problem still persist? Is it the same problem?

    07-30 16:26:51.592 17831 18612 I OneSignal: Location permissions not added on AndroidManifest file
    07-30 16:26:51.593 17831 18612 E OneSignal: Error updating the user record because of the null user id
    

    This is a misleading log and is fixed in Android SDK release 3.15.2

    @mikechoch If so I have created https://github.com/OneSignal/OneSignal-Unity-SDK/issues/310 is it related?

    @Thaina ,
    From first glance it looks like the same error. Yes this should be resolved and will be included in the next Unity release.

    Was this page helpful?
    0 / 5 - 0 ratings