引言
如果打包时使用命令行打包,并且结合[UnityEditor.Callbacks.DidReloadScripts]的OnScriptsReloaded方法使用时,可能会造成Unity崩溃。报错为UnityEngine.Experimental.Rendering.ScriptableRuntimeReflectionSystemWrapper:Internal_ScriptableRuntimeReflectionSystemWrapper_TickRealtimeProbes (bool&)
解决方案为在AssetDatabase刷新后BuildPipeline.BuildPlayer前等待1秒钟再处理打包操作,代码如下:
[UnityEditor.Callbacks.DidReloadScripts]
private static void OnScriptsReloaded()
{
Func<Task> WaitBuild = async () =>
{
await Task.Delay(TimeSpan.FromSeconds(1));
// do something..
};
WaitBuild();
}
这样就解决了打包闪退的问题。
打包闪退的日志最后附上:
Android Unity闪退日志?
========== OUTPUTTING STACK TRACE ==================
0x0000020620C7BEB1 (Mono JIT Code) UnityEngine.Experimental.Rendering.ScriptableRuntimeReflectionSystemWrapper:Internal_ScriptableRuntimeReflectionSystemWrapper_TickRealtimeProbes (bool&)
0x0000020620C7C0B6 (Mono JIT Code) (wrapper runtime-invoke) <Module>:runtime_invoke_void__this___intptr& (object,intptr,intptr,intptr)
0x00007FFF9A53D690 (mono-2.0-bdwgc) [c:\build\output\unity-technologies\mono\mono\mini\mini-runtime.c:2809] mono_jit_runtime_invoke
0x00007FFF9A4C2912 (mono-2.0-bdwgc) [c:\build\output\unity-technologies\mono\mono\metadata\object.c:2921] do_runtime_invoke
0x00007FFF9A4CB96F (mono-2.0-bdwgc) [c:\build\output\unity-technologies\mono\mono\metadata\object.c:2968] mono_runtime_invoke
0x00007FF73153CE4E (Unity) scripting_method_invoke
0x00007FF731536B8D (Unity) ScriptingInvocation::Invoke
0x00007FF731530B75 (Unity) ScriptingInvocation::Invoke<void>
0x00007FF72E89F0C1 (Unity) Scripting::UnityEngine::Experimental::Rendering::ScriptableRuntimeReflectionSystemWrapperProxy::Internal_ScriptableRuntimeReflectionSystemWrapper_TickRealtimeProbes
0x00007FF730811774 (Unity) ScriptableRuntimeReflectionSystem::UpdateRealtimeProbes
0x00007FF730809A85 (Unity) RenderManager::RenderOffscreenCameras
0x00007FF72F36D024 (Unity) PlayerLoopController::UpdateScene
0x00007FF72F8ECF34 (Unity) EditorSceneManager::NewScene
0x00007FF72F4F1A9A (Unity) BuildPlayerData
0x00007FF72F500805 (Unity) DoBuildPlayer_Build
0x00007FF72F4EF8E2 (Unity) BuildPlayer
0x00007FF7302DAAB8 (Unity) BuildPipeline::BuildPlayerInternalNoCheck
0x00007FF7302D87BE (Unity) BuildPipeline_CUSTOM_BuildPlayerInternalNoCheck
0x00000205D79E3ED3 (Mono JIT Code) (wrapper managed-to-native) UnityEditor.BuildPipeline:BuildPlayerInternalNoCheck (string[],string,string,UnityEditor.BuildTargetGroup,UnityEditor.BuildTarget,UnityEditor.BuildOptions,bool)
0x00000205D79E2DB3 (Mono JIT Code) UnityEditor.BuildPipeline:BuildPlayerInternal (string[],string,string,UnityEditor.BuildTargetGroup,UnityEditor.BuildTarget,UnityEditor.BuildOptions)
0x00000205D79E221B (Mono JIT Code) UnityEditor.BuildPipeline:BuildPlayer (string[],string,string,UnityEditor.BuildTargetGroup,UnityEditor.BuildTarget,UnityEditor.BuildOptions)
0x00000205D79E18CB (Mono JIT Code) UnityEditor.BuildPipeline:BuildPlayer (UnityEditor.BuildPlayerOptions)
0x00000205D79E0613 (Mono JIT Code) UnityEditor.BuildPipeline:BuildPlayer (UnityEditor.EditorBuildSettingsScene[],string,UnityEditor.BuildTarget,UnityEditor.BuildOptions)
0x00000205D5AE619B (Mono JIT Code) [D:\Ninja3\Assets\Editor\AssetBundleEditor\ProjectBuild.cs:929] ProjectBuild:BuildProject (UnityEditor.BuildTargetGroup,SinglePackageSetting)
0x00000205D5AE3193 (Mono JIT Code) [D:\Ninja3\Assets\Editor\AssetBundleEditor\ProjectBuild.cs:871] ProjectBuild:BuildProjectWithSinglePackageSetting (UnityEditor.BuildTargetGroup,SinglePackageSetting)
0x00000205D5AD0A4B (Mono JIT Code) [D:\Ninja3\Assets\Editor\AssetBundleEditor\ProjectBuild.cs:516] ProjectBuild:AndroidBuild ()
0x00000205D4E09D3B (Mono JIT Code) [D:\Ninja3\Assets\Editor\AssetBundleEditor\ProjectBuild.cs:132] ProjectBuild:Build ()
0x00000205D4D99D3B (Mono JIT Code) [D:\Ninja3\Assets\Editor\AssetBundleEditor\ProjectBuild.cs:1365] ProjectBuild:OnScriptsReloaded ()
0x00000205CD62E125 (Mono JIT Code) (wrapper runtime-invoke) object:runtime_invoke_void (object,intptr,intptr,intptr)
0x00007FFF9A53D690 (mono-2.0-bdwgc) [c:\build\output\unity-technologies\mono\mono\mini\mini-runtime.c:2809] mono_jit_runtime_invoke
0x00007FFF9A4C2912 (mono-2.0-bdwgc) [c:\build\output\unity-technologies\mono\mono\metadata\object.c:2921] do_runtime_invoke
0x00007FFF9A4CB96F (mono-2.0-bdwgc) [c:\build\output\unity-technologies\mono\mono\metadata\object.c:2968] mono_runtime_invoke
0x00007FF73153CE4E (Unity) scripting_method_invoke
0x00007FF731536B8D (Unity) ScriptingInvocation::Invoke
0x00007FF7314E7739 (Unity) CallMethodsWithAttribute
0x00007FF72F3601E3 (Unity) MonoDomainWasReloaded
0x00007FF7315022FB (Unity) MonoManager::EndReloadAssembly
0x00007FF731508787 (Unity) MonoManager::ReloadAssembly
0x00007FF72F90C6B3 (Unity) HandleCompileStatus
0x00007FF72F90939A (Unity) CompileScriptsWait
0x00007FF72F908B45 (Unity) CompileDirtyScriptsForEditorSyncInternal
0x00007FF72F9089D1 (Unity) CompileDirtyScriptsForEditorSync
0x00007FF72F909051 (Unity) CompileScriptsForEditorSync
0x00007FF72F3614A8 (Unity) Application::ParseARGVCommands
0x00007FF72F3587AB (Unity) Application::FinishLoadingProject
0x00007FF72FCE08E3 (Unity) WinMain
0x00007FF732CE8252 (Unity) __scrt_common_main_seh
0x00007FF812617034 (KERNEL32) BaseThreadInitThunk
0x00007FF812F62651 (ntdll) RtlUserThreadStart
========== END OF STACKTRACE ===========
iOS Unity闪退日志?
[00:00:00] Enlighten: Reflection Probes took 27.000441 seconds. Cancelled, so not done yet.
[00:00:00] Enlighten: LightingDataAsset took 26.969982 seconds. Cancelled, so not done yet.
Assertion failed on expression: 'GetApplication().MayUpdate()'
UnityEditor.BuildPipeline:BuildPlayerInternalNoCheck(String[], String, String, BuildTargetGroup, BuildTarget, BuildOptions, Boolean)
UnityEditor.BuildPipeline:BuildPlayerInternal(String[], String, String, BuildTargetGroup, BuildTarget, BuildOptions) (at /Users/bokken/buildslave/
unity/build/Editor/Mono/BuildPipeline.bindings.cs:387)
UnityEditor.BuildPipeline:BuildPlayer(String[], String, String, BuildTargetGroup, BuildTarget, BuildOptions) (at /Users/bokken/buildslave/unity/
build/Editor/Mono/BuildPipeline.bindings.cs:286)
UnityEditor.BuildPipeline:BuildPlayer(BuildPlayerOptions) (at /Users/bokken/buildslave/unity/build/Editor/Mono/BuildPipeline.bindings.cs:269)
UnityEditor.BuildPipeline:BuildPlayer(EditorBuildSettingsScene[], String, BuildTarget, BuildOptions) (at /Users/bokken/buildslave/unity/build/
Editor/Mono/BuildPipeline.bindings.cs:252)
ProjectBuild:IOSBuild() (at Assets/Editor/AssetBundleEditor/ProjectBuild.cs:607)
ProjectBuild:Build() (at Assets/Editor/AssetBundleEditor/ProjectBuild.cs:136)
ProjectBuild:OnScriptsReloaded() (at Assets/Editor/AssetBundleEditor/ProjectBuild.cs:1358)
[./Editor/Src/Application/PlayerLoopController.cpp line 187]
(Filename: /Users/bokken/buildslave/unity/build/Editor/Mono/BuildPipeline.bindings.cs Line: 387)
Obtained 21 stack frames.
#0 0x00000000000000 in (Unknown)
#1 0x000001abbd347c in mono_jit_runtime_invoke
#2 0x000001abd95f75 in do_runtime_invoke
#3 0x000001abd95ed3 in mono_runtime_invoke
#4 0x00000107f2f7f7 in scripting_method_invoke(ScriptingMethodPtr, ScriptingObjectPtr, ScriptingArguments&, ScriptingExceptionPtr*, bool)
#5 0x00000107f293bf in ScriptingInvocation::Invoke(ScriptingExceptionPtr*, bool)
#6 0x000001048f0f8d in
Scripting::UnityEngine::Experimental::Rendering::ScriptableRuntimeReflectionSystemWrapperProxy::Internal_ScriptableRuntimeReflectionSyste
mWrapper_TickRealtimeProbes(bool*, ScriptingExceptionPtr*)
#7 0x00000107019ba7 in ScriptableRuntimeReflectionSystem::UpdateRealtimeProbes()
#8 0x00000107015bcb in RenderManager::RenderOffscreenCameras()
#9 0x00000105619190 in PlayerLoopController::UpdateScene(bool)
#10 0x00000105e83c14 in EditorSceneManager::FinishNewScene()
#11 0x00000105e83b26 in EditorSceneManager::NewScene(NewSceneParameters const&)
#12 0x0000010583b984 in BuildPlayerData(BuildTargetPlatformGroup, BuildTargetPlatform, BuildPlayerOptions, BuildCompression const&,
std::__1::vector >, std::__1::allocator > > >, AssetBundleBuildData*, std::__1::vector >&, ScriptingObjectPtr, Vector2f, BuildReporting::BuildReport&, core::basic_string > const&, BuildReporting::BuiltAssetBundleInfo*, core::basic_string >
const&)
#13 0x0000010580cb19 in DoBuildPlayer(BuildPlayerSetup const&, std::__1::vector >&, core::basic_string >, std::__1::vector >, std::__1::allocator > > >, bool,
BuildReporting::BuildReport&, BuildReporting::BuiltAssetBundleInfo*, core::basic_string > const&)
#14 0x0000010581298a in BuildPlayer(BuildPlayerSetup const&, BuildReporting::BuildReport&)
#15 0x00000106b3d207 in BuildPipeline_CUSTOM_BuildPlayerInternalNoCheck(ScriptingBackendNativeArrayPtrOpaque*,
ScriptingBackendNativeStringPtrOpaque*, ScriptingBackendNativeStringPtrOpaque*, BuildTargetPlatformGroup, BuildTargetPlatform,
BuildPlayerOptions, unsigned char)
#16 0x000001cb2b20b0 in (wrapper managed-to-native) UnityEditor.BuildPipeline:BuildPlayerInternalNoCheck
(string[],string,string,UnityEditor.BuildTargetGroup,UnityEditor.BuildTarget,UnityEditor.BuildOptions,bool) {0x7f83e10fb2b8} + 0xc0 (0x1cb2b1ff0
0x1cb2b2162) [0x1ab7cec80 - Unity Child Domain]
#17 0x000001cb2b11eb in UnityEditor.BuildPipeline:BuildPlayerInternal
(string[],string,string,UnityEditor.BuildTargetGroup,UnityEditor.BuildTarget,UnityEditor.BuildOptions) {0x7f8436f06910} + 0x1ab (0x1cb2b1040
0x1cb2b123a) [0x1ab7cec80 - Unity Child Domain]
#18 0x000001cb2b07f3 in UnityEditor.BuildPipeline:BuildPlayer
(string[],string,string,UnityEditor.BuildTargetGroup,UnityEditor.BuildTarget,UnityEditor.BuildOptions) {0x7f8436f067c0} + 0x373 (0x1cb2b0480
0x1cb2b0948) [0x1ab7cec80 - Unity Child Domain]
#19 0x000001cb2b00c3 in UnityEditor.BuildPipeline:BuildPlayer (UnityEditor.BuildPlayerOptions) {0x7f8436f06798} + 0x193 (0x1cb2aff30
0x1cb2b0118) [0x1ab7cec80 - Unity Child Domain]
#20 0x000001cb2af07b in UnityEditor.BuildPipeline:BuildPlayer
(UnityEditor.EditorBuildSettingsScene[],string,UnityEditor.BuildTarget,UnityEditor.BuildOptions) {0x7f8436f06748} + 0x29b (0x1cb2aede0
0x1cb2af0dc) [0x1ab7cec80 - Unity Child Domain]
|