diff --git a/libs/fgviewer/src/ApiHandler.cpp b/libs/fgviewer/src/ApiHandler.cpp index e2acaa81c87..51e79c47ca5 100644 --- a/libs/fgviewer/src/ApiHandler.cpp +++ b/libs/fgviewer/src/ApiHandler.cpp @@ -87,9 +87,10 @@ bool ApiHandler::handleGet(CivetServer* server, struct mg_connection* conn) { return error(__LINE__, uri); } -void ApiHandler::addFrameGraph(ViewHandle view_handle) { +void ApiHandler::updateFrameGraph(ViewHandle view_handle) { std::unique_lock const lock(mStatusMutex); snprintf(statusFrameGraphId, sizeof(statusFrameGraphId), "%8.8x", view_handle); + mCurrentStatus++; mStatusCondition.notify_all(); } diff --git a/libs/fgviewer/src/ApiHandler.h b/libs/fgviewer/src/ApiHandler.h index 3ab4a9dae59..36f84fc6a32 100644 --- a/libs/fgviewer/src/ApiHandler.h +++ b/libs/fgviewer/src/ApiHandler.h @@ -40,7 +40,7 @@ class ApiHandler : public CivetHandler { bool handleGet(CivetServer* server, struct mg_connection* conn); - void addFrameGraph(ViewHandle view_handle); + void updateFrameGraph(ViewHandle view_handle); private: const FrameGraphInfo* getFrameGraphInfo(struct mg_connection* conn, @@ -58,7 +58,7 @@ class ApiHandler : public CivetHandler { // This variable is to implement a *hanging* effect for /api/status. The call to /api/status // will always block until statusMaterialId is updated again. The client is expected to keep // calling /api/status (a constant "pull" to simulate a push). - std::atomic mCurrentStatus = 0; + uint64_t mCurrentStatus = 0; }; } // filament::fgviewer diff --git a/libs/fgviewer/src/DebugServer.cpp b/libs/fgviewer/src/DebugServer.cpp index 70d2af08947..268b410d22f 100644 --- a/libs/fgviewer/src/DebugServer.cpp +++ b/libs/fgviewer/src/DebugServer.cpp @@ -110,6 +110,7 @@ ViewHandle DebugServer::createView(utils::CString name) { std::unique_lock lock(mViewsMutex); ViewHandle handle = mViewCounter++; mViews.emplace(handle, FrameGraphInfo(std::move(name))); + mApiHandler->updateFrameGraph(handle); return handle; } @@ -121,8 +122,19 @@ void DebugServer::destroyView(ViewHandle h) { void DebugServer::update(ViewHandle h, FrameGraphInfo info) { std::unique_lock lock(mViewsMutex); + const auto it = mViews.find(h); + if (it == mViews.end()) { + slog.w << "[fgviewer] Received update for unknown handle " << h; + return; + } + + bool has_changed = !(it->second == info); + if (!has_changed) + return; + mViews.erase(h); mViews.emplace(h, std::move(info)); + mApiHandler->updateFrameGraph(h); } } // namespace filament::fgviewer