Showing the changes to libraries/script-engine/src/ScriptEngine.cpp (1 of 3 files). Show all
Unified · Split
| @@ -928,22 +928,23 @@ void ScriptEngine::run() { · 927 unmodified lines | ||
| 928 | 928 | auto remainingSleepUntil = std::chrono::duration_cast<std::chrono::microseconds>(sleepUntil - clock::now()); |
| 929 | 929 | auto closestUntil = std::min(remainingSleepUntil, untilTimer); |
| 930 | 930 | auto thisSleepUntil = std::min(sleepUntil, clock::now() + closestUntil); |
| 931 | + auto untilThisSleepUntil = std::chrono::duration_cast<std::chrono::microseconds>(thisSleepUntil - clock::now()); | |
| 931 | 932 | |
| 932 | 933 | // if the sleep until is more than 1 ms away, then don't sleep, and instead use a wait condition |
| 933 | 934 | // for any possible invoke methods that might also be pending. |
| 934 | 935 | 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(); | |
| 937 | 938 | std::this_thread::sleep_until(thisSleepUntil); |
| 938 | 939 | } else { |
| 939 | 940 | // 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(); | |
| 942 | 943 | _waitingOnInvokeMethod.lock(); |
| 943 | 944 | bool signalled = _hasInvokeMethod.wait(&_waitingOnInvokeMethod, maxWait); |
| 944 | 945 | _waitingOnInvokeMethod.unlock(); |
| 945 | 946 | if (signalled) { |
| 946 | − qDebug() << "SIGNALLED!! done waiting... now:" << usecTimestampNow(); | |
| 947 | + qDebug() << "[" << getFilename() << "]" << "SIGNALLED!! done waiting... now:" << usecTimestampNow(); | |
| 947 | 948 | } |
| 948 | 949 | |
| 949 | 950 | } |
| @@ -1664,13 +1665,15 @@ void ScriptEngine::callWithEnvironment(const EntityItemID& entityID, const QUrl& · 714 unmodified lines | ||
| 1664 | 1665 | } |
| 1665 | 1666 | |
| 1666 | 1667 | void ScriptEngine::callEntityScriptMethod(const EntityItemID& entityID, const QString& methodName, const QStringList& params) { |
| 1668 | + qDebug() << "[" << getFilename() << "]" << __FUNCTION__ << "method:" << methodName << "now:" << usecTimestampNow(); | |
| 1669 | + | |
| 1667 | 1670 | if (QThread::currentThread() != thread()) { |
| 1668 | 1671 | #ifdef THREAD_DEBUGGING |
| 1669 | 1672 | qCDebug(scriptengine) << "*** WARNING *** ScriptEngine::callEntityScriptMethod() called on wrong thread [" << QThread::currentThread() << "], invoking on correct thread [" << thread() << "] " |
| 1670 | 1673 | "entityID:" << entityID << "methodName:" << methodName; |
| 1671 | 1674 | #endif |
| 1672 | 1675 | |
| 1673 | − qDebug() << "about to invokeMethod callEntityScriptMethod() now:" << usecTimestampNow(); | |
| 1676 | + qDebug() << "[" << getFilename() << "]" << "about to invokeMethod callEntityScriptMethod() now:" << usecTimestampNow(); | |
| 1674 | 1677 | |
| 1675 | 1678 | QMetaObject::invokeMethod(this, "callEntityScriptMethod", |
| 1676 | 1679 | Q_ARG(const EntityItemID&, entityID), |
| @@ -1692,6 +1695,8 @@ void ScriptEngine::callEntityScriptMethod(const EntityItemID& entityID, const QS · 15 unmodified lines | ||
| 1692 | 1695 | QScriptValueList args; |
| 1693 | 1696 | args << entityID.toScriptValue(this); |
| 1694 | 1697 | args << qScriptValueFromSequence(this, params); |
| 1698 | + | |
| 1699 | + qDebug() << "[" << getFilename() << "]" << __FUNCTION__ << "about to callWithEnvironment()... method:" << methodName << "now:" << usecTimestampNow(); | |
| 1695 | 1700 | callWithEnvironment(entityID, details.definingSandboxURL, entityScript.property(methodName), entityScript, args); |
| 1696 | 1701 | } |
| 1697 | 1702 | |