【发布时间】:2015-08-11 00:42:24
【问题描述】:
我们正在使用 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] 中 :0
在 Parse.ParseInstallation.SaveAsync (System.Threading.Tasks.Task 等待,
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] in :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(Exception)
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
}
}
2015 年 6 月 15 日更新:解析 Unity SDK 1.5.1(il2cpp 脚本后端)
我们在尝试注册解析 PN 时仍然遇到同样的错误:
ExecutionEngineException: 试图调用方法 'System.Reflection.MonoProperty::StaticGetterAdapterFrame' 未生成提前 (AOT) 代码。 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[] 索引) 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.Object _) Parse.ParseObject+c__DisplayClass18.b__17 (System.Threading.Tasks.Task toAwait) FlurryAnalyticsIOS.SetSessionTimeout (Int32 秒) Parse.ParseObject.SetProperty[ParseACL](Parse.ParseACL 值, System.String propertyName) Parse.Internal.TaskQueue.Enqueue[Task] (System.Func
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()
【问题讨论】:
-
iOS 是 AOT。我认为反射不适用于 AOT?
-
是的,iOS 是 AOT,但如果有任何反映,则在统一导出或 xCode 构建 iap 时构建时会出现错误
-
在网络上搜索“mono getvalue ios”时可以获得很多信息。看起来 .GetValue() 表现不佳,这似乎是您错误的根源。可能是因为使用了泛型?
-
感谢您对 Atra Viator 的评论,但我在问题中说过,与使用不兼容 AOT 的任何单声道功能相比,它与某处的冲突更相关,因为我添加的 sdk 单独工作并且我的项目也完全独立运行。
标签: c# unity3d parse-platform push-notification il2cpp