# HG changeset patch # User Benjamin Golinvaux # Date 1566810113 -7200 # Node ID 92e32e263ae903d3b5d96e92f1c90921597fe1ed # Parent 733be18fe140e7c6062fd1d2ab7f2ca3bb9232dd Removed log in IsContextLost (too many calls) + removed glGetError guards on calls (expensive) + added shared_ptr ref count dump in LoaderCache (still needs to figure that one out) diff -r 733be18fe140 -r 92e32e263ae9 Framework/Loaders/LoaderCache.cpp --- a/Framework/Loaders/LoaderCache.cpp Fri Aug 23 15:02:42 2019 +0200 +++ b/Framework/Loaders/LoaderCache.cpp Mon Aug 26 11:01:53 2019 +0200 @@ -240,10 +240,36 @@ #if ORTHANC_ENABLE_WASM != 1 LockingEmitter::WriterLock lock(lockingEmitter_); #endif + +//#ifndef NDEBUG + // ISO way of checking for debug builds + DebugDisplayObjRefCounts(); +//#endif seriesVolumeProgressiveLoaders_.clear(); multiframeVolumeLoaders_.clear(); dicomVolumeImageMPRSlicers_.clear(); dicomStructureSetLoaders_.clear(); } + + template void DebugDisplayObjRefCountsInMap( + const std::string& name, const std::map >& myMap) + { + LOG(TRACE) << "Map \"" << name << "\" ref counts:"; + size_t i = 0; + for (const auto& it : myMap) + { + auto ptr = it.second; + LOG(TRACE) << " element #" << i << ": ref count = " << it.second.use_count(); + i++; + } + } + + void LoaderCache::DebugDisplayObjRefCounts() + { + DebugDisplayObjRefCountsInMap("seriesVolumeProgressiveLoaders_", seriesVolumeProgressiveLoaders_); + DebugDisplayObjRefCountsInMap("multiframeVolumeLoaders_", multiframeVolumeLoaders_); + DebugDisplayObjRefCountsInMap("dicomVolumeImageMPRSlicers_", dicomVolumeImageMPRSlicers_); + DebugDisplayObjRefCountsInMap("dicomStructureSetLoaders_", dicomStructureSetLoaders_); + } } diff -r 733be18fe140 -r 92e32e263ae9 Framework/Loaders/LoaderCache.h --- a/Framework/Loaders/LoaderCache.h Fri Aug 23 15:02:42 2019 +0200 +++ b/Framework/Loaders/LoaderCache.h Mon Aug 26 11:01:53 2019 +0200 @@ -64,6 +64,7 @@ private: + void DebugDisplayObjRefCounts(); #if ORTHANC_ENABLE_WASM == 1 WebAssemblyOracle& oracle_; #else diff -r 733be18fe140 -r 92e32e263ae9 Framework/OpenGL/OpenGLIncludes.h --- a/Framework/OpenGL/OpenGLIncludes.h Fri Aug 23 15:02:42 2019 +0200 +++ b/Framework/OpenGL/OpenGLIncludes.h Mon Aug 26 11:01:53 2019 +0200 @@ -41,9 +41,19 @@ #endif #if ORTHANC_ENABLE_SDL == 1 -#include +# include + +# ifdef NDEBUG + +// glGetError is very expensive! -#define ORTHANC_OPENGL_CHECK(name) \ +# define ORTHANC_OPENGL_CHECK(name) +# define ORTHANC_OPENGL_TRACE_CURRENT_CONTEXT(msg) +# define ORTHANC_CHECK_CURRENT_CONTEXT(context) + +# else + +# define ORTHANC_OPENGL_CHECK(name) \ if(true) \ { \ GLenum error = glGetError(); \ @@ -54,14 +64,14 @@ } \ } else (void)0 -#define ORTHANC_OPENGL_TRACE_CURRENT_CONTEXT(msg) \ +# define ORTHANC_OPENGL_TRACE_CURRENT_CONTEXT(msg) \ if(true) \ { \ SDL_GLContext ctx = SDL_GL_GetCurrentContext(); \ LOG(TRACE) << msg << " | Current OpenGL context is " << std::hex << ctx; \ } else (void)0 -#define ORTHANC_CHECK_CURRENT_CONTEXT(context) \ +# define ORTHANC_CHECK_CURRENT_CONTEXT(context) \ if(true) \ { \ SDL_GLContext actualCtx = SDL_GL_GetCurrentContext(); \ @@ -72,6 +82,8 @@ } \ } else (void)0 +# endif + #endif #if ORTHANC_ENABLE_WASM == 1 diff -r 733be18fe140 -r 92e32e263ae9 Framework/OpenGL/WebAssemblyOpenGLContext.cpp --- a/Framework/OpenGL/WebAssemblyOpenGLContext.cpp Fri Aug 23 15:02:42 2019 +0200 +++ b/Framework/OpenGL/WebAssemblyOpenGLContext.cpp Mon Aug 26 11:01:53 2019 +0200 @@ -71,7 +71,7 @@ bool IsContextLost() { - LOG(TRACE) << "IsContextLost() for context " << std::hex << context_ << std::dec; + //LOG(TRACE) << "IsContextLost() for context " << std::hex << context_ << std::dec; bool apiFlag = (emscripten_is_webgl_context_lost(context_) != 0); isContextLost_ = apiFlag; return isContextLost_;