-
Notifications
You must be signed in to change notification settings - Fork 139
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
Null Reference After a couple of minutes into Game #58
Comments
Experiencing same issue in Unity editor after few minutes, didn't check on mobile device yet. @sfratini, yes reports are affected since nothing is sent anymore after this error |
I get this too, and using @sfratini's suggestion to replace getInstance with:
is not possible because you can't use "this" in a static method or property. The weird thing for me is that it's works fine for the first run in the Unity editor, but subsequent runs it always fails. If I quit and reopen Unity it again works first time, but as soon as I stop and play again it always fails... |
My bad, I posted a wrong copy/paste. Is everyone getting the error on the same line and class? Class GoogleAnalyticsMPV3, line 144: try { Then, you need to change GoogleAnalyticsV3 (public and static): public static bool initialized = false; Ugly as hell, but well. You can ignore the previous code. |
It appears to work but if I untick "Dry Run" I'm getting a different error now:
|
The question we need to ask ourselves is "How the hell the GoogleAnalyticsV3 instance could be null ?" The root cause of this problem is the Unity's hotswapping. If you have set GA "UncaughtExceptionReporting" to true, the plugin will try to log any exceptions thrown. After a hot swap, on the next SendGaHitWithMeasurementProtocol, there will an exception thrown (because GAv3 instance is null, NullReferenceException) that will lead to a new SendGaHitWithMeasurementProtocol that will lead to another exception, etc... Even if you set GA "UncaughtExceptionReporting" to false, the Like suggested by https://github.com/cobbpg in this github issue #69, we should replace GoogleAnalyticsV3.cs : L133 This kind of scenario only happens when running the application in Unity editor. |
I have exactly the same problem, I use V4. From my investigation it seems, when |
I have this problem in V3 and V4. Tested on Unity 2017.2.0.f3 and 2017.3.0.f3. The first time I hit play in the editor it works without an error. After stopping and playing again I get the NullReferenceError every time I try to send data e.g. LogScreen(string) until I close Unity and start again. Just to verify, this is an editor only issue? It will run okay on iOS and Android? |
Hi! After a couple of minutes of using the Game in Unity, the Editor shows that the console is being filled (999+) with Null references in the GoogleAnalyticsMPV3 class in just a couple of seconds. Particularly, this line:
GoogleAnalyticsV3.getInstance().StartCoroutine(this.HandleWWW(new WWW(newUrl)));
Some debugging made me realize the instance was null, therefore the error. I solved it replacing the code with:
try {
GoogleAnalyticsV3.getInstance().StartCoroutine(this.HandleWWW(new WWW(newUrl)));
} catch (Exception e){
}
To avoid filling the log and replace the getInstance code with this:
Before, if would just return the instance and since it was null, I was getting the error. Will this affect my reports in any way?
The text was updated successfully, but these errors were encountered: