Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More verbose messages when failing to load render engine #236

Merged
merged 1 commit into from
Feb 11, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 40 additions & 18 deletions src/RenderEngineManager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -471,42 +471,64 @@ bool RenderEngineManagerPrivate::LoadEnginePlugin(
return false;
}

std::string pluginName = *pluginNames.begin();
if (pluginName.empty())
auto engineNames = pluginLoader.PluginsImplementing<
ignition::rendering::RenderEnginePlugin>();

if (engineNames.empty())
{
ignerr << "Failed to load plugin [" << _filename <<
"] : couldn't load library on path [" << pathToLib <<
"]." << std::endl;
std::stringstream error;
error << "Found no render engine plugins in ["
<< _filename << "], available interfaces are:"
<< std::endl;
for (auto pluginName : pluginNames)
{
error << "- " << pluginName << std::endl;
}
ignerr << error.str();
return false;
}

auto commonPlugin = this->pluginLoader.Instantiate(pluginName);
if (!commonPlugin)
auto engineName = *engineNames.begin();
if (engineNames.size() > 1)
{
ignerr << "Failed to load plugin [" << _filename <<
"] : couldn't instantiate plugin on path [" << pathToLib <<
"]." << std::endl;
return false;
std::stringstream warn;
warn << "Found multiple render engine plugins in ["
<< _filename << "]:"
<< std::endl;
for (auto pluginName : engineNames)
{
warn << "- " << pluginName << std::endl;
}
warn << "Loading [" << engineName << "]." << std::endl;
ignwarn << warn.str();
}

auto plugin =
commonPlugin->QueryInterface<ignition::rendering::RenderEnginePlugin>();
auto plugin = pluginLoader.Instantiate(engineName);
if (!plugin)
{
ignerr << "Failed to load plugin [" << _filename <<
"] : couldn't get interface [" << pluginName <<
"]." << std::endl;
ignerr << "Failed to instantiate plugin [" << engineName << "]"
<< std::endl;
return false;
}

auto renderPlugin =
plugin->QueryInterface<ignition::rendering::RenderEnginePlugin>();

if (!renderPlugin)
{
ignerr << "Failed to query interface from [" << engineName << "]"
<< std::endl;
return false;
}

// This triggers the engine to be instantiated
{
std::lock_guard<std::recursive_mutex> lock(this->enginesMutex);
this->engines[_filename] = plugin->Engine();
this->engines[_filename] = renderPlugin->Engine();
}

// store engine plugin data so plugin can be unloaded later
this->enginePlugins[_filename] = pluginName;
this->enginePlugins[_filename] = engineName;

return true;
}
Expand Down