History

merge from upstream

Seth Alves committed 10 years ago

Commit b761ecf2 parents a0771f8 20b7e5f55 files · +1110 −356Browse files

Showing the changes to interface/src/Application.cpp (1 of 55 files). Show all

Unified · Split

interface/src/Application.cpp+14−27
@@ -210,9 +210,7 @@ const QHash<QString, Application::AcceptURLMethod> Application::_acceptedExtensi · 209 unmodified lines
210 210
211class DeadlockWatchdogThread : public QThread {211class DeadlockWatchdogThread : public QThread {
212public:212public:
213 static const unsigned long HEARTBEAT_CHECK_INTERVAL_SECS = 1;
214 static const unsigned long HEARTBEAT_UPDATE_INTERVAL_SECS = 1;213 static const unsigned long HEARTBEAT_UPDATE_INTERVAL_SECS = 1;
215 static const unsigned long HEARTBEAT_REPORT_INTERVAL_USECS = 5 * USECS_PER_SECOND;
216 static const unsigned long MAX_HEARTBEAT_AGE_USECS = 30 * USECS_PER_SECOND;214 static const unsigned long MAX_HEARTBEAT_AGE_USECS = 30 * USECS_PER_SECOND;
217 static const int WARNING_ELAPSED_HEARTBEAT = 500 * USECS_PER_MSEC; // warn if elapsed heartbeat average is large215 static const int WARNING_ELAPSED_HEARTBEAT = 500 * USECS_PER_MSEC; // warn if elapsed heartbeat average is large
218 static const int HEARTBEAT_SAMPLES = 100000; // ~5 seconds worth of samples216 static const int HEARTBEAT_SAMPLES = 100000; // ~5 seconds worth of samples
@@ -239,8 +237,6 @@ public: · 20 unmodified lines
239 *crashTrigger = 0xDEAD10CC;237 *crashTrigger = 0xDEAD10CC;
240 }238 }
241 239
242 static void setSuppressStatus(bool suppress) { _suppressStatus = suppress; }
243
244 void run() override {240 void run() override {
245 while (!_quit) {241 while (!_quit) {
246 QThread::sleep(HEARTBEAT_UPDATE_INTERVAL_SECS);242 QThread::sleep(HEARTBEAT_UPDATE_INTERVAL_SECS);
@@ -248,7 +244,6 @@ public: · 1 unmodified line
248 uint64_t lastHeartbeat = _heartbeat; // sample atomic _heartbeat, because we could context switch away and have it updated on us244 uint64_t lastHeartbeat = _heartbeat; // sample atomic _heartbeat, because we could context switch away and have it updated on us
249 uint64_t now = usecTimestampNow();245 uint64_t now = usecTimestampNow();
250 auto lastHeartbeatAge = (now > lastHeartbeat) ? now - lastHeartbeat : 0;246 auto lastHeartbeatAge = (now > lastHeartbeat) ? now - lastHeartbeat : 0;
251 auto sinceLastReport = (now > _lastReport) ? now - _lastReport : 0;
252 auto elapsedMovingAverage = _movingAverage.getAverage();247 auto elapsedMovingAverage = _movingAverage.getAverage();
253 248
254 if (elapsedMovingAverage > _maxElapsedAverage) {249 if (elapsedMovingAverage > _maxElapsedAverage) {
@@ -274,21 +269,10 @@ public: · 19 unmodified lines
274 if (elapsedMovingAverage > WARNING_ELAPSED_HEARTBEAT) {269 if (elapsedMovingAverage > WARNING_ELAPSED_HEARTBEAT) {
275 qDebug() << "DEADLOCK WATCHDOG WARNING:"270 qDebug() << "DEADLOCK WATCHDOG WARNING:"
276 << "lastHeartbeatAge:" << lastHeartbeatAge271 << "lastHeartbeatAge:" << lastHeartbeatAge
277 << "elapsedMovingAverage:" << elapsedMovingAverage << "** OVER EXPECTED VALUE**"272 << "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
288 << "maxElapsed:" << _maxElapsed273 << "maxElapsed:" << _maxElapsed
289 << "maxElapsedAverage:" << _maxElapsedAverage274 << "maxElapsedAverage:" << _maxElapsedAverage
290 << "samples:" << _movingAverage.getSamples();275 << "samples:" << _movingAverage.getSamples();
291 _lastReport = now;
292 }276 }
293 277
294 if (lastHeartbeatAge > MAX_HEARTBEAT_AGE_USECS) {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 static std::atomic<uint64_t> _heartbeat;297 static std::atomic<uint64_t> _heartbeat;
315 static std::atomic<uint64_t> _lastReport;
316 static std::atomic<uint64_t> _maxElapsed;298 static std::atomic<uint64_t> _maxElapsed;
317 static std::atomic<int> _maxElapsedAverage;299 static std::atomic<int> _maxElapsedAverage;
318 static ThreadSafeMovingAverage<int, HEARTBEAT_SAMPLES> _movingAverage;300 static ThreadSafeMovingAverage<int, HEARTBEAT_SAMPLES> _movingAverage;
@@ -320,17 +302,11 @@ public: · 1 unmodified line
320 bool _quit { false };302 bool _quit { false };
321};303};
322 304
323std::atomic<bool> DeadlockWatchdogThread::_suppressStatus;
324std::atomic<uint64_t> DeadlockWatchdogThread::_heartbeat;305std::atomic<uint64_t> DeadlockWatchdogThread::_heartbeat;
325std::atomic<uint64_t> DeadlockWatchdogThread::_lastReport;
326std::atomic<uint64_t> DeadlockWatchdogThread::_maxElapsed;306std::atomic<uint64_t> DeadlockWatchdogThread::_maxElapsed;
327std::atomic<int> DeadlockWatchdogThread::_maxElapsedAverage;307std::atomic<int> DeadlockWatchdogThread::_maxElapsedAverage;
328ThreadSafeMovingAverage<int, DeadlockWatchdogThread::HEARTBEAT_SAMPLES> DeadlockWatchdogThread::_movingAverage;308ThreadSafeMovingAverage<int, DeadlockWatchdogThread::HEARTBEAT_SAMPLES> DeadlockWatchdogThread::_movingAverage;
329 309
330void Application::toggleSuppressDeadlockWatchdogStatus(bool checked) {
331 DeadlockWatchdogThread::setSuppressStatus(checked);
332}
333
334#ifdef Q_OS_WIN310#ifdef Q_OS_WIN
335class MyNativeEventFilter : public QAbstractNativeEventFilter {311class MyNativeEventFilter : public QAbstractNativeEventFilter {
336public:312public:
@@ -3014,8 +2990,19 @@ void Application::init() { · 2677 unmodified lines
3014 _entityClipboardRenderer.setTree(_entityClipboard);2990 _entityClipboardRenderer.setTree(_entityClipboard);
3015 2991
3016 // Make sure any new sounds are loaded as soon as know about them.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);2993 connect(tree.get(), &EntityTree::newCollisionSoundURL, this, [this](QUrl newURL, EntityItemID id) {
3018 connect(getMyAvatar(), &MyAvatar::newCollisionSoundURL, DependencyManager::get<SoundCache>().data(), &SoundCache::getSound);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
3021void Application::updateLOD() const {3008void Application::updateLOD() const {