OneSignal-Xamarin-SDK
OneSignal-Xamarin-SDK copied to clipboard
InvalidOperationException in GetTagsAsync
Some times a InvalidOperationException
is thrown in GetTagsAsync
(confirmed on Android).
The cause is likely, that the callback passed to GetTags
is called more than once under some circumstances and thus TaskCompletionSource.SetResult
throws. Easiest fix would be to change
@this.GetTags(tags => tcs.SetResult(tags));
to
@this.GetTags(tags => tcs.TrySetResult(tags));
although I don't know why the callback is called more than once in the first place, there might be an underlying issue.
Stack Trace: TaskCompletionSource1[TResult].SetResult(TResult result) OneSignalExtensions+<>c__DisplayClass0_0.<GetTagsAsync>b__0(System.Collections.Generic.Dictionary2[TKey, TValue] tags) TagsHandler.TagsAvailable(Org.Json.JSONObject jsonObject) OneSignal+IGetTagsHandlerInvoker.n_TagsAvailable_Lorg_json_JSONObject_(System.IntPtr jnienv, System.IntPtr native__this, System.IntPtr native_p0)
@ArgusMagnus This is definitely a bug we will be fixing - however - I would also recommend that you look at how often you are calling GetTags
and make sure you are not calling it too frequently. This bug is only apparent if you call GetTags
often enough to where the previous request still hasn't finished.
We will be creating a PR in our Android SDK and will be releasing an update soon
On further thought, this might be more serious than I thought. One handler getting called twice probably means that another one is not called at all, which can lead to indefinite waiting, which likely is a serious problem, especially if you are using async-await.
Hello this issue has been open for a very long time with no activity is it still a problem?
Im no longer using OneSignal in my project, I don't know if it's still a problem.