Skip to content

[Bug] iOS port process for the podfile creates a null reference exception. #431

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

Closed
JimmyDeemo opened this issue Mar 26, 2021 · 10 comments
Closed

Comments

@JimmyDeemo
Copy link
Contributor

JimmyDeemo commented Mar 26, 2021

[REQUIRED] Please fill in the following fields:

  • Unity editor version: 2019.4.20f1
  • External Dependency Manager version: 1.2.164
  • Source you installed EDM4U: Unity Package Manager (.unitypackage or Unity Package Manager)
  • Features in External Dependency Manager in use: iOS Resolver (Android Resolver, iOS Resolver, VersionHandler, etc.)
  • Plugins SDK in use: Many inc.; Helpshift, Facebook, Tapjoy and various ad providers. (Firebase, Admob, Facebook, etc.)
  • Platform you are using the Unity editor on: Mac (Mac, Windows, or Linux)

[REQUIRED] Please describe the issue here:

After building my project there are two NullReferenceExceptions in the console related to the resolver. They seem to stem from a HTTP Utility function and track back to

public static void OnPostProcessGenPodfile(BuildTarget buildTarget,
.

Please answer the following, if applicable:

What's the issue repro rate? (eg 100%, 1/5 etc)
100% for each iOS build.

What happened? How can we make the problem occur?
Started happening recently, unsure of the cause. I have attached the stacks to this ticket.

If you have a downloadable sample project that reproduces the bug you're reporting, you will
likely receive a faster response on your issue.

I cannot share the project as it is a commercial codebase. I can try things other than moving to a higher version of unity other than the 2019 LTS branch. I would be happy for a workaround for this issue if you could tell me what might the cause be?

@google-oss-bot
Copy link

This issue does not seem to follow the issue template. Make sure you provide all the required information.

@JimmyDeemo
Copy link
Contributor Author

null_ref_1.txt
null_ref_2.txt

Forgot to attached the stacks.

@JimmyDeemo
Copy link
Contributor Author

This issue does not seem to follow the issue template. Make sure you provide all the required information.

I only deleted the section it asked. All the rest of the template is the same.

@paulinon paulinon removed the new to be triaged label Mar 26, 2021
@JimmyDeemo
Copy link
Contributor Author

Please note; issue does not occur when I reverted to 1.2.162, so I suspect this has happened in 1.2.164 looking at the changelog summary.

@chkuang-g
Copy link
Collaborator

chkuang-g commented Mar 29, 2021

@JimmyDeemo

According to the log you provided, it seems to be caused by this call.

analytics.Report("generatepodfile", "Generate Podfile");

url.AppendFormat("{0}{1}={2}",
url.Length == 0 ? "?" : "&",
HttpUtility.UrlEncode(param.Key),
HttpUtility.UrlEncode(param.Value));

This is an analytics event to report when Podfile generation started. If you don't like this event, you can actually turn this off from iOS Resolver Settings. But I digressed.

Since we did not change anything to this event from 1.2.162 to 1.2.164, I suspect this is a regression from 3fb0e7b.

As a workaround, I would recommend you to simply turn off Enable Analytics Reporting in iOS Resolver settings in Assets > External Dependency Manager > iOS Resolver > Settings menu item.
This is a shared global setting for all analytics reporting in EDM4U

@chkuang-g chkuang-g added needs-attention Need Googler's attention type: bug and removed needs-attention Need Googler's attention type: question labels Mar 29, 2021
@chkuang-g
Copy link
Collaborator

Hmm...Oddly I was not able to reproduce the issue on my machine.

And reading through code, I am not sure what can cause the NullReferenceException.

new[] {
// Version
new KeyValuePair<string, string>("v", "1"),
// Tracking ID.
new KeyValuePair<string, string>("tid", trackingId),
// Client ID.
new KeyValuePair<string, string>("cid", cookie.Key),
// Hit type.
new KeyValuePair<string, string>("t", "pageview"),
// "URL" / string to report.
new KeyValuePair<string, string>(
"dl", path + "?" + cookie.Value + fragment),
// Document title.
new KeyValuePair<string, string>("dt", reportName),
// Cache buster
new KeyValuePair<string, string>("z", random.Next().ToString())
},

@JimmyDeemo Could you turn on the Verbose Logging in iOS Resolver Setting, and send us your editor log after you make an iOS build?

@chkuang-g chkuang-g added the needs-info Need information for the developer label Mar 29, 2021
@chkuang-g
Copy link
Collaborator

chkuang-g commented Mar 29, 2021

When I did a search for HttpEncoder.GetCustomEncoderFromConfig() NullReferenceException, many pointed out to use following way to solve this exception, which actually does not work with Unity.

HttpEncoder.Current = HttpEncoder.Default;

System.Web.Util.HttpEncoder class does not exist in Unity 2019.4.9f1 or 2019.4.23f1, which are the versions I used, yet it showed up in your log from Unity 2019.4.20f1. This indicated that Unity does not fully implemented System.Web.Util.HttpEncoder in .NET 4.5, but to keep it as an internal class.

Also this Unity bugtracker.
https://issuetracker.unity3d.com/issues/httputility-null-reference-exception-on-net-4-dot-x-when-performing-httputility-dot-urlencode

This gives me an impression that this is a bug in Unity (or the mono which Unity includes).

I guess what we can do is to utilize UnityEngine.Networking.UnityWebRequest.EscapeURL instead of HttpUtility.UrlEncode when it is available in 2017.3. Really prefer not to tie to Unity API since Unity can change this API at anytime. Also, it is not available in 2017.2 or below.

For workaround, I have 3 suggestions:

  1. Upgrade Unity. In the bugtracker, the issue is fixed in 2021.2.X. Hopefully they retroactively fix this in the latest version of 2019 or 2020.
  2. Downgrade Unity. Let me know if you still experience this issue in 2019.4.9f1
  3. Basically turn off Analytics, as I mentioned in [Bug] iOS port process for the podfile creates a null reference exception. #431 (comment). This will plague analytics from Firebase as well. So make sure to turn off that one under Windows > Firebase > Documentation and scroll all the way to the bottom

Let me know if this helps.

@chkuang-g
Copy link
Collaborator

Another thing we can do is probably try to catch exception like this during event reporting so that it will not break the rest of resolution process.

@JimmyDeemo
Copy link
Contributor Author

Sorry for my lack of response, I have been on annual leave.

I think, in the first instance, I will disable Analytics. I very much agree that event reporting shouldn't halt the rest of the resolution process. Unfortunately changing the major Unity verions to 2020 isn't an option for me right now, likewise with downgrading on the 2019 line.

@google-oss-bot google-oss-bot added needs-attention Need Googler's attention and removed needs-info Need information for the developer labels Apr 6, 2021
@chkuang-g chkuang-g removed type: question needs-attention Need Googler's attention labels Apr 19, 2021
@chkuang-g
Copy link
Collaborator

No problem. That is reasonable.
For workaround, please just turn off Analytics for both EDM4U and Firebase.

  • Analytics settings for EDM4U can be found under Assets > External Dependency Manager > Version Handler > Settings
  • Analytics settings for Firebase can be found under Windows > Firebase > Documentation at the very bottom.

Appreciate you approved to let us collect usage data before. Since this is causing usability issue, please just turn it off for now.

chkuang-g added a commit that referenced this issue Apr 28, 2021
- Version 1.2.165 - Apr 28, 2021
-- Bug Fixes
* Version Handler - Fixed #431 by replacing the use of `HttpUtility.UrlEncode()`
  which causes NullReferenceException in certain version of Unity.
* Android Resolver - Check that androidSdkRootPath directory exists before using
  as sdkPath.
* Android Resolver - Fixed Android Resolver integration tests with Unity
  2019.3+.

Change-Id: I1431ea3261ede04743ee6ef3e9a6e557355c5f1b
@googlesamples googlesamples locked and limited conversation to collaborators May 29, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants