mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-07-24 11:04:43 +02:00
Merge pull request #9260 from jherico/chrome_tracing
Working on test/trace script interface
This commit is contained in:
commit
b5e964f6ec
7 changed files with 106 additions and 6 deletions
|
@ -5,15 +5,18 @@
|
||||||
// Distributed under the Apache License, Version 2.0.
|
// Distributed under the Apache License, Version 2.0.
|
||||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
//
|
//
|
||||||
|
|
||||||
|
|
||||||
#include "TestScriptingInterface.h"
|
#include "TestScriptingInterface.h"
|
||||||
|
|
||||||
#include <QtCore/QCoreApplication>
|
#include <QtCore/QCoreApplication>
|
||||||
#include <QtCore/QLoggingCategory>
|
#include <QtCore/QLoggingCategory>
|
||||||
|
#include <QtCore/QThread>
|
||||||
|
|
||||||
#include <DependencyManager.h>
|
#include <DependencyManager.h>
|
||||||
#include <Trace.h>
|
#include <Trace.h>
|
||||||
|
#include <StatTracker.h>
|
||||||
|
#include <OffscreenUi.h>
|
||||||
|
|
||||||
|
#include "Application.h"
|
||||||
|
|
||||||
TestScriptingInterface* TestScriptingInterface::getInstance() {
|
TestScriptingInterface* TestScriptingInterface::getInstance() {
|
||||||
static TestScriptingInterface sharedInstance;
|
static TestScriptingInterface sharedInstance;
|
||||||
|
@ -25,12 +28,47 @@ void TestScriptingInterface::quit() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void TestScriptingInterface::waitForTextureIdle() {
|
void TestScriptingInterface::waitForTextureIdle() {
|
||||||
|
waitForCondition(0, []()->bool {
|
||||||
|
return (0 == gpu::Context::getTextureGPUTransferCount());
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void TestScriptingInterface::waitForDownloadIdle() {
|
void TestScriptingInterface::waitForDownloadIdle() {
|
||||||
|
waitForCondition(0, []()->bool {
|
||||||
|
return (0 == ResourceCache::getLoadingRequestCount()) && (0 == ResourceCache::getPendingRequestCount());
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
void TestScriptingInterface::waitForProcessingIdle() {
|
||||||
|
auto statTracker = DependencyManager::get<StatTracker>();
|
||||||
|
waitForCondition(0, [statTracker]()->bool {
|
||||||
|
return (0 == statTracker->getStat("Processing").toInt() && 0 == statTracker->getStat("PendingProcessing").toInt());
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void TestScriptingInterface::waitIdle() {
|
void TestScriptingInterface::waitIdle() {
|
||||||
|
// Initial wait for some incoming work
|
||||||
|
QThread::sleep(1);
|
||||||
|
waitForDownloadIdle();
|
||||||
|
waitForProcessingIdle();
|
||||||
|
waitForTextureIdle();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool TestScriptingInterface::loadTestScene(QString scene) {
|
||||||
|
static const QString TEST_ROOT = "https://raw.githubusercontent.com/highfidelity/hifi_tests/master/";
|
||||||
|
static const QString TEST_BINARY_ROOT = "https://hifi-public.s3.amazonaws.com/test_scene_data/";
|
||||||
|
static const QString TEST_SCRIPTS_ROOT = TEST_ROOT + "scripts/";
|
||||||
|
static const QString TEST_SCENES_ROOT = TEST_ROOT + "scenes/";
|
||||||
|
return DependencyManager::get<OffscreenUi>()->returnFromUiThread([scene]()->QVariant {
|
||||||
|
ResourceManager::setUrlPrefixOverride("atp:/", TEST_BINARY_ROOT + scene + ".atp/");
|
||||||
|
auto tree = qApp->getEntities()->getTree();
|
||||||
|
auto treeIsClient = tree->getIsClient();
|
||||||
|
// Force the tree to accept the load regardless of permissions
|
||||||
|
tree->setIsClient(false);
|
||||||
|
auto result = tree->readFromURL(TEST_SCENES_ROOT + scene + ".json");
|
||||||
|
tree->setIsClient(treeIsClient);
|
||||||
|
return result;
|
||||||
|
}).toBool();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TestScriptingInterface::startTracing(QString logrules) {
|
bool TestScriptingInterface::startTracing(QString logrules) {
|
||||||
|
@ -55,4 +93,35 @@ bool TestScriptingInterface::stopTracing(QString filename) {
|
||||||
tracer->stopTracing();
|
tracer->stopTracing();
|
||||||
tracer->serialize(filename);
|
tracer->serialize(filename);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TestScriptingInterface::clear() {
|
||||||
|
qApp->postLambdaEvent([] {
|
||||||
|
qApp->getEntities()->clear();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
bool TestScriptingInterface::waitForConnection(qint64 maxWaitMs) {
|
||||||
|
// Wait for any previous connection to die
|
||||||
|
QThread::sleep(1);
|
||||||
|
return waitForCondition(maxWaitMs, []()->bool {
|
||||||
|
return DependencyManager::get<NodeList>()->getDomainHandler().isConnected();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
void TestScriptingInterface::wait(int milliseconds) {
|
||||||
|
QThread::msleep(milliseconds);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool TestScriptingInterface::waitForCondition(qint64 maxWaitMs, std::function<bool()> condition) {
|
||||||
|
QElapsedTimer elapsed;
|
||||||
|
elapsed.start();
|
||||||
|
while (!condition()) {
|
||||||
|
if (maxWaitMs > 0 && elapsed.elapsed() > maxWaitMs) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
QThread::msleep(1);
|
||||||
|
}
|
||||||
|
return condition();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
#ifndef hifi_TestScriptingInterface_h
|
#ifndef hifi_TestScriptingInterface_h
|
||||||
#define hifi_TestScriptingInterface_h
|
#define hifi_TestScriptingInterface_h
|
||||||
|
|
||||||
|
#include <functional>
|
||||||
#include <QtCore/QObject>
|
#include <QtCore/QObject>
|
||||||
|
|
||||||
class TestScriptingInterface : public QObject {
|
class TestScriptingInterface : public QObject {
|
||||||
|
@ -34,10 +35,24 @@ public slots:
|
||||||
void waitForDownloadIdle();
|
void waitForDownloadIdle();
|
||||||
|
|
||||||
/**jsdoc
|
/**jsdoc
|
||||||
* Waits for all pending downloads and texture transfers to be complete
|
* Waits for all file parsing operations to be complete
|
||||||
|
*/
|
||||||
|
void waitForProcessingIdle();
|
||||||
|
|
||||||
|
/**jsdoc
|
||||||
|
* Waits for all pending downloads, parsing and texture transfers to be complete
|
||||||
*/
|
*/
|
||||||
void waitIdle();
|
void waitIdle();
|
||||||
|
|
||||||
|
|
||||||
|
bool waitForConnection(qint64 maxWaitMs = 10000);
|
||||||
|
|
||||||
|
void wait(int milliseconds);
|
||||||
|
|
||||||
|
bool loadTestScene(QString sceneFile);
|
||||||
|
|
||||||
|
void clear();
|
||||||
|
|
||||||
/**jsdoc
|
/**jsdoc
|
||||||
* Start recording Chrome compatible tracing events
|
* Start recording Chrome compatible tracing events
|
||||||
* logRules can be used to specify a set of logging category rules to limit what gets captured
|
* logRules can be used to specify a set of logging category rules to limit what gets captured
|
||||||
|
@ -49,6 +64,9 @@ public slots:
|
||||||
* Using a filename with a .gz extension will automatically compress the output file
|
* Using a filename with a .gz extension will automatically compress the output file
|
||||||
*/
|
*/
|
||||||
bool stopTracing(QString filename);
|
bool stopTracing(QString filename);
|
||||||
|
|
||||||
|
private:
|
||||||
|
bool waitForCondition(qint64 maxWaitMs, std::function<bool()> condition);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // hifi_TestScriptingInterface_h
|
#endif // hifi_TestScriptingInterface_h
|
||||||
|
|
|
@ -71,6 +71,11 @@ QList<QSharedPointer<Resource>> ResourceCacheSharedItems::getLoadingRequests() {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint32_t ResourceCacheSharedItems::getLoadingRequestsCount() const {
|
||||||
|
Lock lock(_mutex);
|
||||||
|
return _loadingRequests.size();
|
||||||
|
}
|
||||||
|
|
||||||
void ResourceCacheSharedItems::removeRequest(QWeakPointer<Resource> resource) {
|
void ResourceCacheSharedItems::removeRequest(QWeakPointer<Resource> resource) {
|
||||||
Lock lock(_mutex);
|
Lock lock(_mutex);
|
||||||
|
|
||||||
|
@ -463,6 +468,10 @@ int ResourceCache::getPendingRequestCount() {
|
||||||
return DependencyManager::get<ResourceCacheSharedItems>()->getPendingRequestsCount();
|
return DependencyManager::get<ResourceCacheSharedItems>()->getPendingRequestsCount();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int ResourceCache::getLoadingRequestCount() {
|
||||||
|
return DependencyManager::get<ResourceCacheSharedItems>()->getLoadingRequestsCount();
|
||||||
|
}
|
||||||
|
|
||||||
bool ResourceCache::attemptRequest(QSharedPointer<Resource> resource) {
|
bool ResourceCache::attemptRequest(QSharedPointer<Resource> resource) {
|
||||||
Q_ASSERT(!resource.isNull());
|
Q_ASSERT(!resource.isNull());
|
||||||
auto sharedItems = DependencyManager::get<ResourceCacheSharedItems>();
|
auto sharedItems = DependencyManager::get<ResourceCacheSharedItems>();
|
||||||
|
|
|
@ -73,6 +73,7 @@ public:
|
||||||
uint32_t getPendingRequestsCount() const;
|
uint32_t getPendingRequestsCount() const;
|
||||||
QList<QSharedPointer<Resource>> getLoadingRequests();
|
QList<QSharedPointer<Resource>> getLoadingRequests();
|
||||||
QSharedPointer<Resource> getHighestPendingRequest();
|
QSharedPointer<Resource> getHighestPendingRequest();
|
||||||
|
uint32_t getLoadingRequestsCount() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
ResourceCacheSharedItems() = default;
|
ResourceCacheSharedItems() = default;
|
||||||
|
@ -241,6 +242,8 @@ public:
|
||||||
|
|
||||||
static int getPendingRequestCount();
|
static int getPendingRequestCount();
|
||||||
|
|
||||||
|
static int getLoadingRequestCount();
|
||||||
|
|
||||||
ResourceCache(QObject* parent = nullptr);
|
ResourceCache(QObject* parent = nullptr);
|
||||||
virtual ~ResourceCache();
|
virtual ~ResourceCache();
|
||||||
|
|
||||||
|
|
|
@ -137,5 +137,4 @@ void OculusBaseDisplayPlugin::updatePresentPose() {
|
||||||
}
|
}
|
||||||
|
|
||||||
OculusBaseDisplayPlugin::~OculusBaseDisplayPlugin() {
|
OculusBaseDisplayPlugin::~OculusBaseDisplayPlugin() {
|
||||||
qDebug() << "Destroying OculusBaseDisplayPlugin";
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -183,5 +183,4 @@ QString OculusDisplayPlugin::getPreferredAudioOutDevice() const {
|
||||||
}
|
}
|
||||||
|
|
||||||
OculusDisplayPlugin::~OculusDisplayPlugin() {
|
OculusDisplayPlugin::~OculusDisplayPlugin() {
|
||||||
qDebug() << "Destroying OculusDisplayPlugin";
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,6 +38,7 @@
|
||||||
#include <shared/NetworkUtils.h>
|
#include <shared/NetworkUtils.h>
|
||||||
#include <shared/FileLogger.h>
|
#include <shared/FileLogger.h>
|
||||||
#include <shared/FileUtils.h>
|
#include <shared/FileUtils.h>
|
||||||
|
#include <StatTracker.h>
|
||||||
#include <LogHandler.h>
|
#include <LogHandler.h>
|
||||||
#include <AssetClient.h>
|
#include <AssetClient.h>
|
||||||
|
|
||||||
|
@ -475,6 +476,8 @@ public:
|
||||||
DependencyManager::registerInheritance<EntityActionFactoryInterface, TestActionFactory>();
|
DependencyManager::registerInheritance<EntityActionFactoryInterface, TestActionFactory>();
|
||||||
DependencyManager::registerInheritance<LimitedNodeList, NodeList>();
|
DependencyManager::registerInheritance<LimitedNodeList, NodeList>();
|
||||||
DependencyManager::registerInheritance<SpatialParentFinder, ParentFinder>();
|
DependencyManager::registerInheritance<SpatialParentFinder, ParentFinder>();
|
||||||
|
DependencyManager::set<tracing::Tracer>();
|
||||||
|
DependencyManager::set<StatTracker>();
|
||||||
DependencyManager::set<AddressManager>();
|
DependencyManager::set<AddressManager>();
|
||||||
DependencyManager::set<NodeList>(NodeType::Agent);
|
DependencyManager::set<NodeList>(NodeType::Agent);
|
||||||
DependencyManager::set<DeferredLightingEffect>();
|
DependencyManager::set<DeferredLightingEffect>();
|
||||||
|
|
Loading…
Reference in a new issue