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

AWS sdk carashing with Unity 5.4.0 upwards versions! #492

Closed
NeoAnderson87 opened this issue Nov 18, 2016 · 9 comments
Closed

AWS sdk carashing with Unity 5.4.0 upwards versions! #492

NeoAnderson87 opened this issue Nov 18, 2016 · 9 comments

Comments

@NeoAnderson87
Copy link

Here is the log:
NullReferenceException: A null value was found where an object instance was required.
at Amazon.Runtime.Internal.DownloadHandlerBufferWrapper..cctor () [0x00000] in :0
at Amazon.Runtime.Internal.UnityMainThreadDispatcher+d__7.MoveNext () [0x00000] in :0
at UnityEngine.SetupCoroutine.InvokeMoveNext (IEnumerator enumerator, IntPtr returnValueAddress) [0x00000] in :0
at UnityEngine.MonoBehaviour.StartCoroutine_Auto (IEnumerator routine) [0x00000] in :0
at UnityEngine.MonoBehaviour.StartCoroutine (IEnumerator routine) [0x00000] in :0
at Amazon.Runtime.Internal.UnityMainThreadDispatcher.ProcessRequests () [0x00000] in :0
at Amazon.Runtime.Internal.UnityMainThreadDispatcher.Update () [0x00000] in :0 Rethrow as TypeInitializationException: The type initializer for 'Amazon.Runtime.Internal.DownloadHandlerBufferWrapper' threw an exception.
at Amazon.Runtime.Internal.UnityMainThreadDispatcher+d__7.MoveNext () [0x00000] in :0
at UnityEngine.SetupCoroutine.InvokeMoveNext (IEnumerator enumerator, IntPtr returnValueAddress) [0x00000] in :0
at UnityEngine.MonoBehaviour.StartCoroutine_Auto (IEnumerator routine) [0x00000] in :0
at UnityEngine.MonoBehaviour.StartCoroutine (IEnumerator routine) [0x00000] in :0
at Amazon.Runtime.Internal.UnityMainThreadDispatcher.ProcessRequests () [0x00000] in :0
at Amazon.Runtime.Internal.UnityMainThreadDispatcher.Update () [0x00000] in :0
UnityEngine.MonoBehaviour:StartCoroutine_Auto(IEnumerator)
UnityEngine.MonoBehaviour:StartCoroutine(IEnumerator)Amazon.Runtime.Internal.UnityMainThreadDispatcher:ProcessRequests()
Amazon.Runtime.Internal.UnityMainThreadDispatcher:Update()

(Filename: currently not available on il2cpp Line: -1)

@NeoAnderson87
Copy link
Author

Is there any update on this ? Also this happens only on device not in the unity editor!

@Yukichu
Copy link

Yukichu commented Nov 27, 2016

Had a user report same issue. Any updates?

@JonMcElroy
Copy link

I'm seeing this happen as well. I'm not getting any equivalent error in the editor.

Similar call stack to the one reported above.

NullReferenceException: A null value was found where an object instance was required.
at Amazon.Runtime.Internal.DownloadHandlerBufferWrapper..cctor () [0x00000] in :0
at Amazon.Runtime.Internal.UnityMainThreadDispatcher+d__7.MoveNext () [0x00000] in :0
at UnityEngine.SetupCoroutine.InvokeMoveNext (IEnumerator enumerator, IntPtr returnValueAddress) [0x00000] in :0
at UnityEngine.MonoBehaviour.StartCoroutine_Auto (IEnumerator routine) [0x00000] in :0
at UnityEngine.MonoBehaviour.StartCoroutine (IEnumerator routine) [0x00000] in :0
at Amazon.Runtime.Internal.UnityMainThreadDispatcher.ProcessRequests () [0x00000] in :0
at Amazon.Runtime.Internal.UnityMainThreadDispatcher.Update () [0x00000] in :0
Rethrow as TypeInitializationException: The type initializer for 'Amazon.Runtime.Internal.DownloadHandlerBufferWrapper' threw an exception.
at Amazon.Runtime.Internal.UnityMainThreadDispatcher+d__7.MoveNext () [0x00000] in :0
at UnityEngine.SetupCoroutine.InvokeMoveNext (IEnumerator enumerator, IntPtr returnValueAddress) [0x00000] in :0
at UnityEngine.MonoBehaviour.StartCoroutine_Auto (IEnumerator routine) [0x00000] in :0
at UnityEngine.MonoBehaviour.StartCoroutine (IEnumerator routine) [0x00000] in :0
at Amazon.Runtime.Internal.UnityMainThreadDispatcher.ProcessRequests () [0x00000] in :0
at Amazon.Runtime.Internal.UnityMainThreadDispatcher.Update () [0x00000] in :0
UnityEngine.MonoBehaviour:StartCoroutine_Auto(IEnumerator)
UnityEngine.MonoBehaviour:StartCoroutine(IEnumerator)
Amazon.Runtime.Internal.UnityMainThreadDispatcher:ProcessRequests()
Amazon.Runtime.Internal.UnityMainThreadDispatcher:Update()

