NullReferenceException in MetricizedGooglePlayStoreService.DequeueQueryProducts

Hi

We’re seeing a lot of instances of the following exception from the latest release of our game. Unfortunately we haven’t been able to get the error in house, so don’t have any steps to reproduce at the moment (will add to this thread if we manage to), but we don’t have any subscription products, the exception seems to happen just after the plugin has been initialised, and we had just updated the purchasing plugin to v.4.2.1, so seems to have been introduced with that.
I can’t see any reference to this in the changelog for the latest versions of the plugin - before I take a leap of faith, update the plugin and start the release process rolling, could someone at Unity let me know if this has been fixed in 4.4.0?

<Exception>: NullReferenceException: Object reference not set to an instance of an object.
UnityEngine.Purchasing.MetricizedGooglePlayStoreService.DequeueQueryProducts () (at <00000000000000000000000000000000>:0)
UnityEngine.Purchasing.GooglePlayStoreService.OnDisconnected () (at <00000000000000000000000000000000>:0)
System.Action.Invoke () (at <00000000000000000000000000000000>:0)
System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at <00000000000000000000000000000000>:0)
UnityEngine.AndroidJavaProxy.Invoke (System.String methodName, System.Object[] args) (at <00000000000000000000000000000000>:0)
UnityEngine._AndroidJNIHelper.InvokeJavaProxyMethod (UnityEngine.AndroidJavaProxy proxy, System.IntPtr jmethodName, System.IntPtr jargs) (at <00000000000000000000000000000000>:0)
Rethrow as TargetInvocationException: UnityEngine.Purchasing.BillingClientStateListener.onBillingSetupFinished(UnityEngine.AndroidJavaObject)
UnityEngine.AndroidJavaProxy.Invoke (System.String methodName, System.Object[] args) (at <00000000000000000000000000000000>:0)
UnityEngine._AndroidJNIHelper.InvokeJavaProxyMethod (UnityEngine.AndroidJavaProxy proxy, System.IntPtr jmethodName, System.IntPtr jargs) (at <00000000000000000000000000000000>:0)

The error is not familiar. You did not add a Google plugin separately by any chance? How are you seeing these errors, through an online crash service? Any other information in common, like Android version?

We’re receiving the errors through backtrace. no other google plugins updated and no obvious common info - seeing errors from android versions 10, 11 and 12 from a range of devices.

Got it. The issue is likely present with 4.4.0 also, we are checking

Great, thank you

We are also seeing this in our logs. Exact same stack trace. All Android versions, including 12. We just updated to unity purchasing 4 too.

Furthermore, the error below seems of a similar nature.

System.Array.Copy (System.Array sourceArray, System.Int32 sourceIndex, System.Array destinationArray, System.Int32 destinationIndex, System.Int32 length) (at <00000000000000000000000000000000>:0)
System.Collections.Generic.Queue`1[T].SetCapacity (System.Int32 capacity) (at <00000000000000000000000000000000>:0)
System.Collections.Generic.Queue`1[T].Enqueue (T item) (at <00000000000000000000000000000000>:0)
UnityEngine.Purchasing.Telemetry.TelemetryQueue`1[TTelemetryEventParams].QueueEvent (TTelemetryEventParams telemetryEvent) (at <00000000000000000000000000000000>:0)
UnityEngine.Purchasing.Telemetry.TelemetryMetricsInstanceWrapper.SendMetric (UnityEngine.Purchasing.Telemetry.TelemetryMetricTypes metricType, System.String metricName, System.Double metricTimeSeconds) (at <00000000000000000000000000000000>:0)
UnityEngine.Purchasing.Telemetry.TelemetryMetricEvent.StopAndSendMetric () (at <00000000000000000000000000000000>:0)
UnityEngine.Purchasing.MetricizedGooglePlayStoreService.DequeueQueryProducts () (at <00000000000000000000000000000000>:0)
UnityEngine.Purchasing.GooglePlayStoreService.OnConnected () (at <00000000000000000000000000000000>:0)
System.Action.Invoke () (at <00000000000000000000000000000000>:0)
System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at <00000000000000000000000000000000>:0)
System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) (at <00000000000000000000000000000000>:0)
UnityEngine.AndroidJavaProxy.Invoke (System.String methodName, System.Object[] args) (at <00000000000000000000000000000000>:0)
UnityEngine._AndroidJNIHelper.InvokeJavaProxyMethod (UnityEngine.AndroidJavaProxy proxy, System.IntPtr jmethodName, System.IntPtr jargs) (at <00000000000000000000000000000000>:0)
Rethrow as TargetInvocationException: UnityEngine.Purchasing.BillingClientStateListener.onBillingSetupFinished(UnityEngine.AndroidJavaObject)
UnityEngine.AndroidJavaProxy.Invoke (System.String methodName, System.Object[] args) (at <00000000000000000000000000000000>:0)
UnityEngine._AndroidJNIHelper.InvokeJavaProxyMethod (UnityEngine.AndroidJavaProxy proxy, System.IntPtr jmethodName, System.IntPtr jargs) (at <00000000000000000000000000000000>:0)

Yes, we are working on this and should be addressed in the next release.

Thank you for the update. Could you tell me when the next release is planned please?

We are seeing this with unity purchasing plugin 4.4.0; in case relevant.

Is the recommendation here to hold out for an update; or roll-back to our previous setup?

Update: corrected version number. Unity itself previously showed the wrong version (which I suppose in itself is a bug?)

If your purchases fail, then you would likely want to revert to your most recent working version. Can you elaborate about the version number? I might expect the next release in 2-3 weeks.

Hi @JeffDUnity3D , could you please confirm that a fix for the initial error I posted is also being worked on for the next release, as well as the one GeraldInc posted?

Hello @saltd ,
I can confirm that we are currently working on both of these issues for the next release.

From time to time when you look at the package manager it reports the wrong installed version. I’ve edited my message to reflect the version of the plugin we actually used in our release build. To avoid any doubt: the purchasing exception/crash exists in 4.4.0 - so upgrading to this version will not fix it.

We have downgraded back to our previous stable version, which we believe to be either 4.1.1 or 4.2.1, presumably the former - we are yet to find out.

Got this issue as well.

Non-fatal Exception: java.lang.Exception: Exception : NullReferenceException: Object reference not set to an instance of an object., stackTrace: UnityEngine.Purchasing.MetricizedGooglePlayStoreService.DequeueQueryProducts () (at <00000000000000000000000000000000>:0)
UnityEngine.Purchasing.GooglePlayStoreService.OnDisconnected () (at <00000000000000000000000000000000>:0)
System.Reflection.RuntimeMethodInfo.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[ ] parameters, System.Globalization.CultureInfo culture) (at <00000000000000000000000000000000>:0)
UnityEngine.AndroidJavaProxy.Invoke (System.String methodName, System.Object[ ] args) (at <00000000000000000000000000000000>:0)
UnityEngine._AndroidJNIHelper.InvokeJavaProxyMethod (UnityEngine.AndroidJavaProxy proxy, System.IntPtr jmethodName, System.IntPtr jargs) (at <00000000000000000000000000000000>:0)
Rethrow as TargetInvocationException: UnityEngine.Purchasing.BillingClientStateListener.onBillingSetupFinished(UnityEngine.AndroidJavaObject)
UnityEngine.AndroidJavaProxy.Invoke (System.String methodName, System.Object[ ] args) (at <00000000000000000000000000000000>:0)
UnityEngine._AndroidJNIHelper.InvokeJavaProxyMethod (UnityEngine.AndroidJavaProxy proxy, System.IntPtr jmethodName, System.IntPtr jargs) (at <00000000000000000000000000000000>:0)

is there an fix to this issue ?

Details:

IAP Purchasing version: 4.4.1

Unity Version: 2021.3.3f1
monitorScreen Information
Size: 1080x2326
DPI: 420.0
Refresh Rate: 60
devicesDevice Attributes
Debug Device: false
CPU: ARM64 FP ASIMD AES
CPU Core Count: 8
CPU Clock Frequency: 2730
RAM: 10901
memoryGPU Attributes and Capacities
GPU Memory Size: 4096
GPU Device ID: 0
GPU Device Name: Mali-G77
GPU Device Type: 11
GPU Device Version: OpenGL ES 3.2 v1.r32p1-01bet2-mbs2v39_0.b9c384f9d6a5cfbb847ba727ba3b34bc
GPU Device Vendor ID: 0
GPU Device Vendor Name: —
GPU Supported Render Target Count: 8
GPU Shader Caps: 50
GPU Copy Texture Support: 31
GPU Max Texture Size: 16383

Are you able to reproduce? This issue should be addressed in IAP 4.4.1. Unity IAP package 4.12.2 is now available page-2#post-8386932

Hi there!

I was using 4.4.0 version and having the same error. I don’t know about 4.4.1 because I’ve just found this post and Google will spend some days verifying my updated APK.

But, in my case, I’m using an asset called EasyMobile Pro, which offers multiple functions (notifications system, iapp system, login system and so on).

I’ve noticed that the IAP products are created inside that asset, but doesn’t appear at Unity’s IAP Catalog.

May that one be the reason for “object not found” error?

Thanks for your hard work, guys!

The DequeueQueryProducts issue should be addressed with IAP 4.4.1, but we are hearing reports that it may still be present. Please confirm when you can.

We are still seeing the null pointer exception with 4.4.1, as well as a new bug:

[09/09/2022 11:04:17] <Exception>: InvalidOperationException: Queue empty.
System.Collections.Generic.Queue`1[T].ThrowForEmptyQueue () (at <00000000000000000000000000000000>:0)
System.Collections.Generic.Queue`1[T].Dequeue () (at <00000000000000000000000000000000>:0)
UnityEngine.Purchasing.GooglePlayStoreService.DequeueQueryProducts () (at <00000000000000000000000000000000>:0)
System.Action.Invoke () (at <00000000000000000000000000000000>:0)
UnityEngine.Purchasing.Telemetry.TelemetryMetricsService.ExecuteTimedAction (System.Action timedAction, UnityEngine.Purchasing.Telemetry.TelemetryMetricDefinition metricDefinition) (at <00000000000000000000000000000000>:0)
System.Action.Invoke () (at <00000000000000000000000000000000>:0)
System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at <00000000000000000000000000000000>:0)
UnityEngine.AndroidJavaProxy.Invoke (System.String methodName, System.Object[] args) (at <00000000000000000000000000000000>:0)
UnityEngine._AndroidJNIHelper.InvokeJavaProxyMethod (UnityEngine.AndroidJavaProxy proxy, System.IntPtr jmethodName, System.IntPtr jargs) (at <00000000000000000000000000000000>:0)
Rethrow as TargetInvocationException: UnityEngine.Purchasing.BillingClientStateListener.onBillingSetupFinished(UnityEngine.AndroidJavaObject)
UnityEngine.AndroidJavaProxy.Invoke (System.String methodName, System.Object[] args) (at <00000000000000000000000000000000>:0)
UnityEngine._AndroidJNIHelper.InvokeJavaProxyMethod (UnityEngine.AndroidJavaProxy proxy, System.IntPtr jmethodName, System.IntPtr jargs) (at <00000000000000000000000000000000>:0)

Thank you for the report!

We have a fix that will address this NullPointerException in our next release.
I also verified and this will also fix the new bug with the empty queue.

when the bug fix going to be released?
we are getting these crashes all the time!

2 Likes