From decb94b719311dba73338538f73216214c6fc37b Mon Sep 17 00:00:00 2001 From: Ryan Huffman Date: Thu, 13 Oct 2016 14:01:45 -0700 Subject: [PATCH 1/6] Update ScriptCache to clear ATP assets when disconnected from a domain --- interface/src/Application.cpp | 4 ++++ libraries/script-engine/src/ScriptCache.cpp | 13 +++++++++++++ libraries/script-engine/src/ScriptCache.h | 1 + 3 files changed, 18 insertions(+) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 80e444462f..5658ed8b64 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -668,6 +668,10 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer) : connect(&domainHandler, SIGNAL(disconnectedFromDomain()), SLOT(clearDomainOctreeDetails())); connect(&domainHandler, &DomainHandler::domainConnectionRefused, this, &Application::domainConnectionRefused); + // We could clear ATP assets only when changing domains, but it's possible that the domain you are connected + // to has gone down and switched to a new content set, so when you reconnect the cached ATP assets will no longer be valid. + connect(&domainHandler, &DomainHandler::disconnectedFromDomain, DependencyManager::get().data(), &ScriptCache::clearATPScriptsFromCache); + // update our location every 5 seconds in the metaverse server, assuming that we are authenticated with one const qint64 DATA_SERVER_LOCATION_CHANGE_UPDATE_MSECS = 5 * MSECS_PER_SECOND; diff --git a/libraries/script-engine/src/ScriptCache.cpp b/libraries/script-engine/src/ScriptCache.cpp index e9f20b5164..a2a6a9ecf1 100644 --- a/libraries/script-engine/src/ScriptCache.cpp +++ b/libraries/script-engine/src/ScriptCache.cpp @@ -36,6 +36,19 @@ void ScriptCache::clearCache() { _scriptCache.clear(); } +void ScriptCache::clearATPScriptsFromCache() { + Lock lock(_containerLock); + qDebug(scriptengine) << "Clearing ATP scripts from ScriptCache"; + for (auto it = _scriptCache.begin(); it != _scriptCache.end();) { + if (it.key().scheme() == "atp") { + qDebug(scriptengine) << "Removing: " << it.key(); + it = _scriptCache.erase(it); + } else { + ++it; + } + } +} + QString ScriptCache::getScript(const QUrl& unnormalizedURL, ScriptUser* scriptUser, bool& isPending, bool reload) { QUrl url = ResourceManager::normalizeURL(unnormalizedURL); QString scriptContents; diff --git a/libraries/script-engine/src/ScriptCache.h b/libraries/script-engine/src/ScriptCache.h index 17ba5c4b0a..5aac62b08b 100644 --- a/libraries/script-engine/src/ScriptCache.h +++ b/libraries/script-engine/src/ScriptCache.h @@ -39,6 +39,7 @@ class ScriptCache : public QObject, public Dependency { public: void clearCache(); + Q_INVOKABLE void clearATPScriptsFromCache(); void getScriptContents(const QString& scriptOrURL, contentAvailableCallback contentAvailable, bool forceDownload = false); From 7626f49ddc964b4a1d69609f87fd4280f33b35ee Mon Sep 17 00:00:00 2001 From: Ryan Huffman Date: Thu, 13 Oct 2016 15:43:28 -0700 Subject: [PATCH 2/6] Replace qDebug with qCDebug in ScriptCache --- libraries/script-engine/src/ScriptCache.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libraries/script-engine/src/ScriptCache.cpp b/libraries/script-engine/src/ScriptCache.cpp index a2a6a9ecf1..96e3d7e914 100644 --- a/libraries/script-engine/src/ScriptCache.cpp +++ b/libraries/script-engine/src/ScriptCache.cpp @@ -38,10 +38,10 @@ void ScriptCache::clearCache() { void ScriptCache::clearATPScriptsFromCache() { Lock lock(_containerLock); - qDebug(scriptengine) << "Clearing ATP scripts from ScriptCache"; + qCDebug(scriptengine) << "Clearing ATP scripts from ScriptCache"; for (auto it = _scriptCache.begin(); it != _scriptCache.end();) { if (it.key().scheme() == "atp") { - qDebug(scriptengine) << "Removing: " << it.key(); + qCDebug(scriptengine) << "Removing: " << it.key(); it = _scriptCache.erase(it); } else { ++it; From 6cf4802cc22e157007692e18e1911ad7bb2be099 Mon Sep 17 00:00:00 2001 From: Ryan Huffman Date: Thu, 13 Oct 2016 16:06:07 -0700 Subject: [PATCH 3/6] Change default hifi address from dev-welcome to welcome --- libraries/networking/src/AddressManager.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/networking/src/AddressManager.h b/libraries/networking/src/AddressManager.h index f753bb0548..ab7b53a6d9 100644 --- a/libraries/networking/src/AddressManager.h +++ b/libraries/networking/src/AddressManager.h @@ -23,7 +23,7 @@ #include "AccountManager.h" const QString HIFI_URL_SCHEME = "hifi"; -const QString DEFAULT_HIFI_ADDRESS = "hifi://dev-welcome"; +const QString DEFAULT_HIFI_ADDRESS = "hifi://welcome"; const QString SANDBOX_HIFI_ADDRESS = "hifi://localhost"; const QString SANDBOX_STATUS_URL = "http://localhost:60332/status"; const QString INDEX_PATH = "/"; From d4e83a7461f1bcb10084b3411fdc13838798e999 Mon Sep 17 00:00:00 2001 From: Brad Davis Date: Wed, 12 Oct 2016 23:57:42 -0700 Subject: [PATCH 4/6] Don't crash on OpenVR activation when SteamVR isn't running --- plugins/openvr/src/OpenVrDisplayPlugin.cpp | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/plugins/openvr/src/OpenVrDisplayPlugin.cpp b/plugins/openvr/src/OpenVrDisplayPlugin.cpp index 50443ce73c..b9a491a8a2 100644 --- a/plugins/openvr/src/OpenVrDisplayPlugin.cpp +++ b/plugins/openvr/src/OpenVrDisplayPlugin.cpp @@ -377,9 +377,6 @@ void OpenVrDisplayPlugin::init() { } bool OpenVrDisplayPlugin::internalActivate() { - _openVrDisplayActive = true; - _container->setIsOptionChecked(StandingHMDSensorMode, true); - if (!_system) { _system = acquireOpenVrSystem(); } @@ -388,6 +385,18 @@ bool OpenVrDisplayPlugin::internalActivate() { return false; } + // If OpenVR isn't running, then the compositor won't be accessible + // FIXME find a way to launch the compositor? + if (!vr::VRCompositor()) { + qWarning() << "Failed to acquire OpenVR compositor"; + releaseOpenVrSystem(); + _system = nullptr; + return false; + } + + _openVrDisplayActive = true; + _container->setIsOptionChecked(StandingHMDSensorMode, true); + _system->GetRecommendedRenderTargetSize(&_renderTargetSize.x, &_renderTargetSize.y); // Recommended render target size is per-eye, so double the X size for // left + right eyes From 46326ed27c234f6a3693c888cccb0a0e83f91d46 Mon Sep 17 00:00:00 2001 From: Brad Davis Date: Thu, 13 Oct 2016 16:46:02 -0700 Subject: [PATCH 5/6] Fix crash in switching to plugin that uses the composite framebuffer in customizeContext --- .../src/display-plugins/OpenGLDisplayPlugin.cpp | 13 +++++++++---- .../src/display-plugins/OpenGLDisplayPlugin.h | 2 ++ 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/libraries/display-plugins/src/display-plugins/OpenGLDisplayPlugin.cpp b/libraries/display-plugins/src/display-plugins/OpenGLDisplayPlugin.cpp index 02e5a064f5..a92f36ed71 100644 --- a/libraries/display-plugins/src/display-plugins/OpenGLDisplayPlugin.cpp +++ b/libraries/display-plugins/src/display-plugins/OpenGLDisplayPlugin.cpp @@ -414,6 +414,7 @@ void OpenGLDisplayPlugin::customizeContext() { _cursorPipeline = gpu::Pipeline::create(program, state); } } + updateCompositeFramebuffer(); } void OpenGLDisplayPlugin::uncustomizeContext() { @@ -557,10 +558,7 @@ void OpenGLDisplayPlugin::compositeScene() { } void OpenGLDisplayPlugin::compositeLayers() { - auto renderSize = getRecommendedRenderSize(); - if (!_compositeFramebuffer || _compositeFramebuffer->getSize() != renderSize) { - _compositeFramebuffer = gpu::FramebufferPointer(gpu::Framebuffer::create("displayPlugin::composite", gpu::Element::COLOR_RGBA_32, renderSize.x, renderSize.y)); - } + updateCompositeFramebuffer(); { PROFILE_RANGE_EX("compositeScene", 0xff0077ff, (uint64_t)presentCount()) @@ -760,3 +758,10 @@ void OpenGLDisplayPlugin::render(std::function f) { OpenGLDisplayPlugin::~OpenGLDisplayPlugin() { qDebug() << "Destroying OpenGLDisplayPlugin"; } + +void OpenGLDisplayPlugin::updateCompositeFramebuffer() { + auto renderSize = getRecommendedRenderSize(); + if (!_compositeFramebuffer || _compositeFramebuffer->getSize() != renderSize) { + _compositeFramebuffer = gpu::FramebufferPointer(gpu::Framebuffer::create("OpenGLDisplayPlugin::composite", gpu::Element::COLOR_RGBA_32, renderSize.x, renderSize.y)); + } +} diff --git a/libraries/display-plugins/src/display-plugins/OpenGLDisplayPlugin.h b/libraries/display-plugins/src/display-plugins/OpenGLDisplayPlugin.h index 9369f6d72c..a6de3f7baa 100644 --- a/libraries/display-plugins/src/display-plugins/OpenGLDisplayPlugin.h +++ b/libraries/display-plugins/src/display-plugins/OpenGLDisplayPlugin.h @@ -78,6 +78,8 @@ protected: glm::uvec2 getSurfaceSize() const; glm::uvec2 getSurfacePixels() const; + void updateCompositeFramebuffer(); + virtual void compositeLayers(); virtual void compositeScene(); virtual void compositeOverlay(); From ff3d1b3d0139d9af70efd797bd55439a5af153a5 Mon Sep 17 00:00:00 2001 From: Brad Davis Date: Thu, 13 Oct 2016 16:53:37 -0700 Subject: [PATCH 6/6] Don't use VR compositor if it doesn't exist --- plugins/openvr/src/OpenVrHelpers.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/plugins/openvr/src/OpenVrHelpers.cpp b/plugins/openvr/src/OpenVrHelpers.cpp index ccf318a629..13880af89f 100644 --- a/plugins/openvr/src/OpenVrHelpers.cpp +++ b/plugins/openvr/src/OpenVrHelpers.cpp @@ -109,8 +109,12 @@ void releaseOpenVrSystem() { vr::Texture_t vrTexture{ (void*)INVALID_GL_TEXTURE_HANDLE, vr::API_OpenGL, vr::ColorSpace_Auto }; static vr::VRTextureBounds_t OPENVR_TEXTURE_BOUNDS_LEFT{ 0, 0, 0.5f, 1 }; static vr::VRTextureBounds_t OPENVR_TEXTURE_BOUNDS_RIGHT{ 0.5f, 0, 1, 1 }; - vr::VRCompositor()->Submit(vr::Eye_Left, &vrTexture, &OPENVR_TEXTURE_BOUNDS_LEFT); - vr::VRCompositor()->Submit(vr::Eye_Right, &vrTexture, &OPENVR_TEXTURE_BOUNDS_RIGHT); + + auto compositor = vr::VRCompositor(); + if (compositor) { + compositor->Submit(vr::Eye_Left, &vrTexture, &OPENVR_TEXTURE_BOUNDS_LEFT); + compositor->Submit(vr::Eye_Right, &vrTexture, &OPENVR_TEXTURE_BOUNDS_RIGHT); + } vr::VR_Shutdown(); _openVrQuitRequested = false;