From 75e7472cda56ecd176a692fd62452af079122411 Mon Sep 17 00:00:00 2001 From: amzn-phist <52085794+amzn-phist@users.noreply.github.com> Date: Tue, 29 Jun 2021 10:54:27 -0500 Subject: [PATCH] Fixes audio crash and issues w/ audio playback (#1633) This was caused by the main thread audio update not being called all the time, especially Editor Game mode. The crash was due to main thread containers not being processed and emptied of their requests. Signed-off-by: amzn-phist <52085794+amzn-phist@users.noreply.github.com> --- Code/CryEngine/CryCommon/ISystem.h | 5 ----- Code/CryEngine/CryCommon/Mocks/ISystemMock.h | 4 ---- Code/CryEngine/CrySystem/System.cpp | 19 ++----------------- Code/CryEngine/CrySystem/System.h | 5 ----- Code/CryEngine/CrySystem/SystemInit.cpp | 5 ----- Code/Sandbox/Editor/CryEdit.cpp | 6 ------ 6 files changed, 2 insertions(+), 42 deletions(-) diff --git a/Code/CryEngine/CryCommon/ISystem.h b/Code/CryEngine/CryCommon/ISystem.h index 1a2ffc5a7c..c3b0b591dc 100644 --- a/Code/CryEngine/CryCommon/ISystem.h +++ b/Code/CryEngine/CryCommon/ISystem.h @@ -807,11 +807,6 @@ struct ISystem // Updates only require components during loading virtual bool UpdateLoadtime() = 0; - // Summary: - // Optimisation: do part of the update while waiting for occlusion queries to complete - virtual void DoWorkDuringOcclusionChecks() = 0; - virtual bool NeedDoWorkDuringOcclusionChecks() = 0; - // Summary: // Retrieve the name of the user currently logged in to the computer. virtual const char* GetUserName() = 0; diff --git a/Code/CryEngine/CryCommon/Mocks/ISystemMock.h b/Code/CryEngine/CryCommon/Mocks/ISystemMock.h index 9c25748eca..551949d6c2 100644 --- a/Code/CryEngine/CryCommon/Mocks/ISystemMock.h +++ b/Code/CryEngine/CryCommon/Mocks/ISystemMock.h @@ -26,10 +26,6 @@ public: bool(int, int)); MOCK_METHOD0(UpdateLoadtime, bool()); - MOCK_METHOD0(DoWorkDuringOcclusionChecks, - void()); - MOCK_METHOD0(NeedDoWorkDuringOcclusionChecks, - bool()); MOCK_METHOD0(RenderStatistics, void()); MOCK_METHOD0(GetUserName, diff --git a/Code/CryEngine/CrySystem/System.cpp b/Code/CryEngine/CrySystem/System.cpp index 07160a7143..2d3faf2b68 100644 --- a/Code/CryEngine/CrySystem/System.cpp +++ b/Code/CryEngine/CrySystem/System.cpp @@ -352,8 +352,6 @@ CSystem::CSystem(SharedEnvironmentInstance* pSharedEnvironment) AZ::Debug::Trace::Instance().Init(); } - m_bNeedDoWorkDuringOcclusionChecks = false; - m_eRuntimeState = ESYSTEM_EVENT_LEVEL_UNLOAD; m_bHasRenderedErrorMessage = false; @@ -948,16 +946,12 @@ bool CSystem::UpdatePostTickBus(int updateFlags, int /*nPauseMode*/) } ////////////////////////////////////////////////////////////////////// - //update sound system part 2 - if (!g_cvars.sys_deferAudioUpdateOptim && !m_bNoUpdate) + // Update sound system + if (!m_bNoUpdate) { FRAME_PROFILER("SysUpdate:UpdateAudioSystems", this, PROFILE_SYSTEM); UpdateAudioSystems(); } - else - { - m_bNeedDoWorkDuringOcclusionChecks = true; - } //Now update frame statistics CTimeValue cur_time = gEnv->pTimer->GetAsyncTime(); @@ -1004,15 +998,6 @@ bool CSystem::UpdateLoadtime() return !IsQuitting(); } -void CSystem::DoWorkDuringOcclusionChecks() -{ - if (g_cvars.sys_deferAudioUpdateOptim && !m_bNoUpdate) - { - UpdateAudioSystems(); - m_bNeedDoWorkDuringOcclusionChecks = false; - } -} - void CSystem::UpdateAudioSystems() { AZ_TRACE_METHOD(); diff --git a/Code/CryEngine/CrySystem/System.h b/Code/CryEngine/CrySystem/System.h index 8c122d0df2..e5d7426415 100644 --- a/Code/CryEngine/CrySystem/System.h +++ b/Code/CryEngine/CrySystem/System.h @@ -225,8 +225,6 @@ struct SSystemCVars int sys_FilesystemCaseSensitivity; - int sys_deferAudioUpdateOptim; - AZ::IO::ArchiveVars archiveVars; #if defined(WIN32) @@ -305,8 +303,6 @@ public: virtual bool UpdatePreTickBus(int updateFlags = 0, int nPauseMode = 0); virtual bool UpdatePostTickBus(int updateFlags = 0, int nPauseMode = 0); virtual bool UpdateLoadtime(); - virtual void DoWorkDuringOcclusionChecks(); - virtual bool NeedDoWorkDuringOcclusionChecks() { return m_bNeedDoWorkDuringOcclusionChecks; } //////////////////////////////////////////////////////////////////////// // CrySystemRequestBus interface implementation @@ -737,7 +733,6 @@ protected: // ------------------------------------------------------------- typedef std::list TErrorMessages; TErrorMessages m_ErrorMessages; bool m_bHasRenderedErrorMessage; - bool m_bNeedDoWorkDuringOcclusionChecks; ESystemEvent m_eRuntimeState; bool m_bIsAsserting; diff --git a/Code/CryEngine/CrySystem/SystemInit.cpp b/Code/CryEngine/CrySystem/SystemInit.cpp index 4b07de6933..c2b8eb9861 100644 --- a/Code/CryEngine/CrySystem/SystemInit.cpp +++ b/Code/CryEngine/CrySystem/SystemInit.cpp @@ -1823,11 +1823,6 @@ void CSystem::CreateSystemVars() "1 - CryPak preserves file name casing\n" "Default is 1"); - REGISTER_CVAR2("sys_deferAudioUpdateOptim", &g_cvars.sys_deferAudioUpdateOptim, 1, VF_NULL, - "0 - disable optimisation\n" - "1 - enable optimisation\n" - "Default is 1"); - m_sysNoUpdate = REGISTER_INT("sys_noupdate", 0, VF_CHEAT, "Toggles updating of system with sys_script_debugger.\n" "Usage: sys_noupdate [0/1]\n" diff --git a/Code/Sandbox/Editor/CryEdit.cpp b/Code/Sandbox/Editor/CryEdit.cpp index 0c859e7996..cff4ea8e4f 100644 --- a/Code/Sandbox/Editor/CryEdit.cpp +++ b/Code/Sandbox/Editor/CryEdit.cpp @@ -2336,12 +2336,6 @@ int CCryEditApp::IdleProcessing(bool bBackgroundUpdate) GetIEditor()->Notify(eNotify_OnIdleUpdate); - IEditor* pEditor = GetIEditor(); - if (!pEditor->GetGameEngine()->IsLevelLoaded() && pEditor->GetSystem()->NeedDoWorkDuringOcclusionChecks()) - { - pEditor->GetSystem()->DoWorkDuringOcclusionChecks(); - } - // Since the rendering is done based on the eNotify_OnIdleUpdate, we should trigger a TickSystem as well. // To ensure that there's a system tick for every render done in Idle AZ::ComponentApplication* componentApplication = nullptr;