History

debugging

Brad Hefta-Gaub committed 9 years ago

Commit 82ab8631 parent 74384a63 files · +24 −8Browse files

Showing the changes to libraries/script-engine/src/ScriptEngine.cpp (1 of 3 files). Show all

Unified · Split

libraries/script-engine/src/ScriptEngine.cpp+11−6
@@ -928,22 +928,23 @@ void ScriptEngine::run() { · 927 unmodified lines
928928 auto remainingSleepUntil = std::chrono::duration_cast<std::chrono::microseconds>(sleepUntil - clock::now());
929929 auto closestUntil = std::min(remainingSleepUntil, untilTimer);
930930 auto thisSleepUntil = std::min(sleepUntil, clock::now() + closestUntil);
931+ auto untilThisSleepUntil = std::chrono::duration_cast<std::chrono::microseconds>(thisSleepUntil - clock::now());
931932
932933 // if the sleep until is more than 1 ms away, then don't sleep, and instead use a wait condition
933934 // for any possible invoke methods that might also be pending.
934935 const std::chrono::microseconds MAX_USECS_TO_SLEEP(USECS_PER_MSEC);
935− if (closestUntil < MAX_USECS_TO_SLEEP) {
936− qDebug() << "about to sleep:" << closestUntil.count() << "usec";
936+ if (untilThisSleepUntil < MAX_USECS_TO_SLEEP) {
937+ qDebug() << "[" << getFilename() << "]" << "about to sleep untilThisSleepUntil:" << untilThisSleepUntil.count() << "usec -- averageTimerPerFrame:" << averageTimerPerFrame.count();
937938 std::this_thread::sleep_until(thisSleepUntil);
938939 } else {
939940 // FIXME - we might want to make this 1 less ms to wait
940− unsigned long maxWait = closestUntil.count() / USECS_PER_MSEC;
941− qDebug() << "about to wait:" << maxWait << "ms --- closestUntil:" << closestUntil.count() << "usec";
941+ unsigned long maxWait = untilThisSleepUntil.count() / USECS_PER_MSEC;
942+ qDebug() << "[" << getFilename() << "]" << "about to wait:" << maxWait << "ms --- untilThisSleepUntil:" << untilThisSleepUntil.count() << "usec -- averageTimerPerFrame:" << averageTimerPerFrame.count();
942943 _waitingOnInvokeMethod.lock();
943944 bool signalled = _hasInvokeMethod.wait(&_waitingOnInvokeMethod, maxWait);
944945 _waitingOnInvokeMethod.unlock();
945946 if (signalled) {
946− qDebug() << "SIGNALLED!! done waiting... now:" << usecTimestampNow();
947+ qDebug() << "[" << getFilename() << "]" << "SIGNALLED!! done waiting... now:" << usecTimestampNow();
947948 }
948949
949950 }
@@ -1664,13 +1665,15 @@ void ScriptEngine::callWithEnvironment(const EntityItemID& entityID, const QUrl& · 714 unmodified lines
16641665 }
16651666
16661667 void ScriptEngine::callEntityScriptMethod(const EntityItemID& entityID, const QString& methodName, const QStringList& params) {
1668+ qDebug() << "[" << getFilename() << "]" << __FUNCTION__ << "method:" << methodName << "now:" << usecTimestampNow();
1669+
16671670 if (QThread::currentThread() != thread()) {
16681671 #ifdef THREAD_DEBUGGING
16691672 qCDebug(scriptengine) << "*** WARNING *** ScriptEngine::callEntityScriptMethod() called on wrong thread [" << QThread::currentThread() << "], invoking on correct thread [" << thread() << "] "
16701673 "entityID:" << entityID << "methodName:" << methodName;
16711674 #endif
16721675
1673− qDebug() << "about to invokeMethod callEntityScriptMethod() now:" << usecTimestampNow();
1676+ qDebug() << "[" << getFilename() << "]" << "about to invokeMethod callEntityScriptMethod() now:" << usecTimestampNow();
16741677
16751678 QMetaObject::invokeMethod(this, "callEntityScriptMethod",
16761679 Q_ARG(const EntityItemID&, entityID),
@@ -1692,6 +1695,8 @@ void ScriptEngine::callEntityScriptMethod(const EntityItemID& entityID, const QS · 15 unmodified lines
16921695 QScriptValueList args;
16931696 args << entityID.toScriptValue(this);
16941697 args << qScriptValueFromSequence(this, params);
1698+
1699+ qDebug() << "[" << getFilename() << "]" << __FUNCTION__ << "about to callWithEnvironment()... method:" << methodName << "now:" << usecTimestampNow();
16951700 callWithEnvironment(entityID, details.definingSandboxURL, entityScript.property(methodName), entityScript, args);
16961701 }
16971702