changeset 959:13e078adfb94 toa2019082301

Better error log in fetch failure callback + timeout 600sec in OrthancRestApiCommand + guard against dead controller access in PanSceneTracker + relaxed DicomStructureSet AddReferenceSlice method to accept extraneous adds of the same slice (while trying to understand how it happens in the first place)
author Benjamin Golinvaux <bgo@osimis.io>
date Fri, 23 Aug 2019 14:16:45 +0200
parents 769249e1f3b4
children 733be18fe140
files Framework/Oracle/OrthancRestApiCommand.cpp Framework/Oracle/WebAssemblyOracle.cpp Framework/Scene2D/PanSceneTracker.cpp Framework/Toolbox/DicomStructureSet.cpp
diffstat 4 files changed, 34 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/Framework/Oracle/OrthancRestApiCommand.cpp	Fri Aug 23 10:16:32 2019 +0200
+++ b/Framework/Oracle/OrthancRestApiCommand.cpp	Fri Aug 23 14:16:45 2019 +0200
@@ -51,7 +51,7 @@
   OrthancRestApiCommand::OrthancRestApiCommand() :
     method_(Orthanc::HttpMethod_Get),
     uri_("/"),
-    timeout_(60)
+    timeout_(600)
   {
   }
 
--- a/Framework/Oracle/WebAssemblyOracle.cpp	Fri Aug 23 10:16:32 2019 +0200
+++ b/Framework/Oracle/WebAssemblyOracle.cpp	Fri Aug 23 14:16:45 2019 +0200
@@ -237,13 +237,23 @@
     {
       std::auto_ptr<FetchContext> context(reinterpret_cast<FetchContext*>(fetch->userData));
       
-      LOG(ERROR) << "Fetching " << fetch->url << " failed, HTTP failure status code: " << fetch->status;
+      const size_t kEmscriptenStatusTextSize = sizeof(emscripten_fetch_t::statusText);
+      char message[kEmscriptenStatusTextSize + 1];
+      memcpy(message, fetch->statusText, kEmscriptenStatusTextSize);
+      message[kEmscriptenStatusTextSize] = 0;
+
+      LOG(ERROR) << "Fetching " << fetch->url
+        << " failed, HTTP failure status code: " << fetch->status
+        << " | statusText = " << message
+        << " | numBytes = " << fetch->numBytes
+        << " | totalBytes = " << fetch->totalBytes
+        << " | readyState = " << fetch->readyState;
 
       /**
        * TODO - The following code leads to an infinite recursion, at
        * least with Firefox running on incognito mode => WHY?
        **/      
-      //emscripten_fetch_close(fetch); // Also free data on failure.
+      emscripten_fetch_close(fetch); // Also free data on failure.
     }
   };
     
--- a/Framework/Scene2D/PanSceneTracker.cpp	Fri Aug 23 10:16:32 2019 +0200
+++ b/Framework/Scene2D/PanSceneTracker.cpp	Fri Aug 23 14:16:45 2019 +0200
@@ -37,17 +37,26 @@
   void PanSceneTracker::PointerMove(const PointerEvent& event)
   {
     ScenePoint2D p = event.GetMainPosition().Apply(originalCanvasToScene_);
-      
-    GetController()->SetSceneToCanvasTransform(
-      AffineTransform2D::Combine(
-        originalSceneToCanvas_,
-        AffineTransform2D::CreateOffset(p.GetX() - pivot_.GetX(),
-                                        p.GetY() - pivot_.GetY())));
+
+      // The controller is a weak pointer. It could be deleted when the
+      // tracker is still alive (for instance, because of a lost WebGL
+      // context)
+      if(GetController().get() != NULL)
+      {
+      GetController()->SetSceneToCanvasTransform(
+        AffineTransform2D::Combine(
+          originalSceneToCanvas_,
+          AffineTransform2D::CreateOffset(p.GetX() - pivot_.GetX(),
+                                          p.GetY() - pivot_.GetY())));
+      }
   }
 
   void PanSceneTracker::Cancel()
   {
-    GetController()->SetSceneToCanvasTransform(originalSceneToCanvas_);
+      if(GetController().get() != NULL)
+      {
+        GetController()->SetSceneToCanvasTransform(originalSceneToCanvas_);
+      }
   }
 
 }
--- a/Framework/Toolbox/DicomStructureSet.cpp	Fri Aug 23 10:16:32 2019 +0200
+++ b/Framework/Toolbox/DicomStructureSet.cpp	Fri Aug 23 14:16:45 2019 +0200
@@ -581,7 +581,11 @@
     {
       // This geometry is already known
       LOG(ERROR) << "DicomStructureSet::AddReferencedSlice(): (referencedSlices_.find(sopInstanceUid) != referencedSlices_.end()). sopInstanceUid = " << sopInstanceUid;
-      throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls);
+      
+      // TODO: the following assertion has been disabled on 20190822 by BGO
+      // because it occurred from time to time. Since it wrecked havoc on the
+      
+      //throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls);
     }
     else
     {