0

我们正在使用 Unity3d(版本 5.0.1p1)为 iOS 和 android 创建游戏,并且由于我们使用 Parse.com 数据服务,我们自然而然地使用它来实现远程推送通知。

问题是,在构建游戏并在测试设备(iPhone 4s iOS8.1.2)上运行它之后,我们在游戏启动时遇到了我们无法弄清楚的执行引擎异常。这是一个例外:

ExecutionEngineException: Attempting to call method

'System.Reflection.MonoProperty::StaticGetterAdapterFrame' for which no ahead of time (AOT) code was

generated.

at System.Reflection.EventInfo+AddEventAdapter.Invoke (System.Object
_this, System.Delegate dele)

[0x00000] in <filename unknown>:0

at System.Reflection.MonoProperty+GetterAdapter.Invoke (System.Object
_this) [0x00000] in <filename

unknown>:0

at AOGenerator.BlurBuffer () [0x00000] in <filename unknown>:0

at System.Reflection.MonoProperty.GetValue (System.Object obj, System.Object[] index) [0x00000] in

<filename unknown>:0

at Newtonsoft.Json.Bson.BsonRegex.get_Type () [0x00000] in <filename unknown>:0

at Parse.ParseInstallation.get_Badge () [0x00000] in <filename unknown>:0

at Parse.ParseInstallation.SetPlatformAutomaticValue () [0x00000] in <filename unknown>:0

at Parse.ParseInstallation.SetAutomaticValues () [0x00000] in <filename unknown>:0

at Parse.ParseInstallation.SaveAsync (System.Threading.Tasks.Task toAwait, CancellationToken

cancellationToken) [0x00000] in <filename unknown>:0

