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]: NullReferenceException : Object reference not set to an instance of an object - GetTags #472

Closed
1 task done
RaphaelNSG opened this issue Apr 6, 2022 · 9 comments

Comments

@RaphaelNSG
Copy link

RaphaelNSG commented Apr 6, 2022

What happened?

I updated my project to OneSignal 3.0 and everything was working fine, but some users are reporting an error. It seems related with GetTags method, but i don't know what is causing this error.

Steps to reproduce?

1. Install the OneSignal 3.0
2. Call the `GetTags` method

What did you expect to happen?

I expected to call the GetTags method and receive no error.

Unity version

2019.4.35f1

OneSignal Unity SDK version

3.0.0

Platform

Android and IOS

Relevant log output

Non-fatal Exception: java.lang.Exception: NullReferenceException : Object reference not set to an instance of an object.
       at OneSignalService+<SendIncrementalData>d__0.MoveNext(OneSignalService+<SendIncrementalData>d__0)
       at System.Threading.ContextCallback.Invoke(System.Threading.ContextCallback)
       at System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext)
       at System.Runtime.CompilerServices.AsyncMethodBuilderCore+MoveNextRunner.Run(System.Runtime.CompilerServices.AsyncMethodBuilderCore+MoveNextRunner)
       at System.Action.Invoke(System.Action)
       at System.Threading.ContextCallback.Invoke(System.Threading.ContextCallback)
       at System.Threading.Tasks.AwaitTaskContinuation.RunCallback(System.Threading.Tasks.AwaitTaskContinuation)
       at System.Threading.Tasks.Task.FinishContinuations(System.Threading.Tasks.Task)
       at System.Threading.Tasks.Task`1[TResult].TrySetResult(System.Threading.Tasks.Task`1[TResult])
       at System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1[TResult].SetResult(System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1[TResult])
       at OneSignalSDK.OneSignalAndroid+<GetTags>d__96.MoveNext(OneSignalSDK.OneSignalAndroid+<GetTags>d__96)
       at System.Threading.ContextCallback.Invoke(System.Threading.ContextCallback)
       at System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext)
       at System.Runtime.CompilerServices.AsyncMethodBuilderCore+MoveNextRunner.Run(System.Runtime.CompilerServices.AsyncMethodBuilderCore+MoveNextRunner)
       at System.Action.Invoke(System.Action)
       at System.Threading.ContextCallback.Invoke(System.Threading.ContextCallback)
       at System.Threading.Tasks.AwaitTaskContinuation.RunCallback(System.Threading.Tasks.AwaitTaskContinuation)
       at System.Threading.Tasks.Task.FinishContinuations(System.Threading.Tasks.Task)
       at System.Threading.Tasks.Task`1[TResult].TrySetResult(System.Threading.Tasks.Task`1[TResult])
       at System.Threading.Tasks.TaskCompletionSource`1[TResult].TrySetResult(System.Threading.Tasks.TaskCompletionSource`1[TResult])
       at Laters.AwaitableAndroidJavaProxy`1[TResult]._setResult(Laters.AwaitableAndroidJavaProxy`1[TResult])
       at System.Action`1[T].Invoke(System.Action`1[T])
       at System.Threading.SendOrPostCallback.Invoke(System.Threading.SendOrPostCallback)
       at UnityEngine.UnitySynchronizationContext+WorkRequest.Invoke(UnityEngine.UnitySynchronizationContext+WorkRequest)
       at UnityEngine.UnitySynchronizationContext.Exec(UnityEngine.UnitySynchronizationContext)
       at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw(System.Runtime.ExceptionServices.ExceptionDispatchInfo)
       at System.Runtime.CompilerServices.AsyncMethodBuilderCore+<>c.<ThrowAsync>b__6_0(System.Runtime.CompilerServices.AsyncMethodBuilderCore+<>c)
       at System.Threading.SendOrPostCallback.Invoke(System.Threading.SendOrPostCallback)
       at UnityEngine.UnitySynchronizationContext+WorkRequest.Invoke(UnityEngine.UnitySynchronizationContext+WorkRequest)
       at UnityEngine.UnitySynchronizationContext.Exec(UnityEngine.UnitySynchronizationContext)
       at UnityEngine.UnitySynchronizationContext:Exec(UnityEngine)

