From 73616b81f39bd49362f0e55b893203f544c1369f Mon Sep 17 00:00:00 2001 From: Matt Hardcastle Date: Thu, 20 Jun 2019 15:36:28 -0700 Subject: [PATCH 01/11] Fail on empty LAUNCHER_HMAC_SECRET Priot to this change there was code that attempted to verify that LAUNCHER_HMAC_SECRET was set to something. This code was broke though and didn't catch the case correctly. This change fixes the check. --- launchers/darwin/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/launchers/darwin/CMakeLists.txt b/launchers/darwin/CMakeLists.txt index 4da675fcc9..9592ef69f3 100644 --- a/launchers/darwin/CMakeLists.txt +++ b/launchers/darwin/CMakeLists.txt @@ -67,7 +67,7 @@ add_executable(${PROJECT_NAME} MACOSX_BUNDLE ${src_files}) set_target_properties(${PROJECT_NAME} PROPERTIES OUTPUT_NAME ${APP_NAME} MACOSX_BUNDLE_BUNDLE_NAME ${APP_NAME}) set_from_env(LAUNCHER_HMAC_SECRET LAUNCHER_HMAC_SECRET "") -if (LAUNCHER_HMAC_SECRET STREQUAL "") +if ("${LAUNCHER_HMAC_SECRET}" STREQUAL "") message(FATAL_ERROR "LAUNCHER_HMAC_SECRET is not set") endif() From 3a5aa4194e7fe5a745a1ff17a1f6cb3ebed497db Mon Sep 17 00:00:00 2001 From: Matt Hardcastle Date: Sat, 22 Jun 2019 11:23:17 -0700 Subject: [PATCH 02/11] Pin the macOS HQ Launcher target version to 10.9 This change pins HQ Launcher's target SDK to 10.9, which is the same as the target SDK for Interface. Without this pinned value the target version defaults to whatever the OS version is on the machine that happened to build HQ Launcher. --- launchers/darwin/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/launchers/darwin/CMakeLists.txt b/launchers/darwin/CMakeLists.txt index 9592ef69f3..76d209d89d 100644 --- a/launchers/darwin/CMakeLists.txt +++ b/launchers/darwin/CMakeLists.txt @@ -1,4 +1,5 @@ cmake_minimum_required(VERSION 3.0) +set(ENV{MACOSX_DEPLOYMENT_TARGET} 10.9) project(HQLauncher) set (CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules/") set(src_files From 4d28c5fe412ae1f3df98ccf1edf1f6660211b0a5 Mon Sep 17 00:00:00 2001 From: Matt Hardcastle Date: Sat, 22 Jun 2019 11:32:36 -0700 Subject: [PATCH 03/11] Use version from Interface in macOS HQ Launcher Prior to this change the macOS HQ Launcher used the version from the settings files. Pull this information in the settings file could result in a situation where the setting file was updated, but interface wasn't. When the launcher ran a second time it would check the settings file and think Interface was updated even though it wasn't. This change resolves the issue by asking interface for its version directly. In the event that Interface doesn't response with a version number HQ Launcher knows how to interoperate HQ Launcher will fall back to using the settings file. Known Issues --- 1) Interface reports different version number formats depending on how its built. A stable interface for getting the build version from interface should be added. --- launchers/darwin/CMakeLists.txt | 2 + launchers/darwin/src/Interface.h | 8 ++ launchers/darwin/src/Interface.m | 100 ++++++++++++++++++++++ launchers/darwin/src/LatestBuildRequest.m | 25 ++++-- 4 files changed, 128 insertions(+), 7 deletions(-) create mode 100644 launchers/darwin/src/Interface.h create mode 100644 launchers/darwin/src/Interface.m diff --git a/launchers/darwin/CMakeLists.txt b/launchers/darwin/CMakeLists.txt index 76d209d89d..a3fc0dc7c1 100644 --- a/launchers/darwin/CMakeLists.txt +++ b/launchers/darwin/CMakeLists.txt @@ -27,6 +27,8 @@ set(src_files src/LatestBuildRequest.m src/OrganizationRequest.m src/OrganizationRequest.h + src/Interface.h + src/Interface.m src/ErrorViewController.h src/ErrorViewController.m src/Settings.h diff --git a/launchers/darwin/src/Interface.h b/launchers/darwin/src/Interface.h new file mode 100644 index 0000000000..c142aeecf5 --- /dev/null +++ b/launchers/darwin/src/Interface.h @@ -0,0 +1,8 @@ +#import + +@interface Interface : NSObject + +-(id _Nonnull) initWith:(NSString * _Nonnull) aPathToInterface; +-(NSInteger) getVersion:(out NSError * _Nullable * _Nonnull) anError; + +@end diff --git a/launchers/darwin/src/Interface.m b/launchers/darwin/src/Interface.m new file mode 100644 index 0000000000..b007e7faa5 --- /dev/null +++ b/launchers/darwin/src/Interface.m @@ -0,0 +1,100 @@ +#import "Interface.h" + +@implementation Interface +{ + NSString *pathTo; +} + +-(id) initWith:(NSString*)aPathToInterface +{ + [self init]; + self->pathTo = [NSString stringWithFormat:@"%@/Contents/MacOS/interface", aPathToInterface]; + return self; +} + +-(NSInteger) getVersion:(out NSError * _Nullable *) outError +{ + NSTask * interface = [[NSTask alloc] init]; + NSPipe * standardOut = [NSPipe pipe]; + + interface.launchPath = self->pathTo; + interface.arguments = @[ @"--version" ]; + interface.standardOutput = standardOut; + + NSLog(@"calling interface at %@", self->pathTo); + + if (@available(macOS 10.13, *)) { + NSError *error = nil; + if (![interface launchAndReturnError:&error]) { + *outError = [NSError errorWithDomain:@"interface" + code:-1 + userInfo:@{NSUnderlyingErrorKey: error}]; + return 0; + } + } else { + NSError *error = nil; + [interface launch]; + [interface waitUntilExit]; + if (0 != [interface terminationStatus]) { + *outError = [NSError errorWithDomain:@"interface" + code:-1 + userInfo:@{NSUnderlyingErrorKey: error}]; + return 0; + } + } + + NSFileHandle * fh = [standardOut fileHandleForReading]; + NSData * data = [fh readDataToEndOfFile]; + NSString * output = [NSString stringWithUTF8String:[data bytes]]; + if (output == nil) { + NSDictionary * userInfo = @{ + NSLocalizedDescriptionKey: NSLocalizedString(@"Couldn't start interface", nil) + }; + *outError = [NSError errorWithDomain:@"interface" + code:-1 + userInfo:userInfo]; + return 0; + } + + // Interface returns the build version as a string like this: + // "Interface 33333-DEADBEEF". This code grabs the substring + // between "Interface " and the hyphon ("-") + NSRange start = [output rangeOfString:@"Interface "]; + if (start.length == 0) { + NSDictionary * userInfo = @{ + NSLocalizedDescriptionKey: NSLocalizedString(@"Couldn't read interface's version", nil) + }; + *outError = [NSError errorWithDomain:@"interface" + code:-2 + userInfo:userInfo]; + return 0; + } + NSRange end = [output rangeOfString:@"-"]; + if (end.length == 0) { + NSDictionary * userInfo = @{ + NSLocalizedDescriptionKey: NSLocalizedString(@"Couldn't read interface's version", nil) + }; + *outError = [NSError errorWithDomain:@"interface" + code:-2 + userInfo:userInfo]; + return 0; + } + NSRange subRange = {start.length, end.location - start.length}; + NSString * versionStr; + @try { + versionStr = [output substringWithRange:subRange]; + } + @catch (NSException *) { + NSDictionary * userInfo = @{ + NSLocalizedDescriptionKey: NSLocalizedString(@"Couldn't read interface's version", nil) + }; + *outError = [NSError errorWithDomain:@"interface" + code:-2 + userInfo:userInfo]; + return 0; + } + + return versionStr.integerValue; +} + +@end diff --git a/launchers/darwin/src/LatestBuildRequest.m b/launchers/darwin/src/LatestBuildRequest.m index 5119efa8f6..21f63425ab 100644 --- a/launchers/darwin/src/LatestBuildRequest.m +++ b/launchers/darwin/src/LatestBuildRequest.m @@ -1,9 +1,22 @@ #import "LatestBuildRequest.h" #import "Launcher.h" #import "Settings.h" +#import "Interface.h" @implementation LatestBuildRequest +- (NSInteger) getCurrentVersion { + NSString* interfaceAppPath = [[Launcher.sharedLauncher getAppPath] stringByAppendingString:@"interface.app"]; + NSError * error = nil; + Interface * interface = [[Interface alloc] initWith:interfaceAppPath]; + NSInteger currentVersion = [interface getVersion:&error]; + if (currentVersion == 0 && error != nil) { + NSLog(@"can't get version from interface, falling back to settings: %@", error); + currentVersion = [Settings.sharedSettings latestBuildVersion]; + } + return currentVersion; +} + - (void) requestLatestBuildInfo { NSMutableURLRequest *request = [NSMutableURLRequest new]; [request setURL:[NSURL URLWithString:@"https://thunder.highfidelity.com/builds/api/tags/latest?format=json"]]; @@ -45,8 +58,7 @@ BOOL appDirectoryExist = [fileManager fileExistsAtPath:[[sharedLauncher getAppPath] stringByAppendingString:@"interface.app"]]; dispatch_async(dispatch_get_main_queue(), ^{ - Settings* settings = [Settings sharedSettings]; - NSInteger currentVersion = [settings latestBuildVersion]; + NSInteger currentVersion = [self getCurrentVersion]; NSLog(@"Latest Build Request -> does build directory exist: %@", appDirectoryExist ? @"TRUE" : @"FALSE"); NSLog(@"Latest Build Request -> current version: %ld", currentVersion); NSLog(@"Latest Build Request -> latest version: %ld", buildNumber.integerValue); @@ -105,11 +117,10 @@ NSDictionary* macInstallerObject = [installers objectForKey:@"mac"]; NSString* macInstallerUrl = [macInstallerObject valueForKey:@"zip_url"]; - BOOL appDirectoryExist = [fileManager fileExistsAtPath:[[sharedLauncher getAppPath] stringByAppendingString:@"interface.app"]]; - - Settings* settings = [Settings sharedSettings]; - NSInteger currentVersion = [settings latestBuildVersion]; - BOOL latestVersionAvailable = (currentVersion != buildNumber.integerValue); + NSString* interfaceAppPath = [[sharedLauncher getAppPath] stringByAppendingString:@"interface.app"]; + BOOL appDirectoryExist = [fileManager fileExistsAtPath:interfaceAppPath]; + + BOOL latestVersionAvailable = ([self getCurrentVersion] != buildNumber.integerValue); [[Settings sharedSettings] buildVersion:buildNumber.integerValue]; BOOL shouldDownloadInterface = (latestVersionAvailable || !appDirectoryExist); From 4f6e2c85f9c14ae89b303b1b0ee0800f4845e77c Mon Sep 17 00:00:00 2001 From: Matt Hardcastle Date: Sat, 22 Jun 2019 12:28:57 -0700 Subject: [PATCH 04/11] Never cache the tags API in macOS's HQ Launcher Prior to this change we used the default session while downloading the latest tags API response from Thunder. This left open the possibility that NSURLSession could cache the response, even though the server asked it not to; NSURLSession can be pretty aggressive about its caching. This change ensure no caching of the API is occurring my using an ephemeral session when calling the tags API. --- launchers/darwin/src/LatestBuildRequest.m | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/launchers/darwin/src/LatestBuildRequest.m b/launchers/darwin/src/LatestBuildRequest.m index 21f63425ab..7e836548af 100644 --- a/launchers/darwin/src/LatestBuildRequest.m +++ b/launchers/darwin/src/LatestBuildRequest.m @@ -23,8 +23,8 @@ [request setHTTPMethod:@"GET"]; [request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"]; - - NSURLSession* session = [NSURLSession sharedSession]; + // We're using an ephermeral session here to ensure the tags api response is never cached. + NSURLSession * session = [NSURLSession sessionWithConfiguration:NSURLSessionConfiguration.ephemeralSessionConfiguration]; NSURLSessionDataTask* dataTask = [session dataTaskWithRequest:request completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) { From e39ccff873465dd98e0e05e2323ab71f8db77234 Mon Sep 17 00:00:00 2001 From: Roxanne Skelly Date: Mon, 24 Jun 2019 11:57:37 -0700 Subject: [PATCH 05/11] BUGZ-812 - Log system info on domain connect or connect refusal --- domain-server/src/DomainGatekeeper.cpp | 3 +- domain-server/src/NodeConnectionData.cpp | 6 +++- libraries/networking/CMakeLists.txt | 2 +- libraries/networking/src/NodeList.cpp | 30 +++++++++++-------- .../networking/src/ThreadedAssignment.cpp | 11 +++++++ libraries/networking/src/ThreadedAssignment.h | 2 +- .../networking/src/udt/PacketHeaders.cpp | 2 +- libraries/networking/src/udt/PacketHeaders.h | 3 +- 8 files changed, 40 insertions(+), 19 deletions(-) diff --git a/domain-server/src/DomainGatekeeper.cpp b/domain-server/src/DomainGatekeeper.cpp index 6d339852d5..6aaa348f6c 100644 --- a/domain-server/src/DomainGatekeeper.cpp +++ b/domain-server/src/DomainGatekeeper.cpp @@ -136,7 +136,8 @@ void DomainGatekeeper::processConnectRequestPacket(QSharedPointergetSenderSockAddr() << "with hardware address" << nodeConnection.hardwareAddress - << "and machine fingerprint" << nodeConnection.machineFingerprint; + << "and machine fingerprint" << nodeConnection.machineFingerprint + << "sysinfo" << nodeConnection.SystemInfo; } } diff --git a/domain-server/src/NodeConnectionData.cpp b/domain-server/src/NodeConnectionData.cpp index 9703db39c8..e3406aa797 100644 --- a/domain-server/src/NodeConnectionData.cpp +++ b/domain-server/src/NodeConnectionData.cpp @@ -37,7 +37,11 @@ NodeConnectionData NodeConnectionData::fromDataStream(QDataStream& dataStream, c dataStream >> newHeader.machineFingerprint; // and the operating system type - dataStream >> newHeader.SystemInfo; + QByteArray compressedSystemInfo; + dataStream >> compressedSystemInfo; + if(!compressedSystemInfo.isEmpty()) { + newHeader.SystemInfo = qUncompress(compressedSystemInfo); + } dataStream >> newHeader.connectReason; diff --git a/libraries/networking/CMakeLists.txt b/libraries/networking/CMakeLists.txt index c3592c5da2..9f63f2cb00 100644 --- a/libraries/networking/CMakeLists.txt +++ b/libraries/networking/CMakeLists.txt @@ -1,6 +1,6 @@ set(TARGET_NAME networking) setup_hifi_library(Network) -link_hifi_libraries(shared) +link_hifi_libraries(shared platform) target_openssl() target_tbb() diff --git a/libraries/networking/src/NodeList.cpp b/libraries/networking/src/NodeList.cpp index 96b713c583..0dad7705f8 100644 --- a/libraries/networking/src/NodeList.cpp +++ b/libraries/networking/src/NodeList.cpp @@ -26,6 +26,8 @@ #include #include #include +#include +#include #include "AccountManager.h" #include "AddressManager.h" @@ -42,6 +44,7 @@ using namespace std::chrono; const int KEEPALIVE_PING_INTERVAL_MS = 1000; +const int MAX_SYSTEM_INFO_SIZE = 1000; NodeList::NodeList(char newOwnerType, int socketListenPort, int dtlsListenPort) : LimitedNodeList(socketListenPort, dtlsListenPort), @@ -418,19 +421,20 @@ void NodeList::sendDomainServerCheckIn() { auto accountManager = DependencyManager::get(); packetStream << FingerprintUtils::getMachineFingerprint(); - QString systemInfo; -#if defined Q_OS_WIN - systemInfo = "OS:Windows"; -#elif defined Q_OS_OSX - systemInfo = "OS:OSX"; -#elif defined Q_OS_LINUX - systemInfo = "OS:Linux"; -#elif defined Q_OS_ANDROID - systemInfo = "OS:Android"; -#else - systemInfo = "OS:Unknown"; -#endif - packetStream << systemInfo; + auto desc = platform::getAll(); + + QByteArray systemInfo(desc.dump().c_str()); + QByteArray compressedSystemInfo = qCompress(systemInfo); + + if(compressedSystemInfo.size() > MAX_SYSTEM_INFO_SIZE) { + // Highly unlikely, as not even unreasonable machines will + // overflow the max size, but prevent MTU overflow anyway. + // We could do something sophisticated like clearing specific + // values if they're too big, but we'll save that for later. + compressedSystemInfo.clear(); + } + + packetStream << compressedSystemInfo; packetStream << _connectReason; diff --git a/libraries/networking/src/ThreadedAssignment.cpp b/libraries/networking/src/ThreadedAssignment.cpp index 2b415073f2..b8a8f65080 100644 --- a/libraries/networking/src/ThreadedAssignment.cpp +++ b/libraries/networking/src/ThreadedAssignment.cpp @@ -20,6 +20,7 @@ #include #include +#include #include "NetworkLogging.h" ThreadedAssignment::ThreadedAssignment(ReceivedMessage& message) : @@ -38,6 +39,16 @@ ThreadedAssignment::ThreadedAssignment(ReceivedMessage& message) : // if the NL tells us we got a DS response, clear our member variable of queued check-ins auto nodeList = DependencyManager::get(); connect(nodeList.data(), &NodeList::receivedDomainServerList, this, &ThreadedAssignment::clearQueuedCheckIns); + + platform::create(); + if (!platform::enumeratePlatform()) { + qCDebug(networking) << "Failed to enumerate platform."; + } +} + +ThreadedAssignment::~ThreadedAssignment() { + stop(); + platform::destroy(); } void ThreadedAssignment::setFinished(bool isFinished) { diff --git a/libraries/networking/src/ThreadedAssignment.h b/libraries/networking/src/ThreadedAssignment.h index e76533b2a1..12096cf23f 100644 --- a/libraries/networking/src/ThreadedAssignment.h +++ b/libraries/networking/src/ThreadedAssignment.h @@ -22,7 +22,7 @@ class ThreadedAssignment : public Assignment { Q_OBJECT public: ThreadedAssignment(ReceivedMessage& message); - ~ThreadedAssignment() { stop(); } + ~ThreadedAssignment(); virtual void aboutToFinish() { }; void addPacketStatsAndSendStatsPacket(QJsonObject statsObject); diff --git a/libraries/networking/src/udt/PacketHeaders.cpp b/libraries/networking/src/udt/PacketHeaders.cpp index e434867c9a..ed68fe89dc 100644 --- a/libraries/networking/src/udt/PacketHeaders.cpp +++ b/libraries/networking/src/udt/PacketHeaders.cpp @@ -72,7 +72,7 @@ PacketVersion versionForPacketType(PacketType packetType) { return static_cast(DomainConnectionDeniedVersion::IncludesExtraInfo); case PacketType::DomainConnectRequest: - return static_cast(DomainConnectRequestVersion::HasSystemInfo); + return static_cast(DomainConnectRequestVersion::HasCompressedSystemInfo); case PacketType::DomainServerAddedNode: return static_cast(DomainServerAddedNodeVersion::PermissionsGrid); diff --git a/libraries/networking/src/udt/PacketHeaders.h b/libraries/networking/src/udt/PacketHeaders.h index a244399c5a..6230b8b11e 100644 --- a/libraries/networking/src/udt/PacketHeaders.h +++ b/libraries/networking/src/udt/PacketHeaders.h @@ -347,7 +347,8 @@ enum class DomainConnectRequestVersion : PacketVersion { AlwaysHasMachineFingerprint, HasTimestamp, HasReason, - HasSystemInfo + HasSystemInfo, + HasCompressedSystemInfo }; enum class DomainConnectionDeniedVersion : PacketVersion { From 3c0c1413db22c19dc6bb77b733d69df46ca76f74 Mon Sep 17 00:00:00 2001 From: Roxanne Skelly Date: Mon, 24 Jun 2019 14:12:25 -0700 Subject: [PATCH 06/11] fix apple build --- libraries/platform/CMakeLists.txt | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/libraries/platform/CMakeLists.txt b/libraries/platform/CMakeLists.txt index 70f3157e1e..55203d45a4 100644 --- a/libraries/platform/CMakeLists.txt +++ b/libraries/platform/CMakeLists.txt @@ -5,3 +5,11 @@ link_hifi_libraries(shared) GroupSources("src") target_json() + +if (APPLE) + # link in required OS X frameworks and include the right GL headers + find_library(OpenGL OpenGL) + find_library(AppKit AppKit) + + target_link_libraries(${TARGET_NAME} ${OpenGL} ${AppKit}) +endif () From 9ae67c15b233f873b50ff3e1235054283803bbc3 Mon Sep 17 00:00:00 2001 From: Matt Hardcastle Date: Mon, 24 Jun 2019 14:27:07 -0700 Subject: [PATCH 07/11] Use old API to launch tasks on all versions of macOS --- launchers/darwin/src/Interface.m | 26 ++++++++------------------ 1 file changed, 8 insertions(+), 18 deletions(-) diff --git a/launchers/darwin/src/Interface.m b/launchers/darwin/src/Interface.m index b007e7faa5..d02b66b581 100644 --- a/launchers/darwin/src/Interface.m +++ b/launchers/darwin/src/Interface.m @@ -23,24 +23,14 @@ NSLog(@"calling interface at %@", self->pathTo); - if (@available(macOS 10.13, *)) { - NSError *error = nil; - if (![interface launchAndReturnError:&error]) { - *outError = [NSError errorWithDomain:@"interface" - code:-1 - userInfo:@{NSUnderlyingErrorKey: error}]; - return 0; - } - } else { - NSError *error = nil; - [interface launch]; - [interface waitUntilExit]; - if (0 != [interface terminationStatus]) { - *outError = [NSError errorWithDomain:@"interface" - code:-1 - userInfo:@{NSUnderlyingErrorKey: error}]; - return 0; - } + NSError *error = nil; + [interface launch]; + [interface waitUntilExit]; + if (0 != [interface terminationStatus]) { + *outError = [NSError errorWithDomain:@"interface" + code:-1 + userInfo:@{NSUnderlyingErrorKey: error}]; + return 0; } NSFileHandle * fh = [standardOut fileHandleForReading]; From c605c2917f1c7a60ec447980bd82094269b6d301 Mon Sep 17 00:00:00 2001 From: SamGondelman Date: Mon, 24 Jun 2019 11:04:01 -0700 Subject: [PATCH 08/11] trying to fix entity tree renderer performance --- .../src/EntityTreeRenderer.cpp | 52 ++++++++----------- .../src/EntityTreeRenderer.h | 2 +- libraries/shared/src/PrioritySortUtil.h | 2 +- 3 files changed, 24 insertions(+), 32 deletions(-) diff --git a/libraries/entities-renderer/src/EntityTreeRenderer.cpp b/libraries/entities-renderer/src/EntityTreeRenderer.cpp index 5ac6e4f642..5cb7b89de5 100644 --- a/libraries/entities-renderer/src/EntityTreeRenderer.cpp +++ b/libraries/entities-renderer/src/EntityTreeRenderer.cpp @@ -207,7 +207,7 @@ void EntityTreeRenderer::stopDomainAndNonOwnedEntities() { if (entityItem && !entityItem->getScript().isEmpty()) { if (!(entityItem->isLocalEntity() || (entityItem->isAvatarEntity() && entityItem->getOwningAvatarID() == getTree()->getMyAvatarSessionUUID()))) { - if (entityItem->contains(_avatarPosition)) { + if (_currentEntitiesInside.contains(entityID)) { _entitiesScriptEngine->callEntityScriptMethod(entityID, "leaveEntity"); } _entitiesScriptEngine->unloadEntityScript(entityID, true); @@ -222,6 +222,7 @@ void EntityTreeRenderer::clearDomainAndNonOwnedEntities() { auto sessionUUID = getTree()->getMyAvatarSessionUUID(); std::unordered_map savedEntities; + std::unordered_set savedRenderables; // remove all entities from the scene auto scene = _viewState->getMain3DScene(); if (scene) { @@ -232,11 +233,12 @@ void EntityTreeRenderer::clearDomainAndNonOwnedEntities() { fadeOutRenderable(renderer); } else { savedEntities[entry.first] = entry.second; + savedRenderables.insert(entry.second); } } } - _renderablesToUpdate = savedEntities; + _renderablesToUpdate = savedRenderables; _entitiesInScene = savedEntities; if (_layeredZones.clearDomainAndNonOwnedZones(sessionUUID)) { @@ -389,13 +391,7 @@ void EntityTreeRenderer::updateChangedEntities(const render::ScenePointer& scene PerformanceTimer pt("change"); std::unordered_set changedEntities; _changedEntitiesGuard.withWriteLock([&] { -#if 0 - // FIXME Weird build failure in latest VC update that fails to compile when using std::swap changedEntities.swap(_changedEntities); -#else - changedEntities.insert(_changedEntities.begin(), _changedEntities.end()); - _changedEntities.clear(); -#endif }); { @@ -404,7 +400,7 @@ void EntityTreeRenderer::updateChangedEntities(const render::ScenePointer& scene auto renderable = renderableForEntityId(entityId); if (renderable) { // only add valid renderables _renderablesToUpdate - _renderablesToUpdate.insert({ entityId, renderable }); + _renderablesToUpdate.insert(renderable); } } } @@ -414,8 +410,7 @@ void EntityTreeRenderer::updateChangedEntities(const render::ScenePointer& scene // we expect to update all renderables within available time budget PROFILE_RANGE_EX(simulation_physics, "UpdateRenderables", 0xffff00ff, (uint64_t)_renderablesToUpdate.size()); uint64_t updateStart = usecTimestampNow(); - for (const auto& entry : _renderablesToUpdate) { - const auto& renderable = entry.second; + for (const auto& renderable : _renderablesToUpdate) { assert(renderable); // only valid renderables are added to _renderablesToUpdate renderable->updateInScene(scene, transaction); } @@ -424,8 +419,8 @@ void EntityTreeRenderer::updateChangedEntities(const render::ScenePointer& scene // compute average per-renderable update cost float cost = (float)(usecTimestampNow() - updateStart) / (float)(numRenderables); - const float blend = 0.1f; - _avgRenderableUpdateCost = (1.0f - blend) * _avgRenderableUpdateCost + blend * cost; + const float BLEND = 0.1f; + _avgRenderableUpdateCost = (1.0f - BLEND) * _avgRenderableUpdateCost + BLEND * cost; } else { // we expect the cost to updating all renderables to exceed available time budget // so we first sort by priority and update in order until out of time @@ -450,43 +445,40 @@ void EntityTreeRenderer::updateChangedEntities(const render::ScenePointer& scene PrioritySortUtil::PriorityQueue sortedRenderables(views); sortedRenderables.reserve(_renderablesToUpdate.size()); { - PROFILE_RANGE_EX(simulation_physics, "SortRenderables", 0xffff00ff, (uint64_t)_renderablesToUpdate.size()); - std::unordered_map::iterator itr = _renderablesToUpdate.begin(); - while (itr != _renderablesToUpdate.end()) { - assert(itr->second); // only valid renderables are added to _renderablesToUpdate - sortedRenderables.push(SortableRenderer(itr->second)); - ++itr; + PROFILE_RANGE_EX(simulation_physics, "BuildSortedRenderables", 0xffff00ff, (uint64_t)_renderablesToUpdate.size()); + for (const auto& renderable : _renderablesToUpdate) { + assert(renderable); // only valid renderables are added to _renderablesToUpdate + sortedRenderables.push(SortableRenderer(renderable)); } } { - PROFILE_RANGE_EX(simulation_physics, "UpdateRenderables", 0xffff00ff, sortedRenderables.size()); + PROFILE_RANGE_EX(simulation_physics, "SortAndUpdateRenderables", 0xffff00ff, sortedRenderables.size()); // compute remaining time budget + const auto& sortedRenderablesVector = sortedRenderables.getSortedVector(); uint64_t updateStart = usecTimestampNow(); - uint64_t timeBudget = MIN_SORTED_UPDATE_RENDERABLES_TIME_BUDGET; uint64_t sortCost = updateStart - sortStart; + uint64_t timeBudget = MIN_SORTED_UPDATE_RENDERABLES_TIME_BUDGET; if (sortCost < MAX_UPDATE_RENDERABLES_TIME_BUDGET - MIN_SORTED_UPDATE_RENDERABLES_TIME_BUDGET) { timeBudget = MAX_UPDATE_RENDERABLES_TIME_BUDGET - sortCost; } uint64_t expiry = updateStart + timeBudget; // process the sorted renderables - size_t numSorted = sortedRenderables.size(); - const auto& sortedRenderablesVector = sortedRenderables.getSortedVector(); for (const auto& sortedRenderable : sortedRenderablesVector) { if (usecTimestampNow() > expiry) { break; } const auto& renderable = sortedRenderable.getRenderer(); renderable->updateInScene(scene, transaction); - _renderablesToUpdate.erase(renderable->getEntity()->getID()); + _renderablesToUpdate.erase(renderable); } // compute average per-renderable update cost - size_t numUpdated = numSorted - sortedRenderables.size() + 1; // add one to avoid divide by zero + size_t numUpdated = sortedRenderables.size() - _renderablesToUpdate.size() + 1; // add one to avoid divide by zero float cost = (float)(usecTimestampNow() - updateStart) / (float)(numUpdated); - const float blend = 0.1f; - _avgRenderableUpdateCost = (1.0f - blend) * _avgRenderableUpdateCost + blend * cost; + const float BLEND = 0.1f; + _avgRenderableUpdateCost = (1.0f - BLEND) * _avgRenderableUpdateCost + BLEND * cost; } } } @@ -990,7 +982,6 @@ void EntityTreeRenderer::mouseMoveEvent(QMouseEvent* event) { void EntityTreeRenderer::deletingEntity(const EntityItemID& entityID) { // If it's in a pending queue, remove it - _renderablesToUpdate.erase(entityID); _entitiesToAdd.erase(entityID); auto itr = _entitiesInScene.find(entityID); @@ -1000,7 +991,7 @@ void EntityTreeRenderer::deletingEntity(const EntityItemID& entityID) { } if (_tree && !_shuttingDown && _entitiesScriptEngine && !itr->second->getEntity()->getScript().isEmpty()) { - if (itr->second->getEntity()->contains(_avatarPosition)) { + if (_currentEntitiesInside.contains(entityID)) { _entitiesScriptEngine->callEntityScriptMethod(entityID, "leaveEntity"); } _entitiesScriptEngine->unloadEntityScript(entityID, true); @@ -1013,6 +1004,7 @@ void EntityTreeRenderer::deletingEntity(const EntityItemID& entityID) { } auto renderable = itr->second; + _renderablesToUpdate.erase(renderable); _entitiesInScene.erase(itr); if (!renderable) { @@ -1047,7 +1039,7 @@ void EntityTreeRenderer::checkAndCallPreload(const EntityItemID& entityID, bool QString scriptUrl = entity->getScript(); if ((shouldLoad && unloadFirst) || scriptUrl.isEmpty()) { if (_entitiesScriptEngine) { - if (entity->contains(_avatarPosition)) { + if (_currentEntitiesInside.contains(entityID)) { _entitiesScriptEngine->callEntityScriptMethod(entityID, "leaveEntity"); } _entitiesScriptEngine->unloadEntityScript(entityID); diff --git a/libraries/entities-renderer/src/EntityTreeRenderer.h b/libraries/entities-renderer/src/EntityTreeRenderer.h index f794d947ed..bea04f106b 100644 --- a/libraries/entities-renderer/src/EntityTreeRenderer.h +++ b/libraries/entities-renderer/src/EntityTreeRenderer.h @@ -246,7 +246,7 @@ private: ReadWriteLockable _changedEntitiesGuard; std::unordered_set _changedEntities; - std::unordered_map _renderablesToUpdate; + std::unordered_set _renderablesToUpdate; std::unordered_map _entitiesInScene; std::unordered_map _entitiesToAdd; diff --git a/libraries/shared/src/PrioritySortUtil.h b/libraries/shared/src/PrioritySortUtil.h index d6a740231c..e4a258a065 100644 --- a/libraries/shared/src/PrioritySortUtil.h +++ b/libraries/shared/src/PrioritySortUtil.h @@ -45,7 +45,7 @@ namespace PrioritySortUtil { class PriorityQueue { public: PriorityQueue() = delete; - PriorityQueue(const ConicalViewFrustums& views) : _views(views) { } + PriorityQueue(const ConicalViewFrustums& views) : _views(views), _usecCurrentTime(usecTimestampNow()) { } PriorityQueue(const ConicalViewFrustums& views, float angularWeight, float centerWeight, float ageWeight) : _views(views), _angularWeight(angularWeight), _centerWeight(centerWeight), _ageWeight(ageWeight) , _usecCurrentTime(usecTimestampNow()) { From e119afdeada368d895e7fd547c0aff0823adfda3 Mon Sep 17 00:00:00 2001 From: dante ruiz Date: Mon, 24 Jun 2019 14:35:59 -0700 Subject: [PATCH 09/11] terms of service --- .../cmake/modules/MacOSXBundleInfo.plist.in | 2 +- launchers/darwin/nib/DisplayNameScreen.xib | 32 ++++++++++++++++++- launchers/darwin/src/DisplayNameScreen.m | 5 +++ 3 files changed, 37 insertions(+), 2 deletions(-) diff --git a/launchers/darwin/cmake/modules/MacOSXBundleInfo.plist.in b/launchers/darwin/cmake/modules/MacOSXBundleInfo.plist.in index 4c87bff3cf..3fe8e80f7a 100644 --- a/launchers/darwin/cmake/modules/MacOSXBundleInfo.plist.in +++ b/launchers/darwin/cmake/modules/MacOSXBundleInfo.plist.in @@ -32,6 +32,6 @@ CFBundleName ${MACOSX_BUNDLE_BUNDLE_NAME} CFBundleDisplayName - CFBundleName + ${MACOSX_BUNDLE_BUNDLE_NAME} diff --git a/launchers/darwin/nib/DisplayNameScreen.xib b/launchers/darwin/nib/DisplayNameScreen.xib index e56f2bf66b..f75491fc13 100644 --- a/launchers/darwin/nib/DisplayNameScreen.xib +++ b/launchers/darwin/nib/DisplayNameScreen.xib @@ -69,8 +69,17 @@ + + + + + + + + + + + + + + + + + + + + + @@ -91,5 +112,14 @@ + + + + + + + + + diff --git a/launchers/darwin/src/DisplayNameScreen.m b/launchers/darwin/src/DisplayNameScreen.m index 7a402d792b..581eabc4ee 100644 --- a/launchers/darwin/src/DisplayNameScreen.m +++ b/launchers/darwin/src/DisplayNameScreen.m @@ -31,4 +31,9 @@ { [[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:@"https://www.highfidelity.com/hq-support"]]; } + +- (IBAction)termsOfService:(id)sender +{ + [[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:@"https://www.highfidelity.com/termsofservice"]]; +} @end From c5883a8d67dc361c5a87b48fe95a0e66ccd57a67 Mon Sep 17 00:00:00 2001 From: Roxanne Skelly Date: Mon, 24 Jun 2019 14:58:06 -0700 Subject: [PATCH 10/11] CR fixes --- domain-server/src/NodeConnectionData.cpp | 2 +- libraries/networking/src/NodeList.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/domain-server/src/NodeConnectionData.cpp b/domain-server/src/NodeConnectionData.cpp index e3406aa797..5419014622 100644 --- a/domain-server/src/NodeConnectionData.cpp +++ b/domain-server/src/NodeConnectionData.cpp @@ -39,7 +39,7 @@ NodeConnectionData NodeConnectionData::fromDataStream(QDataStream& dataStream, c // and the operating system type QByteArray compressedSystemInfo; dataStream >> compressedSystemInfo; - if(!compressedSystemInfo.isEmpty()) { + if (!compressedSystemInfo.isEmpty()) { newHeader.SystemInfo = qUncompress(compressedSystemInfo); } diff --git a/libraries/networking/src/NodeList.cpp b/libraries/networking/src/NodeList.cpp index 0dad7705f8..9dd7716823 100644 --- a/libraries/networking/src/NodeList.cpp +++ b/libraries/networking/src/NodeList.cpp @@ -426,7 +426,7 @@ void NodeList::sendDomainServerCheckIn() { QByteArray systemInfo(desc.dump().c_str()); QByteArray compressedSystemInfo = qCompress(systemInfo); - if(compressedSystemInfo.size() > MAX_SYSTEM_INFO_SIZE) { + if (compressedSystemInfo.size() > MAX_SYSTEM_INFO_SIZE) { // Highly unlikely, as not even unreasonable machines will // overflow the max size, but prevent MTU overflow anyway. // We could do something sophisticated like clearing specific From dd639c4191b3ba47acbcf8fa0d0355f70dd83d42 Mon Sep 17 00:00:00 2001 From: dante ruiz Date: Mon, 24 Jun 2019 15:33:47 -0700 Subject: [PATCH 11/11] fix typo --- launchers/darwin/nib/DisplayNameScreen.xib | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/launchers/darwin/nib/DisplayNameScreen.xib b/launchers/darwin/nib/DisplayNameScreen.xib index f75491fc13..3ba3deba53 100644 --- a/launchers/darwin/nib/DisplayNameScreen.xib +++ b/launchers/darwin/nib/DisplayNameScreen.xib @@ -72,7 +72,7 @@ - +