at Parse.PlatformHooks+<>c__DisplayClass38.<RequestAsync>b__33 (System.Threading.Tasks.Task`1 _)

[0x00000] in <filename unknown>:0

at Parse.ParseObject+<>c__DisplayClass18.<SaveAsync>b__17 (System.Threading.Tasks.Task toAwait)

[0x00000] in <filename unknown>:0

at FlurryAnalyticsIOS.SetSessionTimeout (Int32 seconds) [0x00000] in <filename unknown>:0

at

System.Collections.Generic.Dictionary`2[System.Int64,System.Boolean].Do_ICollectionCopyTo[KeyValuePair`2]

(System.Array array, Int32 index, System.Collections.Generic.Transform`1 transform) [0x00000] in <filename

unknown>:0

at Parse.Internal.TaskQueue.Enqueue[Task] (System.Func`2 taskStart, CancellationToken cancellationToken)

[0x00000] in <filename unknown>:0

at Parse.ParseObject.SaveAsync (CancellationToken cancellationToken) [0x00000] in <filename unknown>:0

at Parse.ParseObject.SaveAsync () [0x00000] in <filename unknown>:0

at Parse.ParseInitializeBehaviour.<Awake>b__0 (System.Byte[] deviceToken) [0x00000] in <filename

unknown>:0

at FlurryAnalyticsIOS.SetSessionTimeout (Int32 seconds) [0x00000] in <filename unknown>:0

at Newtonsoft.Json.Bson.BsonRegex.get_Type () [0x00000] in <filename unknown>:0

at Parse.PlatformHooks+<>c__DisplayClass24.<RegisterDeviceTokenRequest>b__22 () [0x00000] in

<filename unknown>:0

at System.Action.Invoke () [0x00000] in <filename unknown>:0

at Newtonsoft.Json.Bson.BsonRegex.get_Type () [0x00000] in <filename unknown>:0

at Parse.PlatformHooks+<RunDispatcher>d__44.MoveNext () [0x00000] in <filename unknown>:0

at System.Nullable`1[System.DateTimeOffset].ToString () [0x00000] in <filename unknown>:0

System.Nullable`1:ToString()

UnityEngine.Debug:Internal_LogException(Exception, Object)

UnityEngine.Debug:LogException(Exception)

Parse.<RunDispatcher>d__44:MoveNext()

System.Nullable`1:ToString()

新的 Unity Parse SDK 1.5(包含 PNS 功能)刚刚出现了这个问题。我们所知道的是,仅使用 parse sdk 运行一个空项目就可以了,并且通知工作正常,但是在我们的实际项目中,由于异常,设备不会在 parse 中注册通知,所以我们假设有一个parse 和我们正在使用的其他工具之一之间存在冲突。

仅供参考:我们正在使用 IL2CPP 为通用架构构建游戏(我们也在使用 .Net 2.0 子集构建游戏,但我认为这与问题无关)。

感谢您的时间和您的回答。

更新 ::

这次我们尝试使用 Mono(2.x) 构建,我们遇到了几乎相同的异常,变成了这个:

ExecutionEngineException:尝试 JIT 编译方法

'System.Reflection.MonoProperty:StaticGetterAdapterFrame

(System.Reflection.MonoProperty/StaticGetter`1,object)' 使用 aotonly 运行时。

在 System.Reflection.MonoProperty.GetValue(System.Object obj,System.Object[] 索引)

[0x00000] 在:0

在 Parse.ParseInstallation.get_Badge () [0x00000] in :0

在 Parse.ParseInstallation.SetPlatformAutomaticValue () [0x00000] 中

未知>:0

在 Parse.ParseInstallation.SetAutomaticValues () [0x00000] in :0

在 Parse.ParseInstallation.SaveAsync (System.Threading.Tasks.Task toAwait,

CancellationToken cancelToken) [0x00000] in :0

在 Parse.ParseObject+<>c__DisplayClass18.b__17

(System.Threading.Tasks.Task toAwait) [0x00000] in :0

在 Parse.Internal.TaskQueue.Enqueue[Task] (System.Func`2 taskStart, CancellationToken

取消令牌)[0x00000]在:0

在 Parse.ParseObject.SaveAsync (CancellationToken cancelToken) [0x00000] 中

:0

在 Parse.ParseObject.SaveAsync () [0x00000] in :0

在 Parse.ParseInitializeBehaviour.b__0 (System.Byte[] deviceToken) [0x00000] 中

:0

在 Parse.PlatformHooks+<>c__DisplayClass24.b__22 ()

[0x00000] 在:0

在 Parse.PlatformHooks+d__44.MoveNext () [0x00000] 中

未知>:0

UnityEngine.Debug:Internal_LogException(异常,对象)

UnityEngine.Debug:LogException(异常)

Parse.d__44:MoveNext()

希望它能给你们带来更多关于这个问题的细节。

更新 2 ::

我们确切地知道导致异常发生的原因,不幸的是我们无法控制它,当我们注册通知时,我们这样做:

using NotificationServices = UnityEngine.iOS.NotificationServices;
using NotificationType = UnityEngine.iOS.NotificationType;

        /*
         .
         .
         .
         */

        void ACalledFunction ()
        {
            // Ask for permission for push notifications (Can Receive deviceToken)
            #if UNITY_IPHONE
            NotificationServices.RegisterForNotifications(
                NotificationType.Alert | 
                NotificationType.Badge | 
                NotificationType.Sound);
            #endif
        }
    }

更新 15/06/2015:解析 Unity SDK 1.5.1(il2cpp 脚本后端)

尝试注册解析 PN 时,我们仍然遇到相同的错误:

ExecutionEngineException:尝试调用未生成提前 (AOT) 代码的方法“System.Reflection.MonoProperty::StaticGetterAdapterFrame”。System.Reflection.MonoProperty+GetterAdapter.Invoke (System.Object _this) System.Reflection.MonoProperty+GetterAdapter.Invoke (System.Object _this) CurvedText.OnRectTransformDimensionsChange () System.Reflection.MonoProperty.GetValue (System.Object obj, System. Object[] index) Newtonsoft.Json.Bson.BsonString.set_IncludeLength (布尔值) Parse.ParseInstallation.get_Badge () Parse.ParseInstallation.SetPlatformAutomaticValue () Parse.ParseInstallation.SetAutomaticValues () Parse.ParseInstallation.SaveAsync (System.Threading.Tasks .Task toAwait, CancellationToken cancelToken) Parse.PlatformHooks+<>c__DisplayClass42.b__36 (System.2 taskStart, CancellationToken cancellationToken) Parse.ParseObject.SaveAsync (CancellationToken cancellationToken) Parse.ParseObject.SaveAsync () Parse.ParseInitializeBehaviour.b__0 (System.Byte[] deviceToken) FlurryAnalyticsIOS.SetSessionTimeout (Int32 seconds) Newtonsoft.Json.Bson.BsonString.set_IncludeLength (Boolean value) Parse.PlatformHooks+<>c__DisplayClass24.b__22 () System.Action.Invoke () Newtonsoft.Json.Bson.BsonString.set_IncludeLength (Boolean value) Parse.PlatformHooks+d__44.MoveNext () System.Array+InternalEnumerator1[System.UInt64].get_Current () UnityEngine.Debug:LogException(Exception) Parse.d__44:MoveNext() System.InternalEnumerator`1:get_Current()

4

1 回答 1

1

可以在 AOT 构建中使用反射(使用 Mono 脚本后端和 IL2CPP 脚本后端)。限制实际上是在System.Reflection.Emit命名空间中使用任何东西。

与 Mono 的 Unity 版本一起提供的 mscorlib.dll 程序集的某些部分对 AOT 代码路径不友好,并且System.Reflection.MonoProperty::StaticGetterAdapterFrame是其中之一。此代码不适用于 AOT 构建,但不幸的是,Unity 无法在编译时确定,因此错误只会在运行时发生。

这可能是 Parse SDK 论坛上提出的一个问题。可能可以使用不同的 SDK 来避免此问题。

于 2015-05-29T11:45:13.013 回答