From 288443d74b62585ad6dab5fbd00b0a84ac3e1d7b Mon Sep 17 00:00:00 2001 From: Bradley Austin Davis Date: Wed, 7 Feb 2018 16:43:15 -0800 Subject: [PATCH 1/4] Fix for deadlock triggering while loading QML engine --- interface/src/Application.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 0932eaf396..4a52e425fa 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -2337,7 +2337,9 @@ void Application::initializeUi() { tabletScriptingInterface->getTablet(SYSTEM_TABLET); } auto offscreenUi = DependencyManager::get(); + DeadlockWatchdogThread::pause(); offscreenUi->create(); + DeadlockWatchdogThread::resume(); auto surfaceContext = offscreenUi->getSurfaceContext(); From 4bb329696ac53c75eeeff565117d9f64223139e2 Mon Sep 17 00:00:00 2001 From: Bradley Austin Davis Date: Wed, 7 Feb 2018 15:27:34 -0800 Subject: [PATCH 2/4] Don't trigger a backtrace exception on quitting while in HMD --- interface/src/Application_render.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interface/src/Application_render.cpp b/interface/src/Application_render.cpp index 1231e5834b..512f79bf89 100644 --- a/interface/src/Application_render.cpp +++ b/interface/src/Application_render.cpp @@ -55,7 +55,7 @@ void Application::paintGL() { // If a display plugin loses it's underlying support, it // needs to be able to signal us to not use it if (!displayPlugin->beginFrameRender(_renderFrameCount)) { - updateDisplayMode(); + QMetaObject::invokeMethod(this, "updateDisplayMode"); return; } } From f6fbac25b0477b8a9f6d7a940e4eda9742bc1b7d Mon Sep 17 00:00:00 2001 From: Bradley Austin Davis Date: Thu, 8 Feb 2018 10:23:25 -0800 Subject: [PATCH 3/4] Prevent deadlock crashes when building shaders at startup --- interface/src/Application.cpp | 53 ++++++++++++++++++----------------- 1 file changed, 28 insertions(+), 25 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 4a52e425fa..c2b6f1da35 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -307,8 +307,12 @@ static QTimer locationUpdateTimer; static QTimer identityPacketTimer; static QTimer pingTimer; -static const QString DISABLE_WATCHDOG_FLAG("HIFI_DISABLE_WATCHDOG"); -static bool DISABLE_WATCHDOG = QProcessEnvironment::systemEnvironment().contains(DISABLE_WATCHDOG_FLAG); +#if defined(Q_OS_ANDROID) +static bool DISABLE_WATCHDOG = true; +#else +static const QString DISABLE_WATCHDOG_FLAG{ "HIFI_DISABLE_WATCHDOG" }; +static bool DISABLE_WATCHDOG = nsightActive() || QProcessEnvironment::systemEnvironment().contains(DISABLE_WATCHDOG_FLAG); +#endif static const int MAX_CONCURRENT_RESOURCE_DOWNLOADS = 16; @@ -398,20 +402,26 @@ public: *crashTrigger = 0xDEAD10CC; } + static void withPause(const std::function& lambda) { + pause(); + lambda(); + resume(); + } static void pause() { _paused = true; } static void resume() { - _paused = false; + // Update the heartbeat BEFORE resuming the checks updateHeartbeat(); + _paused = false; } void run() override { while (!_quit) { QThread::sleep(HEARTBEAT_UPDATE_INTERVAL_SECS); // Don't do heartbeat detection under nsight - if (nsightActive() || _paused) { + if (_paused) { continue; } uint64_t lastHeartbeat = _heartbeat; // sample atomic _heartbeat, because we could context switch away and have it updated on us @@ -1103,9 +1113,6 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo // Make sure we don't time out during slow operations at startup updateHeartbeat(); - // Now that OpenGL is initialized, we are sure we have a valid context and can create the various pipeline shaders with success. - DependencyManager::get()->initializeShapePipelines(); - // sessionRunTime will be reset soon by loadSettings. Grab it now to get previous session value. // The value will be 0 if the user blew away settings this session, which is both a feature and a bug. static const QString TESTER = "HIFI_TESTER"; @@ -2220,25 +2227,21 @@ void Application::initializeGL() { initDisplay(); qCDebug(interfaceapp, "Initialized Display."); -#ifdef Q_OS_OSX - // FIXME: on mac os the shaders take up to 1 minute to compile, so we pause the deadlock watchdog thread. - DeadlockWatchdogThread::pause(); -#endif + // FIXME: on low end systems os the shaders take up to 1 minute to compile, so we pause the deadlock watchdog thread. + DeadlockWatchdogThread::withPause([&] { + // Set up the render engine + render::CullFunctor cullFunctor = LODManager::shouldRender; + static const QString RENDER_FORWARD = "HIFI_RENDER_FORWARD"; + bool isDeferred = !QProcessEnvironment::systemEnvironment().contains(RENDER_FORWARD); + _renderEngine->addJob("UpdateScene"); + _renderEngine->addJob("SecondaryCameraJob", cullFunctor); + _renderEngine->addJob("RenderMainView", cullFunctor, isDeferred); + _renderEngine->load(); + _renderEngine->registerScene(_main3DScene); - // Set up the render engine - render::CullFunctor cullFunctor = LODManager::shouldRender; - static const QString RENDER_FORWARD = "HIFI_RENDER_FORWARD"; - bool isDeferred = !QProcessEnvironment::systemEnvironment().contains(RENDER_FORWARD); - _renderEngine->addJob("UpdateScene"); - _renderEngine->addJob("SecondaryCameraJob", cullFunctor); - _renderEngine->addJob("RenderMainView", cullFunctor, isDeferred); - -#ifdef Q_OS_OSX - DeadlockWatchdogThread::resume(); -#endif - - _renderEngine->load(); - _renderEngine->registerScene(_main3DScene); + // Now that OpenGL is initialized, we are sure we have a valid context and can create the various pipeline shaders with success. + DependencyManager::get()->initializeShapePipelines(); + }); _offscreenContext = new OffscreenGLCanvas(); _offscreenContext->setObjectName("MainThreadContext"); From bc51f3643d87c85e44f658af91daa87737f1d69b Mon Sep 17 00:00:00 2001 From: samcake Date: Mon, 12 Feb 2018 09:09:15 -0800 Subject: [PATCH 4/4] Adding a check for item existence before calling the update on the render::Item --- libraries/render/src/render/Scene.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/libraries/render/src/render/Scene.cpp b/libraries/render/src/render/Scene.cpp index bc75e5ad21..aaf1d2f1c8 100644 --- a/libraries/render/src/render/Scene.cpp +++ b/libraries/render/src/render/Scene.cpp @@ -342,6 +342,13 @@ void Scene::updateItems(const Transaction::Updates& transactions) { // Access the true item auto& item = _items[updateID]; + + // If item doesn't exist it cannot be updated + if (!item.exist()) { + continue; + } + + // Good to go, deal with the update auto oldCell = item.getCell(); auto oldKey = item.getKey();