amazon-archives / aws-sdk-unity

ARCHIVED: The aws sdk for unity is now distributed as a part of aws sdk for dotnet:
https://github.com/aws/aws-sdk-net
Other
105 stars 43 forks source link

Mobile Analytics working in editor, but ceases to work when built on device. #84

Closed mol-x closed 8 years ago

mol-x commented 9 years ago

Hello,

We've been implementing Mobile Analytics into our game, and are running into an issue with the events not being reported when sent from the device, but working perfectly fine in the Unity editor.

-We are using Unity version 5.1.2f1 -We are using the AWS SDK version 2.0.0.3

We are wondering if there is something we are missing in our implementation. Let us know if you need anymore information.

Thanks, -Nick

karthiksaligrama commented 9 years ago

can you tell me if this is on android or ios?

mol-x commented 9 years ago

This is on ios.

ghost commented 9 years ago

Hi, can you find the logging of https://github.com/aws/aws-sdk-unity/blob/master/Assets/AWSSDK/src/Services/MobileAnalytics/Custom/Delivery/_unity/DeliveryClient.cs#L111 ?

mol-x commented 9 years ago

I am able to see that log within the Unity console, but I am not seeing it in XCode when playing the game on the device.

ghost commented 9 years ago

It's possible that exception occurs at https://github.com/aws/aws-sdk-unity/blob/master/Assets/AWSSDK/src/Services/MobileAnalytics/Custom/Delivery/_unity/DeliveryClient.cs#L97.

Can you add try catch around it ? We recently find similar issue on mobile device.

mol-x commented 9 years ago

After adding a try catch around that line and some logging, I am seeing "EventStoreException: Event cannot be stored." and "AmazonClientException: NOT NULL constraint failed: ma_events.ma_event".

mol-x commented 9 years ago

Based on the research we've been conducting the last couple of days, it seems this is an issue with only iOS and how the compiler is working. We are also getting this error - "Attempting to call method 'System.Reflection.MonoProperty::GetterAdapterFrame' for which no ahead of time (AOT) code was generated."

We are wondering if creating the JSON string ourselves or using a different JSON parser other than LitJSON would be an appropriate workaround for the time being?

Any feedback would be great.

ghost commented 9 years ago

Hi, search online I found similar issue reported here http://forum.unity3d.com/threads/unity-5-0-3f2-il2cpp-problem-attempting-to-call-method-system-reflection-monoproperty-getteradapt.332335/

Can you try to use "Net 2.0 subset". It should work around this issue.

mol-x commented 9 years ago

We are currently using a couple plugins that require us to use .Net 2.0. We are exploring multiple workarounds to try to get everything working as we need.

mol-x commented 9 years ago

Just wanted to let you guys know, we were able to get our analytics reporting from iOS devices by changing a line of code in the JsonMapper.cs file. This fix allows us to continue running with .NET 2.0 and not the Subset.

Through our research we were able to find that on iOS devices you can't have code cause JIT(Just-In-Time) compilation. The method that was causing this issue was PropertyInfo.GetValue() as you can see below:

Before:

847                        WriteValue (p_info.GetValue (obj, null),
848                                    writer, writer_is_private, depth + 1);  

After:

847                        WriteValue (p_info.GetGetMethod().Invoke (obj, null),
848                                    writer, writer_is_private, depth + 1);  
ghost commented 9 years ago

Thanks for your solution !

ghost commented 9 years ago

What iOS device are you using ? Do you use IL2CPP ?

mol-x commented 9 years ago

The issue was occurring on all our beta testers, which includes basically every iOS device starting at iPhone 4 and later.

We are building with IL2CPP as well.

karthiksaligrama commented 8 years ago

Fixed in Version 2.0.0.5