matdbg: repair invalid JSON and display of active variants.
The JSON response to /api/active became malformed after #4465 because raw hex strings need to be enclosed by quotes. This commit changes the variant format in the /api/materials response to be consistent with one used for /api/active. By using integers instead of strings, we're avoiding the need to parse integers at run time. The JSON error did not appear in the Chrome console because it was being silenced as a hack to appease "matinfo --web-server". I fix this by removing the hack and simply emitting a valid response when there's no live backend. Also fixed the display of materials, which were always being marked as active even when they had no active variants.
This commit is contained in:
@@ -144,7 +144,7 @@ public:
|
||||
std::string uri(request->local_uri);
|
||||
|
||||
const auto error = [request](int line) {
|
||||
slog.e << "DebugServer: 404 at line " << line << ": " << request->query_string
|
||||
slog.e << "DebugServer: 404 at line " << line << ": " << request->local_uri
|
||||
<< io::endl;
|
||||
return false;
|
||||
};
|
||||
@@ -160,6 +160,14 @@ public:
|
||||
mServer->updateActiveVariants();
|
||||
mg_printf(conn, kSuccessHeader.c_str(), "application/json");
|
||||
mg_printf(conn, "{");
|
||||
|
||||
// If the backend has not been resolved to Vulkan, Metal, etc, then return an empty
|
||||
// list. This can occur if the server is matinfo rather than an actual Filament session.
|
||||
if (mServer->mBackend == backend::Backend::DEFAULT) {
|
||||
mg_printf(conn, "}");
|
||||
return true;
|
||||
}
|
||||
|
||||
int index = 0;
|
||||
for (const auto& pair : mServer->mMaterialRecords) {
|
||||
const auto& record = pair.second;
|
||||
|
||||
Reference in New Issue
Block a user