From 10d045b11b0dfe78eda1dcb82260dfe3dcf0503f Mon Sep 17 00:00:00 2001 From: Dante Ruiz Date: Thu, 8 Nov 2018 17:16:34 -0800 Subject: [PATCH] fix infinate loading if entity server is not running --- interface/src/Application.cpp | 1 + interface/src/octree/SafeLanding.cpp | 15 ++++++++++++++- interface/src/octree/SafeLanding.h | 1 + scripts/system/interstitialPage.js | 2 +- 4 files changed, 17 insertions(+), 2 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 75a9f598f7..a9d75e745c 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -5705,6 +5705,7 @@ void Application::update(float deltaTime) { quint64 now = usecTimestampNow(); if (isServerlessMode() || _octreeProcessor.isLoadSequenceComplete()) { bool enableInterstitial = DependencyManager::get()->getDomainHandler().getInterstitialModeEnabled(); + if (gpuTextureMemSizeStable() || !enableInterstitial) { // we've received a new full-scene octree stats packet, or it's been long enough to try again anyway _lastPhysicsCheckTime = now; diff --git a/interface/src/octree/SafeLanding.cpp b/interface/src/octree/SafeLanding.cpp index db381d5350..224ef064b6 100644 --- a/interface/src/octree/SafeLanding.cpp +++ b/interface/src/octree/SafeLanding.cpp @@ -11,6 +11,7 @@ #include "SafeLanding.h" +#include #include #include "EntityTreeRenderer.h" @@ -19,6 +20,8 @@ #include "Application.h" const int SafeLanding::SEQUENCE_MODULO = std::numeric_limits::max() + 1; +const quint64 MAX_ELAPSED_TIME = 1000; // msec +const quint64 MICRO_TO_MILI_SECONDS = 1000; namespace { template bool lessThanWraparound(int a, int b) { @@ -107,7 +110,9 @@ void SafeLanding::noteReceivedsequenceNumber(int sequenceNumber) { } bool SafeLanding::isLoadSequenceComplete() { - if (isEntityLoadingComplete() && isSequenceNumbersComplete()) { + quint64 elapsedTime = (usecTimestampNow() - _startTime) / MICRO_TO_MILI_SECONDS; + if ((isEntityLoadingComplete() && isSequenceNumbersComplete()) || + (elapsedTime >= MAX_ELAPSED_TIME && isEntityServerNotRunning() && _sequenceNumbers.empty())) { Locker lock(_lock); _initialStart = INVALID_SEQUENCE; _initialEnd = INVALID_SEQUENCE; @@ -119,6 +124,14 @@ bool SafeLanding::isLoadSequenceComplete() { return !_trackingEntities; } +bool SafeLanding::isEntityServerNotRunning() { + auto nodeList = DependencyManager::get(); + const auto& domainHandler = nodeList->getDomainHandler(); + auto entityServer = nodeList->soloNodeOfType(NodeType::EntityServer); + + return (domainHandler.isConnected() && !entityServer); +} + float SafeLanding::loadingProgressPercentage() { Locker lock(_lock); static const int MINIMUM_TRACKED_ENTITY_STABILITY_COUNT = 15; diff --git a/interface/src/octree/SafeLanding.h b/interface/src/octree/SafeLanding.h index 51357b60ff..157fda53aa 100644 --- a/interface/src/octree/SafeLanding.h +++ b/interface/src/octree/SafeLanding.h @@ -40,6 +40,7 @@ private: bool isSequenceNumbersComplete(); void debugDumpSequenceIDs() const; bool isEntityLoadingComplete(); + bool isEntityServerNotRunning(); std::mutex _lock; using Locker = std::lock_guard; diff --git a/scripts/system/interstitialPage.js b/scripts/system/interstitialPage.js index b7c5809b3a..9a67964801 100644 --- a/scripts/system/interstitialPage.js +++ b/scripts/system/interstitialPage.js @@ -15,7 +15,7 @@ (function() { Script.include("/~/system/libraries/Xform.js"); Script.include("/~/system/libraries/globals.js"); - var DEBUG = false; + var DEBUG = true; var TOTAL_LOADING_PROGRESS = 3.7; var EPSILON = 0.05; var TEXTURE_EPSILON = 0.01;