Code of Conduct

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

Hey @RaphaelNSG can you tell me more about the device you tested this on? The device model and which version of Android you used would be great.

@RaphaelNSG
Copy link
Author

Hey @adamschlesinger sorry for the delay. Actually this error is happening on Android and IOS in many devices. For exemple:

  • Iphone XR = 15.4.1
  • Iphone 6 = 12.5.5-
  • Xiaomi MI 8 Lite = Android 10
  • Samsung Galaxy A30 = Android 11

@RaphaelNSG
Copy link
Author

IOS error:

Non-fatal Exception: NullReferenceException
0  ???                            0x0 MoveNext (OneSignalService+<SendIncrementalData>d__0)
1  ???                            0x0 Invoke (System.Threading.ContextCallback)
2  ???                            0x0 RunInternal (System.Threading.ExecutionContext)
3  ???                            0x0 Run (System.Runtime.CompilerServices.AsyncMethodBuilderCore+MoveNextRunner)
4  ???                            0x0 Invoke (System.Action)
5  ???                            0x0 Invoke (System.Threading.ContextCallback)
6  ???                            0x0 RunCallback (System.Threading.Tasks.AwaitTaskContinuation)
7  ???                            0x0 FinishContinuations (System.Threading.Tasks.Task)
8  ???                            0x0 TrySetResult (System.Threading.Tasks.Task`1[TResult])
9  ???                            0x0 SetResult (System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1[TResult])
10 ???                            0x0 MoveNext (OneSignalSDK.OneSignalIOS+<GetTags>d__139)
11 ???                            0x0 Invoke (System.Threading.ContextCallback)
12 ???                            0x0 RunInternal (System.Threading.ExecutionContext)
13 ???                            0x0 Run (System.Runtime.CompilerServices.AsyncMethodBuilderCore+MoveNextRunner)
14 ???                            0x0 Invoke (System.Action)
15 ???                            0x0 Invoke (System.Threading.SendOrPostCallback)
16 ???                            0x0 Invoke (UnityEngine.UnitySynchronizationContext+WorkRequest)
17 ???                            0x0 Exec (UnityEngine.UnitySynchronizationContext)
18 ???                            0x0 Throw (System.Runtime.ExceptionServices.ExceptionDispatchInfo)
19 ???                            0x0 <ThrowAsync>b__6_0 (System.Runtime.CompilerServices.AsyncMethodBuilderCore+<>c)
20 ???                            0x0 Invoke (System.Threading.SendOrPostCallback)
21 ???                            0x0 Invoke (UnityEngine.UnitySynchronizationContext+WorkRequest)
22 ???                            0x0 Exec (UnityEngine.UnitySynchronizationContext)
23 ???                            0x0 UnitySynchronizationContext:Exec (UnityEngine)

@jkasten2
Copy link
Member

@RaphaelNSG Thanks for the stacktrace, however it doesn't provide any extra details to investigate. Could you share where and how you are calling GetTags? Could you share some of your code?

We have a new 3.0.1 version, could you also tell us if the issue happens there as well?

@RaphaelNSG
Copy link
Author

@jkasten2 I figure out that the GetTags() function is returning 'null' and that is what is causing the NullReferenceException. This is my function:

public static async void SendIncrementalData(string key)
    {
        Dictionary<string, object> tags = await OneSignal.Default.GetTags();

        if (tags.ContainsKey(key))
        {
            int value = int.Parse(tags[key].ToString());
            value++;
            OneSignal.Default.SendTag(key, value.ToString());
        }
        else
        {
            OneSignal.Default.SendTag(key, "1");
        }
    }

Can the result of GetTags function be null?

@adamschlesinger
Copy link
Contributor

Hi @RaphaelNSG yes the object returned by GetTags can be null.

@RaphaelNSG
Copy link
Author

@adamschlesinger thanks for the answer, but this is new because in the older version this never happened, so it might be a good idea to update the documentation with this information.

@adamschlesinger
Copy link
Contributor

@RaphaelNSG definitely! We're also going to evaluate if this is ideal behavior or not.

@shepherd-l
Copy link
Contributor

Closing this issue as it has gone stale. We haven’t seen any further reports of this. Please try upgrading the OneSignal SDK if you or anyone is still having this issue. If this is still an issue, please open a new report with updated information.

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

4 participants