diff --git a/libraries/entities/src/EntityItemPropertiesDefaults.h b/libraries/entities/src/EntityItemPropertiesDefaults.h index aa4fb5c619..d5d44bb4a8 100644 --- a/libraries/entities/src/EntityItemPropertiesDefaults.h +++ b/libraries/entities/src/EntityItemPropertiesDefaults.h @@ -65,7 +65,7 @@ const float ENTITY_ITEM_MAX_RESTITUTION = 0.99f; const float ENTITY_ITEM_DEFAULT_RESTITUTION = 0.5f; const float ENTITY_ITEM_MIN_FRICTION = 0.0f; -const float ENTITY_ITEM_MAX_FRICTION = 0.99f; +const float ENTITY_ITEM_MAX_FRICTION = 10.0f; const float ENTITY_ITEM_DEFAULT_FRICTION = 0.5f; const bool ENTITY_ITEM_DEFAULT_COLLISIONLESS = false; diff --git a/libraries/networking/src/udt/Socket.cpp b/libraries/networking/src/udt/Socket.cpp index cf66847b6c..b3ddc24914 100644 --- a/libraries/networking/src/udt/Socket.cpp +++ b/libraries/networking/src/udt/Socket.cpp @@ -36,6 +36,11 @@ Socket::Socket(QObject* parent) : // start our timer for the synchronization time interval _synTimer->start(_synInterval); + + // make sure we hear about errors and state changes from the underlying socket + connect(&_udpSocket, SIGNAL(error(QAbstractSocket::SocketError)), + this, SLOT(handleSocketError(QAbstractSocket::SocketError))); + connect(&_udpSocket, &QAbstractSocket::stateChanged, this, &Socket::handleStateChanged); } void Socket::bind(const QHostAddress& address, quint16 port) { @@ -406,3 +411,13 @@ std::vector Socket::getConnectionSockAddrs() { } return addr; } + +void Socket::handleSocketError(QAbstractSocket::SocketError socketError) { + qCWarning(networking) << "udt::Socket error -" << socketError; +} + +void Socket::handleStateChanged(QAbstractSocket::SocketState socketState) { + if (socketState != QAbstractSocket::BoundState) { + qCWarning(networking) << "udt::Socket state changed - state is now" << socketState; + } +} diff --git a/libraries/networking/src/udt/Socket.h b/libraries/networking/src/udt/Socket.h index 35a32a034f..6b8ccf1fa8 100644 --- a/libraries/networking/src/udt/Socket.h +++ b/libraries/networking/src/udt/Socket.h @@ -86,7 +86,10 @@ public slots: private slots: void readPendingDatagrams(); void rateControlSync(); - + + void handleSocketError(QAbstractSocket::SocketError socketError); + void handleStateChanged(QAbstractSocket::SocketState socketState); + private: void setSystemBufferSizes(); Connection& findOrCreateConnection(const HifiSockAddr& sockAddr); diff --git a/libraries/render/src/render/DrawTask.cpp b/libraries/render/src/render/DrawTask.cpp index 58b3a50e54..6d43d169c3 100755 --- a/libraries/render/src/render/DrawTask.cpp +++ b/libraries/render/src/render/DrawTask.cpp @@ -46,7 +46,7 @@ void renderShape(RenderArgs* args, const ShapePlumberPointer& shapeContext, cons } else if (key.hasOwnPipeline()) { item.render(args); } else { - qDebug() << "Item could not be rendered: invalid key ?" << key; + qDebug() << "Item could not be rendered with invalid key" << key; } } @@ -96,7 +96,7 @@ void render::renderStateSortShapes(const SceneContextPointer& sceneContext, cons } else if (key.hasOwnPipeline()) { ownPipelineBucket.push_back(item); } else { - qDebug() << "Item could not be rendered: invalid key ?" << key; + qDebug() << "Item could not be rendered with invalid key" << key; } } } diff --git a/libraries/render/src/render/ShapePipeline.cpp b/libraries/render/src/render/ShapePipeline.cpp index a16847fddf..37c8db8364 100644 --- a/libraries/render/src/render/ShapePipeline.cpp +++ b/libraries/render/src/render/ShapePipeline.cpp @@ -95,7 +95,11 @@ const ShapePipelinePointer ShapePlumber::pickPipeline(RenderArgs* args, const Ke const auto& pipelineIterator = _pipelineMap.find(key); if (pipelineIterator == _pipelineMap.end()) { - qDebug() << "Couldn't find a pipeline from ShapeKey ?" << key; + // The first time we can't find a pipeline, we should log it + if (_missingKeys.find(key) == _missingKeys.end()) { + _missingKeys.insert(key); + qDebug() << "Couldn't find a pipeline for" << key; + } return PipelinePointer(nullptr); } diff --git a/libraries/render/src/render/ShapePipeline.h b/libraries/render/src/render/ShapePipeline.h index af1b05f5c0..aba4de6acf 100644 --- a/libraries/render/src/render/ShapePipeline.h +++ b/libraries/render/src/render/ShapePipeline.h @@ -12,6 +12,8 @@ #ifndef hifi_render_ShapePipeline_h #define hifi_render_ShapePipeline_h +#include + #include #include @@ -147,7 +149,7 @@ public: bool hasOwnPipeline() const { return _flags[OWN_PIPELINE]; } bool isValid() const { return !_flags[INVALID]; } - // Hasher for use in unordered_maps + // Comparator for use in stl containers class Hash { public: size_t operator() (const ShapeKey& key) const { @@ -155,7 +157,7 @@ public: } }; - // Comparator for use in unordered_maps + // Comparator for use in stl containers class KeyEqual { public: bool operator()(const ShapeKey& lhs, const ShapeKey& rhs) const { return lhs._flags == rhs._flags; } @@ -271,7 +273,11 @@ public: protected: void addPipelineHelper(const Filter& filter, Key key, int bit, const PipelinePointer& pipeline); PipelineMap _pipelineMap; + +private: + mutable std::unordered_set _missingKeys; }; + using ShapePlumberPointer = std::shared_ptr; } diff --git a/libraries/script-engine/src/ScriptEngine.cpp b/libraries/script-engine/src/ScriptEngine.cpp index 6d4747df2d..6c7739c784 100644 --- a/libraries/script-engine/src/ScriptEngine.cpp +++ b/libraries/script-engine/src/ScriptEngine.cpp @@ -146,12 +146,15 @@ ScriptEngine::ScriptEngine(const QString& scriptContents, const QString& fileNam ScriptEngine::~ScriptEngine() { qCDebug(scriptengine) << "Script Engine shutting down (destructor) for script:" << getFilename(); + auto scriptEngines = DependencyManager::get(); if (scriptEngines) { scriptEngines->removeScriptEngine(this); } else { qCWarning(scriptengine) << "Script destroyed after ScriptEngines!"; } + + waitTillDoneRunning(); } void ScriptEngine::disconnectNonEssentialSignals() { @@ -172,7 +175,7 @@ void ScriptEngine::runInThread() { } _isThreaded = true; - QThread* workerThread = new QThread(this); // thread is not owned, so we need to manage the delete + QThread* workerThread = new QThread(); QString scriptEngineName = QString("Script Thread:") + getFilename(); workerThread->setObjectName(scriptEngineName); @@ -194,35 +197,35 @@ void ScriptEngine::runInThread() { void ScriptEngine::waitTillDoneRunning() { // If the script never started running or finished running before we got here, we don't need to wait for it - if (_isRunning && _isThreaded) { - - // NOTE: waitTillDoneRunning() will be called on the main Application thread, inside of stopAllScripts() - // we want the application thread to continue to process events, because the scripts will likely need to - // marshall messages across to the main thread. For example if they access Settings or Menu in any of their - // shutdown code. + auto workerThread = thread(); + if (_isThreaded && workerThread) { QString scriptName = getFilename(); - auto startedWaiting = usecTimestampNow(); - while (thread()->isRunning()) { - // process events for the main application thread, allowing invokeMethod calls to pass between threads - QCoreApplication::processEvents(); - auto stillWaiting = usecTimestampNow(); - auto elapsedUsecs = stillWaiting - startedWaiting; - - // if we've been waiting a second or more, then tell the script engine to stop evaluating - static const auto MAX_SCRIPT_EVALUATION_TIME = USECS_PER_SECOND; - static const auto WAITING_TOO_LONG = MAX_SCRIPT_EVALUATION_TIME * 5; - // if we've been waiting for more than 5 seconds then we should be more aggessive about stopping - if (elapsedUsecs > WAITING_TOO_LONG) { - qCDebug(scriptengine) << "Script " << scriptName << " has been running too long [" << elapsedUsecs << " usecs] quitting."; - thread()->quit(); + while (workerThread->isRunning()) { + // NOTE: This will be called on the main application thread from stopAllScripts. + // The application thread will need to continue to process events, because + // the scripts will likely need to marshall messages across to the main thread, e.g. + // if they access Settings or Menu in any of their shutdown code. So: + // Process events for the main application thread, allowing invokeMethod calls to pass between threads. + QCoreApplication::processEvents(); // thread-safe :) + + // If we've been waiting a second or more, then tell the script engine to stop evaluating + static const auto MAX_SCRIPT_EVALUATION_TIME = USECS_PER_SECOND; + auto elapsedUsecs = usecTimestampNow() - startedWaiting; + if (elapsedUsecs > MAX_SCRIPT_EVALUATION_TIME) { + qCDebug(scriptengine) << + "Script " << scriptName << " has been running too long [" << elapsedUsecs << " usecs] quitting."; + abortEvaluation(); // to allow the thread to quit + workerThread->quit(); break; - } else if (elapsedUsecs > MAX_SCRIPT_EVALUATION_TIME) { - qCDebug(scriptengine) << "Script " << scriptName << " has been running too long [" << elapsedUsecs << " usecs] aborting evaluation."; - QMetaObject::invokeMethod(this, "abortEvaluation"); } + + // Avoid a pure busy wait + QThread::yieldCurrentThread(); } + + workerThread->deleteLater(); } } diff --git a/unpublishedScripts/DomainContent/CellScience/Scripts/nav_button_cells.js b/unpublishedScripts/DomainContent/CellScience/Scripts/nav_button_cells.js index 343564c4e4..2253bb8068 100644 --- a/unpublishedScripts/DomainContent/CellScience/Scripts/nav_button_cells.js +++ b/unpublishedScripts/DomainContent/CellScience/Scripts/nav_button_cells.js @@ -7,7 +7,7 @@ (function() { - var version = 12; + var version = 13; var baseURL = "https://hifi-production.s3.amazonaws.com/DomainContent/CellScience/"; var button; @@ -47,7 +47,7 @@ var buttonPadding = 10; var offset = 0; var buttonPositionX = (offset + 1) * (buttonWidth + buttonPadding) + (windowDimensions.x / 2) - (buttonWidth * 3 + buttonPadding * 2.5); - var buttonPositionY = (windowDimensions.y - buttonHeight) - 50; + var buttonPositionY = (windowDimensions.y - buttonHeight) - 150; button = Overlays.addOverlay("image", { x: buttonPositionX, y: buttonPositionY, diff --git a/unpublishedScripts/DomainContent/CellScience/Scripts/nav_button_hexokinase.js b/unpublishedScripts/DomainContent/CellScience/Scripts/nav_button_hexokinase.js index 6f704af7bd..7ca8de64a6 100644 --- a/unpublishedScripts/DomainContent/CellScience/Scripts/nav_button_hexokinase.js +++ b/unpublishedScripts/DomainContent/CellScience/Scripts/nav_button_hexokinase.js @@ -13,7 +13,7 @@ (function() { - var version = 12; + var version = 13; var baseURL = "https://hifi-production.s3.amazonaws.com/DomainContent/CellScience/"; var button; @@ -53,7 +53,7 @@ var buttonPadding = 10; var offset = 3; var buttonPositionX = (offset + 1) * (buttonWidth + buttonPadding) + (windowDimensions.x / 2) - (buttonWidth * 3 + buttonPadding * 2.5); - var buttonPositionY = (windowDimensions.y - buttonHeight) - 50; + var buttonPositionY = (windowDimensions.y - buttonHeight) - 150; button = Overlays.addOverlay("image", { x: buttonPositionX, y: buttonPositionY, diff --git a/unpublishedScripts/DomainContent/CellScience/Scripts/nav_button_inside_the_cell.js b/unpublishedScripts/DomainContent/CellScience/Scripts/nav_button_inside_the_cell.js index 5e9faf3086..47cffa1a52 100644 --- a/unpublishedScripts/DomainContent/CellScience/Scripts/nav_button_inside_the_cell.js +++ b/unpublishedScripts/DomainContent/CellScience/Scripts/nav_button_inside_the_cell.js @@ -7,7 +7,7 @@ (function() { - var version = 12; + var version = 13; var baseURL = "https://hifi-production.s3.amazonaws.com/DomainContent/CellScience/"; var button; @@ -47,7 +47,7 @@ var buttonPadding = 10; var offset = 1; var buttonPositionX = (offset + 1) * (buttonWidth + buttonPadding) + (windowDimensions.x / 2) - (buttonWidth * 3 + buttonPadding * 2.5); - var buttonPositionY = (windowDimensions.y - buttonHeight) - 50; + var buttonPositionY = (windowDimensions.y - buttonHeight) - 150; button = Overlays.addOverlay("image", { x: buttonPositionX, y: buttonPositionY, diff --git a/unpublishedScripts/DomainContent/CellScience/Scripts/nav_button_ribosome.js b/unpublishedScripts/DomainContent/CellScience/Scripts/nav_button_ribosome.js index 4cbc375390..95ec29a479 100644 --- a/unpublishedScripts/DomainContent/CellScience/Scripts/nav_button_ribosome.js +++ b/unpublishedScripts/DomainContent/CellScience/Scripts/nav_button_ribosome.js @@ -6,7 +6,7 @@ // (function() { - var version = 12; + var version = 13; var baseURL = "https://hifi-production.s3.amazonaws.com/DomainContent/CellScience/"; var button; @@ -26,9 +26,9 @@ z: 3000 }, target: { - x: 3276.6, - y: 13703.3, - z: 4405.6 + x: 13500, + y: 3000, + z: 3000 }, preload: function(entityId) { print('CELL PRELOAD RIBOSOME 1') @@ -46,7 +46,7 @@ var buttonPadding = 10; var offset = 2; var buttonPositionX = (offset + 1) * (buttonWidth + buttonPadding) + (windowDimensions.x / 2) - (buttonWidth * 3 + buttonPadding * 2.5); - var buttonPositionY = (windowDimensions.y - buttonHeight) - 50; + var buttonPositionY = (windowDimensions.y - buttonHeight) - 150; button = Overlays.addOverlay("image", { x: buttonPositionX, y: buttonPositionY, diff --git a/unpublishedScripts/DomainContent/CellScience/importNow.js b/unpublishedScripts/DomainContent/CellScience/importNow.js index eb4c0e4b64..0d06e60954 100644 --- a/unpublishedScripts/DomainContent/CellScience/importNow.js +++ b/unpublishedScripts/DomainContent/CellScience/importNow.js @@ -5,7 +5,7 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -var version = 1217; +var version = 1219; var WORLD_OFFSET = { x: 0,