Showing the changes to interface/src/Application.cpp (1 of 55 files). Show all
Unified · Split
| @@ -210,9 +210,7 @@ const QHash<QString, Application::AcceptURLMethod> Application::_acceptedExtensi · 209 unmodified lines | ||
| 210 | 210 | |
| 211 | 211 | class DeadlockWatchdogThread : public QThread { |
| 212 | 212 | public: |
| 213 | − static const unsigned long HEARTBEAT_CHECK_INTERVAL_SECS = 1; | |
| 214 | 213 | static const unsigned long HEARTBEAT_UPDATE_INTERVAL_SECS = 1; |
| 215 | − static const unsigned long HEARTBEAT_REPORT_INTERVAL_USECS = 5 * USECS_PER_SECOND; | |
| 216 | 214 | static const unsigned long MAX_HEARTBEAT_AGE_USECS = 30 * USECS_PER_SECOND; |
| 217 | 215 | static const int WARNING_ELAPSED_HEARTBEAT = 500 * USECS_PER_MSEC; // warn if elapsed heartbeat average is large |
| 218 | 216 | static const int HEARTBEAT_SAMPLES = 100000; // ~5 seconds worth of samples |
| @@ -239,8 +237,6 @@ public: · 20 unmodified lines | ||
| 239 | 237 | *crashTrigger = 0xDEAD10CC; |
| 240 | 238 | } |
| 241 | 239 | |
| 242 | − static void setSuppressStatus(bool suppress) { _suppressStatus = suppress; } | |
| 243 | − | |
| 244 | 240 | void run() override { |
| 245 | 241 | while (!_quit) { |
| 246 | 242 | QThread::sleep(HEARTBEAT_UPDATE_INTERVAL_SECS); |
| @@ -248,7 +244,6 @@ public: · 1 unmodified line | ||
| 248 | 244 | uint64_t lastHeartbeat = _heartbeat; // sample atomic _heartbeat, because we could context switch away and have it updated on us |
| 249 | 245 | uint64_t now = usecTimestampNow(); |
| 250 | 246 | auto lastHeartbeatAge = (now > lastHeartbeat) ? now - lastHeartbeat : 0; |
| 251 | − auto sinceLastReport = (now > _lastReport) ? now - _lastReport : 0; | |
| 252 | 247 | auto elapsedMovingAverage = _movingAverage.getAverage(); |
| 253 | 248 | |
| 254 | 249 | if (elapsedMovingAverage > _maxElapsedAverage) { |
| @@ -274,21 +269,10 @@ public: · 19 unmodified lines | ||
| 274 | 269 | if (elapsedMovingAverage > WARNING_ELAPSED_HEARTBEAT) { |
| 275 | 270 | qDebug() << "DEADLOCK WATCHDOG WARNING:" |
| 276 | 271 | << "lastHeartbeatAge:" << lastHeartbeatAge |
| 277 | − << "elapsedMovingAverage:" << elapsedMovingAverage << "** OVER EXPECTED VALUE**" | |
| 278 | − << "maxElapsed:" << _maxElapsed | |
| 279 | − << "maxElapsedAverage:" << _maxElapsedAverage | |
| 280 | − << "samples:" << _movingAverage.getSamples(); | |
| 281 | − _lastReport = now; | |
| 282 | − } | |
| 283 | − | |
| 284 | − if (!_suppressStatus && sinceLastReport > HEARTBEAT_REPORT_INTERVAL_USECS) { | |
| 285 | − qDebug() << "DEADLOCK WATCHDOG STATUS:" | |
| 286 | − << "lastHeartbeatAge:" << lastHeartbeatAge | |
| 287 | − << "elapsedMovingAverage:" << elapsedMovingAverage | |
| 272 | + << "elapsedMovingAverage:" << elapsedMovingAverage << "** OVER EXPECTED VALUE **" | |
| 288 | 273 | << "maxElapsed:" << _maxElapsed |
| 289 | 274 | << "maxElapsedAverage:" << _maxElapsedAverage |
| 290 | 275 | << "samples:" << _movingAverage.getSamples(); |
| 291 | − _lastReport = now; | |
| 292 | 276 | } |
| 293 | 277 | |
| 294 | 278 | if (lastHeartbeatAge > MAX_HEARTBEAT_AGE_USECS) { |
| @@ -310,9 +294,7 @@ public: · 15 unmodified lines | ||
| 310 | 294 | } |
| 311 | 295 | } |
| 312 | 296 | |
| 313 | − static std::atomic<bool> _suppressStatus; | |
| 314 | 297 | static std::atomic<uint64_t> _heartbeat; |
| 315 | − static std::atomic<uint64_t> _lastReport; | |
| 316 | 298 | static std::atomic<uint64_t> _maxElapsed; |
| 317 | 299 | static std::atomic<int> _maxElapsedAverage; |
| 318 | 300 | static ThreadSafeMovingAverage<int, HEARTBEAT_SAMPLES> _movingAverage; |
| @@ -320,17 +302,11 @@ public: · 1 unmodified line | ||
| 320 | 302 | bool _quit { false }; |
| 321 | 303 | }; |
| 322 | 304 | |
| 323 | −std::atomic<bool> DeadlockWatchdogThread::_suppressStatus; | |
| 324 | 305 | std::atomic<uint64_t> DeadlockWatchdogThread::_heartbeat; |
| 325 | −std::atomic<uint64_t> DeadlockWatchdogThread::_lastReport; | |
| 326 | 306 | std::atomic<uint64_t> DeadlockWatchdogThread::_maxElapsed; |
| 327 | 307 | std::atomic<int> DeadlockWatchdogThread::_maxElapsedAverage; |
| 328 | 308 | ThreadSafeMovingAverage<int, DeadlockWatchdogThread::HEARTBEAT_SAMPLES> DeadlockWatchdogThread::_movingAverage; |
| 329 | 309 | |
| 330 | −void Application::toggleSuppressDeadlockWatchdogStatus(bool checked) { | |
| 331 | − DeadlockWatchdogThread::setSuppressStatus(checked); | |
| 332 | −} | |
| 333 | − | |
| 334 | 310 | #ifdef Q_OS_WIN |
| 335 | 311 | class MyNativeEventFilter : public QAbstractNativeEventFilter { |
| 336 | 312 | public: |
| @@ -3014,8 +2990,19 @@ void Application::init() { · 2677 unmodified lines | ||
| 3014 | 2990 | _entityClipboardRenderer.setTree(_entityClipboard); |
| 3015 | 2991 | |
| 3016 | 2992 | // Make sure any new sounds are loaded as soon as know about them. |
| 3017 | − connect(tree.get(), &EntityTree::newCollisionSoundURL, DependencyManager::get<SoundCache>().data(), &SoundCache::getSound); | |
| 3018 | − connect(getMyAvatar(), &MyAvatar::newCollisionSoundURL, DependencyManager::get<SoundCache>().data(), &SoundCache::getSound); | |
| 2993 | + connect(tree.get(), &EntityTree::newCollisionSoundURL, this, [this](QUrl newURL, EntityItemID id) { | |
| 2994 | + EntityTreePointer tree = getEntities()->getTree(); | |
| 2995 | + if (auto entity = tree->findEntityByEntityItemID(id)) { | |
| 2996 | + auto sound = DependencyManager::get<SoundCache>()->getSound(newURL); | |
| 2997 | + entity->setCollisionSound(sound); | |
| 2998 | + } | |
| 2999 | + }, Qt::QueuedConnection); | |
| 3000 | + connect(getMyAvatar(), &MyAvatar::newCollisionSoundURL, this, [this](QUrl newURL) { | |
| 3001 | + if (auto avatar = getMyAvatar()) { | |
| 3002 | + auto sound = DependencyManager::get<SoundCache>()->getSound(newURL); | |
| 3003 | + avatar->setCollisionSound(sound); | |
| 3004 | + } | |
| 3005 | + }, Qt::QueuedConnection); | |
| 3019 | 3006 | } |
| 3020 | 3007 | |
| 3021 | 3008 | void Application::updateLOD() const { |