Asset Processor: Remove gem loading from AP (#6488)
* AssetBuilder sends builder registration network message to AP Signed-off-by: amzn-mike <80125227+amzn-mike@users.noreply.github.com> * Add AP activating status message Signed-off-by: amzn-mike <80125227+amzn-mike@users.noreply.github.com> * First builder handles registration. Fixed deadlock caused by AP and AssetBuilder waiting on each other when registering by moving AP builder start code to a thread Signed-off-by: amzn-mike <80125227+amzn-mike@users.noreply.github.com> * Clean up external builder registration Signed-off-by: amzn-mike <80125227+amzn-mike@users.noreply.github.com> * Add thread description for builder manager idle thread Signed-off-by: amzn-mike <80125227+amzn-mike@users.noreply.github.com> * Remove gem loading Signed-off-by: amzn-mike <80125227+amzn-mike@users.noreply.github.com> * Clean up builder registration and remove unused functions Signed-off-by: amzn-mike <80125227+amzn-mike@users.noreply.github.com> * Remove PostActivate call from batch application since it will be called after builders are registered Signed-off-by: amzn-mike <80125227+amzn-mike@users.noreply.github.com> * Removal external builder dependency scanning since we no longer support builder dlls Signed-off-by: amzn-mike <80125227+amzn-mike@users.noreply.github.com> * Fix missing bus disconnect Signed-off-by: amzn-mike <80125227+amzn-mike@users.noreply.github.com> * Remove unused variable Signed-off-by: amzn-mike <80125227+amzn-mike@users.noreply.github.com> * Moved AP-AssetBuilder specific types into AssetBuilder.Static library. Also removed some unused/old code Signed-off-by: amzn-mike <80125227+amzn-mike@users.noreply.github.com>
This commit is contained in:
@@ -16,6 +16,7 @@
|
||||
#include <native/utilities/AssetBuilderInfo.h>
|
||||
#include <QCoreApplication>
|
||||
#include <AzCore/Settings/SettingsRegistryMergeUtils.h>
|
||||
#include <AssetBuilder/AssetBuilderStatic.h>
|
||||
|
||||
namespace AssetProcessor
|
||||
{
|
||||
@@ -138,7 +139,7 @@ namespace AssetProcessor
|
||||
}
|
||||
}
|
||||
|
||||
bool Builder::Start()
|
||||
bool Builder::Start(bool doRegistration)
|
||||
{
|
||||
// Get the current BinXXX folder based on the current running AP
|
||||
QString applicationDir = QCoreApplication::instance()->applicationDirPath();
|
||||
@@ -155,7 +156,7 @@ namespace AssetProcessor
|
||||
return false;
|
||||
}
|
||||
|
||||
const AZStd::vector<AZStd::string> params = BuildParams("resident", buildersFolder.c_str(), UuidString(), "", "");
|
||||
const AZStd::vector<AZStd::string> params = BuildParams("resident", buildersFolder.c_str(), UuidString(), "", "", doRegistration);
|
||||
|
||||
m_processWatcher = LaunchProcess(fullExePathString.c_str(), params);
|
||||
|
||||
@@ -179,7 +180,7 @@ namespace AssetProcessor
|
||||
return !m_processWatcher || (m_processWatcher && m_processWatcher->IsProcessRunning(exitCode));
|
||||
}
|
||||
|
||||
AZStd::vector<AZStd::string> Builder::BuildParams(const char* task, const char* moduleFilePath, const AZStd::string& builderGuid, const AZStd::string& jobDescriptionFile, const AZStd::string& jobResponseFile) const
|
||||
AZStd::vector<AZStd::string> Builder::BuildParams(const char* task, const char* moduleFilePath, const AZStd::string& builderGuid, const AZStd::string& jobDescriptionFile, const AZStd::string& jobResponseFile, bool doRegistration) const
|
||||
{
|
||||
QDir projectCacheRoot;
|
||||
AssetUtilities::ComputeProjectCacheRoot(projectCacheRoot);
|
||||
@@ -200,6 +201,11 @@ namespace AssetProcessor
|
||||
params.emplace_back(AZStd::string::format(R"(-engine-path="%s")", enginePath.c_str()));
|
||||
params.emplace_back(AZStd::string::format("-port=%d", portNumber));
|
||||
|
||||
if(doRegistration)
|
||||
{
|
||||
params.emplace_back("--register");
|
||||
}
|
||||
|
||||
if (moduleFilePath && moduleFilePath[0])
|
||||
{
|
||||
params.emplace_back(AZStd::string::format(R"(-module="%s")", moduleFilePath));
|
||||
@@ -232,7 +238,7 @@ namespace AssetProcessor
|
||||
{
|
||||
AzFramework::ProcessLauncher::ProcessLaunchInfo processLaunchInfo;
|
||||
processLaunchInfo.m_processExecutableString = fullExePath;
|
||||
|
||||
|
||||
AZStd::vector<AZStd::string> commandLineArray{ fullExePath };
|
||||
commandLineArray.insert(commandLineArray.end(), params.begin(), params.end());
|
||||
processLaunchInfo.m_commandlineParameters = AZStd::move(commandLineArray);
|
||||
@@ -350,17 +356,19 @@ namespace AssetProcessor
|
||||
BuilderManager::BuilderManager(ConnectionManager* connectionManager)
|
||||
{
|
||||
using namespace AZStd::placeholders;
|
||||
connectionManager->RegisterService(AssetBuilderSDK::BuilderHelloRequest::MessageType(), AZStd::bind(&BuilderManager::IncomingBuilderPing, this, _1, _2, _3, _4, _5));
|
||||
connectionManager->RegisterService(AssetBuilder::BuilderHelloRequest::MessageType(), AZStd::bind(&BuilderManager::IncomingBuilderPing, this, _1, _2, _3, _4, _5));
|
||||
|
||||
// Setup a background thread to pump the idle builders so they don't get blocked trying to output to stdout/err
|
||||
m_pollingThread = AZStd::thread([this]()
|
||||
AZStd::thread_desc desc;
|
||||
desc.m_name = "BuilderManager Idle Pump";
|
||||
m_pollingThread = AZStd::thread(desc, [this]()
|
||||
{
|
||||
while (!m_quitListener.WasQuitRequested())
|
||||
{
|
||||
while (!m_quitListener.WasQuitRequested())
|
||||
{
|
||||
PumpIdleBuilders();
|
||||
AZStd::this_thread::sleep_for(AZStd::chrono::milliseconds(s_IdleBuilderPumpingDelayMS));
|
||||
}
|
||||
});
|
||||
PumpIdleBuilders();
|
||||
AZStd::this_thread::sleep_for(AZStd::chrono::milliseconds(s_IdleBuilderPumpingDelayMS));
|
||||
}
|
||||
});
|
||||
|
||||
m_quitListener.BusConnect();
|
||||
BusConnect();
|
||||
@@ -399,8 +407,8 @@ namespace AssetProcessor
|
||||
|
||||
void BuilderManager::IncomingBuilderPing(AZ::u32 connId, AZ::u32 /*type*/, AZ::u32 serial, QByteArray payload, QString platform)
|
||||
{
|
||||
AssetBuilderSDK::BuilderHelloRequest requestPing;
|
||||
AssetBuilderSDK::BuilderHelloResponse responsePing;
|
||||
AssetBuilder::BuilderHelloRequest requestPing;
|
||||
AssetBuilder::BuilderHelloResponse responsePing;
|
||||
|
||||
if (!AZ::Utils::LoadObjectFromBufferInPlace(payload.data(), payload.length(), requestPing))
|
||||
{
|
||||
@@ -476,7 +484,7 @@ namespace AssetProcessor
|
||||
return builder;
|
||||
}
|
||||
|
||||
BuilderRef BuilderManager::GetBuilder()
|
||||
BuilderRef BuilderManager::GetBuilder(bool doRegistration)
|
||||
{
|
||||
AZStd::shared_ptr<Builder> newBuilder;
|
||||
BuilderRef builderRef;
|
||||
@@ -484,27 +492,30 @@ namespace AssetProcessor
|
||||
{
|
||||
AZStd::unique_lock<AZStd::mutex> lock(m_buildersMutex);
|
||||
|
||||
for (auto itr = m_builders.begin(); itr != m_builders.end(); )
|
||||
if (!doRegistration)
|
||||
{
|
||||
auto& builder = itr->second;
|
||||
|
||||
if (!builder->m_busy)
|
||||
for (auto itr = m_builders.begin(); itr != m_builders.end();)
|
||||
{
|
||||
builder->PumpCommunicator();
|
||||
auto& builder = itr->second;
|
||||
|
||||
if (builder->IsValid())
|
||||
if (!builder->m_busy)
|
||||
{
|
||||
return BuilderRef(builder);
|
||||
builder->PumpCommunicator();
|
||||
|
||||
if (builder->IsValid())
|
||||
{
|
||||
return BuilderRef(builder);
|
||||
}
|
||||
else
|
||||
{
|
||||
itr = m_builders.erase(itr);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
itr = m_builders.erase(itr);
|
||||
++itr;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
++itr;
|
||||
}
|
||||
}
|
||||
|
||||
AZ_TracePrintf("BuilderManager", "Starting new builder for job request\n");
|
||||
@@ -516,7 +527,7 @@ namespace AssetProcessor
|
||||
builderRef = BuilderRef(newBuilder);
|
||||
}
|
||||
|
||||
if (!newBuilder->Start())
|
||||
if (!newBuilder->Start(doRegistration))
|
||||
{
|
||||
AZ_Error("BuilderManager", false, "Builder failed to start");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user