@JonMcElroy
Copy link

JonMcElroy commented Dec 6, 2016

This looks like the static constructor for DownloadHandlerBufferWrapper which sets up the "downloadHandlerBufferType" may not be getting called somehow or the types fetched inside of it are returning null. When the main ctor gets called it has a null reference to the type. I'm only seeing this on AOT platforms so it's possibly just a code stripping issue.

Constructor exception is here

@JonMcElroy
Copy link

JonMcElroy commented Dec 6, 2016

Building against the class in the depot instead of the built assembly I see dig in and see the error on my AOT devices here

It seems that the line before that

dataProperty = downloadHandlerBufferType.GetProperty("data");

results in dataProperty being null

Not sure if the interface changed in Unity or something else but still investigating.

@JonMcElroy
Copy link

JonMcElroy commented Dec 7, 2016

Looks like the property is stripped out at compile time, explicitly accessing the same property somewhere else in the code causes the property to be included. I've also tried adding it through the link.xml file as well but maybe I'm not setting syntax correctly.

Anyway, even a simple touch of the .data property fixes this. I feel like I see this a lot in libraries these days but I've missed it myself when building for AOT platforms using reflection. I added a function like this to my startup and it gets me rolling for now.

// DO NOT CALL, should be a no-op, just a hint to the linker
void AOTHelper()
{
    UnityEngine.Networking.DownloadHandlerBuffer dhb = new UnityEngine.Networking.DownloadHandlerBuffer();
    object.Equals(dhb.data, null);
}

I should note that the recommendation in Unity.README.md for modifications to the link.xml file doesn't fix this issue although I feel like it should so maybe something is wrong there?

<assembly fullname="UnityEngine">
	<type fullname="UnityEngine.Experimental.Networking.UnityWebRequest" preserve="all" />
	<type fullname="UnityEngine.Experimental.Networking.UploadHandlerRaw" preserve="all" />
	<type fullname="UnityEngine.Experimental.Networking.UploadHandler" preserve="all" />
	<type fullname="UnityEngine.Experimental.Networking.DownloadHandler" preserve="all" />
	<type fullname="UnityEngine.Experimental.Networking.DownloadHandlerBuffer" preserve="all" />
</assembly>

@aphexyuri
Copy link
Contributor

aphexyuri commented Jan 30, 2017

Curious, have you tried to change occurrences of UnityEngine.Experimental.Networking to UnityEngine.Networking?

@JonMcElroy
Copy link

It's been a while since I've been working on this but at the time I had tried excluding both the experimental and non-experimental networking libraries from the stripper and was still seeing issues. Not sure if things are different now or if there was something wrong with way the link.xml was preserving files in that version as there has been a point update since then.

@github-actions
Copy link

We have noticed this issue has not recieved attention in 2 years. We will close this issue for now. If you think this is in error, please feel free to comment and reopen the issue.

@github-actions github-actions bot added the closing-soon This issue will automatically close in 4 days unless further comments are made. label May 27, 2020
@github-actions github-actions bot added closed-for-staleness and removed closing-soon This issue will automatically close in 4 days unless further comments are made. labels Jul 10, 2020
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

5 participants