From 8a3672f3c5c15b722c4010e65b024189ef97a122 Mon Sep 17 00:00:00 2001 From: Roxanne Skelly Date: Tue, 11 Jun 2019 12:41:45 -0700 Subject: [PATCH 01/24] Checkpoint MTBF uptime reporting --- domain-server/src/DomainGatekeeper.cpp | 22 ++++++++++--------- domain-server/src/NodeConnectionData.cpp | 4 ++++ domain-server/src/NodeConnectionData.h | 2 ++ libraries/networking/src/LimitedNodeList.cpp | 1 + libraries/networking/src/LimitedNodeList.h | 8 +++++++ libraries/networking/src/NodeList.cpp | 14 +++++++++++- .../networking/src/udt/PacketHeaders.cpp | 2 +- libraries/networking/src/udt/PacketHeaders.h | 3 ++- libraries/networking/src/udt/Socket.cpp | 16 ++++++++++---- 9 files changed, 55 insertions(+), 17 deletions(-) diff --git a/domain-server/src/DomainGatekeeper.cpp b/domain-server/src/DomainGatekeeper.cpp index f5705a570b..289d583719 100644 --- a/domain-server/src/DomainGatekeeper.cpp +++ b/domain-server/src/DomainGatekeeper.cpp @@ -57,7 +57,7 @@ void DomainGatekeeper::processConnectRequestPacket(QSharedPointergetSize() == 0) { return; } - + QDataStream packetStream(message->getMessage()); // read a NodeConnectionData object from the packet so we can pass around this data while we're inspecting it @@ -88,11 +88,10 @@ void DomainGatekeeper::processConnectRequestPacket(QSharedPointersecond); } else if (!STATICALLY_ASSIGNED_NODES.contains(nodeConnection.nodeType)) { - QString username; QByteArray usernameSignature; if (message->getBytesLeftToRead() > 0) { @@ -122,9 +121,13 @@ void DomainGatekeeper::processConnectRequestPacket(QSharedPointersetNodeInterestSet(safeInterestSet); nodeData->setPlaceName(nodeConnection.placeName); - qDebug() << "Allowed connection from node" << uuidStringWithoutCurlyBraces(node->getUUID()) - << "on" << message->getSenderSockAddr() << "with MAC" << nodeConnection.hardwareAddress - << "and machine fingerprint" << nodeConnection.machineFingerprint; + qDebug() << "Allowed connection from node" << uuidStringWithoutCurlyBraces(node->getUUID()) + << "on" << message->getSenderSockAddr() + << "with MAC" << nodeConnection.hardwareAddress + << "and machine fingerprint" << nodeConnection.machineFingerprint + << "user" << username + << "reason" << nodeConnection.connectReason + << "previous connection uptime" << nodeConnection.previousConnectionUpTime/USECS_PER_MSEC << "msec"; // signal that we just connected a node so the DomainServer can get it a list // and broadcast its presence right away @@ -468,7 +471,7 @@ SharedNodePointer DomainGatekeeper::processAgentConnectRequest(const NodeConnect if (node->getPublicSocket() == nodeConnection.publicSockAddr && node->getLocalSocket() == nodeConnection.localSockAddr) { // we have a node that already has these exact sockets // this can occur if a node is failing to connect to the domain - + // remove the old node before adding the new node qDebug() << "Deleting existing connection from same sockaddr: " << node->getUUID(); existingNodeID = node->getUUID(); @@ -842,7 +845,7 @@ void DomainGatekeeper::processICEPingPacket(QSharedPointer mess // before we respond to this ICE ping packet, make sure we have a peer in the list that matches QUuid icePeerID = QUuid::fromRfc4122({ message->getRawMessage(), NUM_BYTES_RFC4122_UUID }); - + if (_icePeers.contains(icePeerID)) { auto pingReplyPacket = limitedNodeList->constructICEPingReplyPacket(*message, limitedNodeList->getSessionUUID()); @@ -882,7 +885,6 @@ void DomainGatekeeper::getGroupMemberships(const QString& username) { QJsonArray groupIDs = QJsonArray::fromStringList(groupIDSet.toList()); json["groups"] = groupIDs; - // if we've already asked, wait for the answer before asking again QString lowerUsername = username.toLower(); if (_inFlightGroupMembershipsRequests.contains(lowerUsername)) { @@ -969,7 +971,7 @@ void DomainGatekeeper::getDomainOwnerFriendsList() { QNetworkAccessManager::GetOperation, callbackParams, QByteArray(), NULL, QVariantMap()); } - + } void DomainGatekeeper::getDomainOwnerFriendsListJSONCallback(QNetworkReply* requestReply) { diff --git a/domain-server/src/NodeConnectionData.cpp b/domain-server/src/NodeConnectionData.cpp index b3ea005bd1..b4aaacd749 100644 --- a/domain-server/src/NodeConnectionData.cpp +++ b/domain-server/src/NodeConnectionData.cpp @@ -35,6 +35,10 @@ NodeConnectionData NodeConnectionData::fromDataStream(QDataStream& dataStream, c // now the machine fingerprint dataStream >> newHeader.machineFingerprint; + + dataStream >> newHeader.connectReason; + + dataStream >> newHeader.previousConnectionUpTime; } dataStream >> newHeader.lastPingTimestamp; diff --git a/domain-server/src/NodeConnectionData.h b/domain-server/src/NodeConnectionData.h index 43661f9caf..23eceb0dca 100644 --- a/domain-server/src/NodeConnectionData.h +++ b/domain-server/src/NodeConnectionData.h @@ -31,6 +31,8 @@ public: QString placeName; QString hardwareAddress; QUuid machineFingerprint; + quint32 connectReason; + quint64 previousConnectionUpTime; QByteArray protocolVersion; }; diff --git a/libraries/networking/src/LimitedNodeList.cpp b/libraries/networking/src/LimitedNodeList.cpp index 48f08d6d2e..9f4eb39013 100644 --- a/libraries/networking/src/LimitedNodeList.cpp +++ b/libraries/networking/src/LimitedNodeList.cpp @@ -632,6 +632,7 @@ void LimitedNodeList::processKillNode(ReceivedMessage& message) { } void LimitedNodeList::handleNodeKill(const SharedNodePointer& node, ConnectionID nextConnectionID) { + _nodeDisconnectTimestamp = usecTimestampNow(); qCDebug(networking) << "Killed" << *node; node->stopPingTimer(); emit nodeKilled(node); diff --git a/libraries/networking/src/LimitedNodeList.h b/libraries/networking/src/LimitedNodeList.h index f7ea0ec2ad..42fb5311b1 100644 --- a/libraries/networking/src/LimitedNodeList.h +++ b/libraries/networking/src/LimitedNodeList.h @@ -337,6 +337,12 @@ public: NodeType::EntityScriptServer }; + enum DomainConnectReason : quint32 { + START = 0, + RECONNECT + }; + Q_ENUM(DomainConnectReason); + public slots: void reset(); void eraseAllNodes(); @@ -461,6 +467,8 @@ protected: } std::unordered_map _connectionIDs; + quint64 _nodeConnectTimestamp { 0 }; + quint64 _nodeDisconnectTimestamp { 0 }; private slots: void flagTimeForConnectionStep(ConnectionStep connectionStep, quint64 timestamp); diff --git a/libraries/networking/src/NodeList.cpp b/libraries/networking/src/NodeList.cpp index 0e6b5503d7..c352b9f5ea 100644 --- a/libraries/networking/src/NodeList.cpp +++ b/libraries/networking/src/NodeList.cpp @@ -296,6 +296,8 @@ void NodeList::addSetOfNodeTypesToNodeInterestSet(const NodeSet& setOfNodeTypes) void NodeList::sendDomainServerCheckIn() { + int outstandingCheckins = _domainHandler.getCheckInPacketsSinceLastReply(); + // On ThreadedAssignments (assignment clients), this function // is called by the server check-in timer thread // not the NodeList thread. Calling it on the NodeList thread @@ -414,6 +416,16 @@ void NodeList::sendDomainServerCheckIn() { // now add the machine fingerprint auto accountManager = DependencyManager::get(); packetStream << FingerprintUtils::getMachineFingerprint(); + + packetStream << ((outstandingCheckins >= MAX_SILENT_DOMAIN_SERVER_CHECK_INS) ? RECONNECT : START); + + if (_nodeDisconnectTimestamp < _nodeConnectTimestamp) { + _nodeDisconnectTimestamp = usecTimestampNow(); + } + quint64 previousConnectionUptime = _nodeConnectTimestamp ? _nodeDisconnectTimestamp - _nodeConnectTimestamp : 0; + + packetStream << previousConnectionUptime; + } packetStream << quint64(duration_cast(system_clock::now().time_since_epoch()).count()); @@ -439,7 +451,6 @@ void NodeList::sendDomainServerCheckIn() { // Send duplicate check-ins in the exponentially increasing sequence 1, 1, 2, 4, ... static const int MAX_CHECKINS_TOGETHER = 20; static const int REBIND_CHECKIN_COUNT = 2; - int outstandingCheckins = _domainHandler.getCheckInPacketsSinceLastReply(); if (outstandingCheckins > REBIND_CHECKIN_COUNT) { _nodeSocket.rebind(); @@ -626,6 +637,7 @@ void NodeList::processDomainServerConnectionTokenPacket(QSharedPointerreadWithoutCopy(NUM_BYTES_RFC4122_UUID))); _domainHandler.clearPendingCheckins(); + _nodeConnectTimestamp = usecTimestampNow(); sendDomainServerCheckIn(); } diff --git a/libraries/networking/src/udt/PacketHeaders.cpp b/libraries/networking/src/udt/PacketHeaders.cpp index 566e1e4946..7ebaf5224f 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::HasTimestamp); + return static_cast(DomainConnectRequestVersion::HasReason); 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 903c1f4c93..5baf5448dd 100644 --- a/libraries/networking/src/udt/PacketHeaders.h +++ b/libraries/networking/src/udt/PacketHeaders.h @@ -345,7 +345,8 @@ enum class DomainConnectRequestVersion : PacketVersion { HasMACAddress, HasMachineFingerprint, AlwaysHasMachineFingerprint, - HasTimestamp + HasTimestamp, + HasReason }; enum class DomainConnectionDeniedVersion : PacketVersion { diff --git a/libraries/networking/src/udt/Socket.cpp b/libraries/networking/src/udt/Socket.cpp index 406c2ff213..350c592c61 100644 --- a/libraries/networking/src/udt/Socket.cpp +++ b/libraries/networking/src/udt/Socket.cpp @@ -59,10 +59,13 @@ void Socket::bind(const QHostAddress& address, quint16 port) { auto sd = _udpSocket.socketDescriptor(); int val = IP_PMTUDISC_DONT; setsockopt(sd, IPPROTO_IP, IP_MTU_DISCOVER, &val, sizeof(val)); -#elif defined(Q_OS_WINDOWS) +#elif defined(Q_OS_WIN) auto sd = _udpSocket.socketDescriptor(); int val = 0; // false - setsockopt(sd, IPPROTO_IP, IP_DONTFRAGMENT, &val, sizeof(val)); + if (setsockopt(sd, IPPROTO_IP, IP_DONTFRAGMENT, (const char*)&val, sizeof(val))) { + auto err = WSAGetLastError(); + qCWarning(networking) << "Socket::bind Cannot setsockopt IP_DONTFRAGMENT" << err; + } #endif } } @@ -232,14 +235,17 @@ qint64 Socket::writeDatagram(const QByteArray& datagram, const HifiSockAddr& soc } qint64 bytesWritten = _udpSocket.writeDatagram(datagram, sockAddr.getAddress(), sockAddr.getPort()); + + if (bytesWritten < 0) { - qCDebug(networking) << "udt::writeDatagram (" << _udpSocket.state() << ") error - " << _udpSocket.error() << "(" << _udpSocket.errorString() << ")"; #ifdef WIN32 int wsaError = WSAGetLastError(); qCDebug(networking) << "windows socket error " << wsaError; #endif + qCDebug(networking) << "udt::writeDatagram (" << _udpSocket.state() << ") error - " << _udpSocket.error() << "(" << _udpSocket.errorString() << ")"; + #ifdef DEBUG_EVENT_QUEUE int nodeListQueueSize = ::hifi::qt::getEventQueueSize(thread()); qCDebug(networking) << "Networking queue size - " << nodeListQueueSize; @@ -506,11 +512,13 @@ std::vector Socket::getConnectionSockAddrs() { } void Socket::handleSocketError(QAbstractSocket::SocketError socketError) { - qCDebug(networking) << "udt::Socket (" << _udpSocket.state() << ") error - " << socketError << "(" << _udpSocket.errorString() << ")"; + #ifdef WIN32 int wsaError = WSAGetLastError(); qCDebug(networking) << "windows socket error " << wsaError; #endif + + qCDebug(networking) << "udt::Socket (" << _udpSocket.state() << ") error - " << socketError << "(" << _udpSocket.errorString() << ")"; #ifdef DEBUG_EVENT_QUEUE int nodeListQueueSize = ::hifi::qt::getEventQueueSize(thread()); qCDebug(networking) << "Networking queue size - " << nodeListQueueSize; From ec91f4dae4f5141802d95480d0e9a9746cfbbb91 Mon Sep 17 00:00:00 2001 From: Roxanne Skelly Date: Tue, 11 Jun 2019 14:37:46 -0700 Subject: [PATCH 02/24] More checkpoint MTBF logging --- domain-server/src/DomainGatekeeper.cpp | 2 +- domain-server/src/DomainServer.cpp | 7 ++++--- domain-server/src/DomainServer.h | 2 +- domain-server/src/NodeConnectionData.cpp | 2 +- domain-server/src/NodeConnectionData.h | 2 +- libraries/networking/src/NodeList.cpp | 8 +++++++- 6 files changed, 15 insertions(+), 8 deletions(-) diff --git a/domain-server/src/DomainGatekeeper.cpp b/domain-server/src/DomainGatekeeper.cpp index 289d583719..4645a25ca6 100644 --- a/domain-server/src/DomainGatekeeper.cpp +++ b/domain-server/src/DomainGatekeeper.cpp @@ -126,7 +126,7 @@ void DomainGatekeeper::processConnectRequestPacket(QSharedPointer mess // client-side send time of last connect/domain list request nodeData->setLastDomainCheckinTimestamp(nodeRequestData.lastPingTimestamp); - sendDomainListToNode(sendingNode, message->getFirstPacketReceiveTime(), message->getSenderSockAddr()); + sendDomainListToNode(sendingNode, message->getFirstPacketReceiveTime(), message->getSenderSockAddr(), false); } bool DomainServer::isInInterestSet(const SharedNodePointer& nodeA, const SharedNodePointer& nodeB) { @@ -1145,7 +1145,7 @@ void DomainServer::handleConnectedNode(SharedNodePointer newNode, quint64 reques DomainServerNodeData* nodeData = static_cast(newNode->getLinkedData()); // reply back to the user with a PacketType::DomainList - sendDomainListToNode(newNode, requestReceiveTime, nodeData->getSendingSockAddr()); + sendDomainListToNode(newNode, requestReceiveTime, nodeData->getSendingSockAddr(), true); // if this node is a user (unassigned Agent), signal if (newNode->getType() == NodeType::Agent && !nodeData->wasAssigned()) { @@ -1161,7 +1161,7 @@ void DomainServer::handleConnectedNode(SharedNodePointer newNode, quint64 reques broadcastNewNode(newNode); } -void DomainServer::sendDomainListToNode(const SharedNodePointer& node, quint64 requestPacketReceiveTime, const HifiSockAddr &senderSockAddr) { +void DomainServer::sendDomainListToNode(const SharedNodePointer& node, quint64 requestPacketReceiveTime, const HifiSockAddr &senderSockAddr, bool newConnection) { const int NUM_DOMAIN_LIST_EXTENDED_HEADER_BYTES = NUM_BYTES_RFC4122_UUID + NLPacket::NUM_BYTES_LOCALID + NUM_BYTES_RFC4122_UUID + NLPacket::NUM_BYTES_LOCALID + 4; @@ -1181,6 +1181,7 @@ void DomainServer::sendDomainListToNode(const SharedNodePointer& node, quint64 r extendedHeaderStream << nodeData->getLastDomainCheckinTimestamp(); extendedHeaderStream << quint64(duration_cast(system_clock::now().time_since_epoch()).count()); extendedHeaderStream << quint64(duration_cast(p_high_resolution_clock::now().time_since_epoch()).count()) - requestPacketReceiveTime; + extendedHeaderStream << newConnection; auto domainListPackets = NLPacketList::create(PacketType::DomainList, extendedHeader); // always send the node their own UUID back diff --git a/domain-server/src/DomainServer.h b/domain-server/src/DomainServer.h index 36ebe5a234..54b7fbe466 100644 --- a/domain-server/src/DomainServer.h +++ b/domain-server/src/DomainServer.h @@ -173,7 +173,7 @@ private: void handleKillNode(SharedNodePointer nodeToKill); void broadcastNodeDisconnect(const SharedNodePointer& disconnnectedNode); - void sendDomainListToNode(const SharedNodePointer& node, quint64 requestPacketReceiveTime, const HifiSockAddr& senderSockAddr); + void sendDomainListToNode(const SharedNodePointer& node, quint64 requestPacketReceiveTime, const HifiSockAddr& senderSockAddr, bool newConnection); bool isInInterestSet(const SharedNodePointer& nodeA, const SharedNodePointer& nodeB); diff --git a/domain-server/src/NodeConnectionData.cpp b/domain-server/src/NodeConnectionData.cpp index b4aaacd749..c99437d185 100644 --- a/domain-server/src/NodeConnectionData.cpp +++ b/domain-server/src/NodeConnectionData.cpp @@ -36,7 +36,7 @@ NodeConnectionData NodeConnectionData::fromDataStream(QDataStream& dataStream, c // now the machine fingerprint dataStream >> newHeader.machineFingerprint; - dataStream >> newHeader.connectReason; + dataStream >> newHeader.wasSilentDomainDisconnect; dataStream >> newHeader.previousConnectionUpTime; } diff --git a/domain-server/src/NodeConnectionData.h b/domain-server/src/NodeConnectionData.h index 23eceb0dca..96a9c0d392 100644 --- a/domain-server/src/NodeConnectionData.h +++ b/domain-server/src/NodeConnectionData.h @@ -31,7 +31,7 @@ public: QString placeName; QString hardwareAddress; QUuid machineFingerprint; - quint32 connectReason; + quint32 wasSilentDomainDisconnect; quint64 previousConnectionUpTime; QByteArray protocolVersion; diff --git a/libraries/networking/src/NodeList.cpp b/libraries/networking/src/NodeList.cpp index c352b9f5ea..dc1bd701b8 100644 --- a/libraries/networking/src/NodeList.cpp +++ b/libraries/networking/src/NodeList.cpp @@ -637,7 +637,6 @@ void NodeList::processDomainServerConnectionTokenPacket(QSharedPointerreadWithoutCopy(NUM_BYTES_RFC4122_UUID))); _domainHandler.clearPendingCheckins(); - _nodeConnectTimestamp = usecTimestampNow(); sendDomainServerCheckIn(); } @@ -678,6 +677,13 @@ void NodeList::processDomainServerList(QSharedPointer message) quint64 domainServerCheckinProcessingTime; packetStream >> domainServerCheckinProcessingTime; + bool newConnection; + packetStream >> newConnection; + + if (newConnection) { + _nodeConnectTimestamp = usecTimestampNow(); + } + qint64 pingLagTime = (now - qint64(connectRequestTimestamp)) / qint64(USECS_PER_MSEC); qint64 domainServerRequestLag = (qint64(domainServerPingSendTime - domainServerCheckinProcessingTime) - qint64(connectRequestTimestamp)) / qint64(USECS_PER_MSEC);; From 071a779930321b853fbdbe5b40395a0435530925 Mon Sep 17 00:00:00 2001 From: Roxanne Skelly Date: Tue, 11 Jun 2019 14:38:39 -0700 Subject: [PATCH 03/24] convert enum reason for disconnect to boolean --- libraries/networking/src/LimitedNodeList.h | 7 +------ libraries/networking/src/NodeList.cpp | 18 +++++++++++++----- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/libraries/networking/src/LimitedNodeList.h b/libraries/networking/src/LimitedNodeList.h index 42fb5311b1..4df6df621f 100644 --- a/libraries/networking/src/LimitedNodeList.h +++ b/libraries/networking/src/LimitedNodeList.h @@ -337,12 +337,6 @@ public: NodeType::EntityScriptServer }; - enum DomainConnectReason : quint32 { - START = 0, - RECONNECT - }; - Q_ENUM(DomainConnectReason); - public slots: void reset(); void eraseAllNodes(); @@ -469,6 +463,7 @@ protected: std::unordered_map _connectionIDs; quint64 _nodeConnectTimestamp { 0 }; quint64 _nodeDisconnectTimestamp { 0 }; + bool _wasSilentDomainDisconnect { false }; private slots: void flagTimeForConnectionStep(ConnectionStep connectionStep, quint64 timestamp); diff --git a/libraries/networking/src/NodeList.cpp b/libraries/networking/src/NodeList.cpp index c352b9f5ea..fa3c40b138 100644 --- a/libraries/networking/src/NodeList.cpp +++ b/libraries/networking/src/NodeList.cpp @@ -113,6 +113,9 @@ NodeList::NodeList(char newOwnerType, int socketListenPort, int dtlsListenPort) connect(&_domainHandler, SIGNAL(connectedToDomain(QUrl)), &_keepAlivePingTimer, SLOT(start())); connect(&_domainHandler, &DomainHandler::disconnectedFromDomain, &_keepAlivePingTimer, &QTimer::stop); + connect(&_domainHandler, &DomainHandler::limitOfSilentDomainCheckInsReached, + this, [this]() {_wasSilentDomainDisconnect = true; }); + // set our sockAddrBelongsToDomainOrNode method as the connection creation filter for the udt::Socket using std::placeholders::_1; _nodeSocket.setConnectionCreationFilterOperator(std::bind(&NodeList::sockAddrBelongsToDomainOrNode, this, _1)); @@ -296,8 +299,6 @@ void NodeList::addSetOfNodeTypesToNodeInterestSet(const NodeSet& setOfNodeTypes) void NodeList::sendDomainServerCheckIn() { - int outstandingCheckins = _domainHandler.getCheckInPacketsSinceLastReply(); - // On ThreadedAssignments (assignment clients), this function // is called by the server check-in timer thread // not the NodeList thread. Calling it on the NodeList thread @@ -417,7 +418,7 @@ void NodeList::sendDomainServerCheckIn() { auto accountManager = DependencyManager::get(); packetStream << FingerprintUtils::getMachineFingerprint(); - packetStream << ((outstandingCheckins >= MAX_SILENT_DOMAIN_SERVER_CHECK_INS) ? RECONNECT : START); + packetStream << quint32(_wasSilentDomainDisconnect ? 1 : 0); if (_nodeDisconnectTimestamp < _nodeConnectTimestamp) { _nodeDisconnectTimestamp = usecTimestampNow(); @@ -451,7 +452,7 @@ void NodeList::sendDomainServerCheckIn() { // Send duplicate check-ins in the exponentially increasing sequence 1, 1, 2, 4, ... static const int MAX_CHECKINS_TOGETHER = 20; static const int REBIND_CHECKIN_COUNT = 2; - + int outstandingCheckins = _domainHandler.getCheckInPacketsSinceLastReply(); if (outstandingCheckins > REBIND_CHECKIN_COUNT) { _nodeSocket.rebind(); } @@ -637,7 +638,6 @@ void NodeList::processDomainServerConnectionTokenPacket(QSharedPointerreadWithoutCopy(NUM_BYTES_RFC4122_UUID))); _domainHandler.clearPendingCheckins(); - _nodeConnectTimestamp = usecTimestampNow(); sendDomainServerCheckIn(); } @@ -678,6 +678,14 @@ void NodeList::processDomainServerList(QSharedPointer message) quint64 domainServerCheckinProcessingTime; packetStream >> domainServerCheckinProcessingTime; + bool newConnection; + packetStream >> newConnection; + + if (newConnection) { + _nodeConnectTimestamp = usecTimestampNow(); + _wasSilentDomainDisconnect = false; + } + qint64 pingLagTime = (now - qint64(connectRequestTimestamp)) / qint64(USECS_PER_MSEC); qint64 domainServerRequestLag = (qint64(domainServerPingSendTime - domainServerCheckinProcessingTime) - qint64(connectRequestTimestamp)) / qint64(USECS_PER_MSEC);; From 3c9edb90d87747ba1f520df7d63a7cb276844b6a Mon Sep 17 00:00:00 2001 From: Roxanne Skelly Date: Tue, 11 Jun 2019 15:35:50 -0700 Subject: [PATCH 04/24] Log formatting fix --- domain-server/src/DomainGatekeeper.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/domain-server/src/DomainGatekeeper.cpp b/domain-server/src/DomainGatekeeper.cpp index 4645a25ca6..1b4b78c81e 100644 --- a/domain-server/src/DomainGatekeeper.cpp +++ b/domain-server/src/DomainGatekeeper.cpp @@ -126,7 +126,7 @@ void DomainGatekeeper::processConnectRequestPacket(QSharedPointer Date: Tue, 11 Jun 2019 16:00:49 -0700 Subject: [PATCH 05/24] Update packet headers / add connect 'reason' --- domain-server/src/DomainGatekeeper.cpp | 2 +- domain-server/src/NodeConnectionData.cpp | 2 +- domain-server/src/NodeConnectionData.h | 2 +- libraries/networking/src/LimitedNodeList.h | 168 +++++++++++------- libraries/networking/src/NodeList.cpp | 7 +- .../networking/src/udt/PacketHeaders.cpp | 2 +- libraries/networking/src/udt/PacketHeaders.h | 3 +- 7 files changed, 108 insertions(+), 78 deletions(-) diff --git a/domain-server/src/DomainGatekeeper.cpp b/domain-server/src/DomainGatekeeper.cpp index 1b4b78c81e..fee6069c7a 100644 --- a/domain-server/src/DomainGatekeeper.cpp +++ b/domain-server/src/DomainGatekeeper.cpp @@ -126,7 +126,7 @@ void DomainGatekeeper::processConnectRequestPacket(QSharedPointer> newHeader.machineFingerprint; - dataStream >> newHeader.wasSilentDomainDisconnect; + dataStream >> newHeader.connectReason; dataStream >> newHeader.previousConnectionUpTime; } diff --git a/domain-server/src/NodeConnectionData.h b/domain-server/src/NodeConnectionData.h index 96a9c0d392..23eceb0dca 100644 --- a/domain-server/src/NodeConnectionData.h +++ b/domain-server/src/NodeConnectionData.h @@ -31,7 +31,7 @@ public: QString placeName; QString hardwareAddress; QUuid machineFingerprint; - quint32 wasSilentDomainDisconnect; + quint32 connectReason; quint64 previousConnectionUpTime; QByteArray protocolVersion; diff --git a/libraries/networking/src/LimitedNodeList.h b/libraries/networking/src/LimitedNodeList.h index 4df6df621f..fc93435599 100644 --- a/libraries/networking/src/LimitedNodeList.h +++ b/libraries/networking/src/LimitedNodeList.h @@ -20,7 +20,7 @@ #include #ifndef _WIN32 -#include // not on windows, not needed for mac or windows +#include // not on windows, not needed for mac or windows #endif #include @@ -51,7 +51,7 @@ const int INVALID_PORT = -1; const quint64 NODE_SILENCE_THRESHOLD_MSECS = 10 * 1000; -static const size_t DEFAULT_MAX_CONNECTION_RATE { std::numeric_limits::max() }; +static const size_t DEFAULT_MAX_CONNECTION_RATE{ std::numeric_limits::max() }; const char DEFAULT_ASSIGNMENT_SERVER_HOSTNAME[] = "localhost"; @@ -67,26 +67,26 @@ const QHostAddress DEFAULT_ASSIGNMENT_CLIENT_MONITOR_HOSTNAME = QHostAddress::Lo const QString USERNAME_UUID_REPLACEMENT_STATS_KEY = "$username"; using ConnectionID = int64_t; -const ConnectionID NULL_CONNECTION_ID { -1 }; -const ConnectionID INITIAL_CONNECTION_ID { 0 }; +const ConnectionID NULL_CONNECTION_ID{ -1 }; +const ConnectionID INITIAL_CONNECTION_ID{ 0 }; typedef std::pair UUIDNodePair; typedef tbb::concurrent_unordered_map NodeHash; typedef quint8 PingType_t; namespace PingType { - const PingType_t Agnostic = 0; - const PingType_t Local = 1; - const PingType_t Public = 2; - const PingType_t Symmetric = 3; -} +const PingType_t Agnostic = 0; +const PingType_t Local = 1; +const PingType_t Public = 2; +const PingType_t Symmetric = 3; +} // namespace PingType class LimitedNodeList : public QObject, public Dependency { Q_OBJECT SINGLETON_DEPENDENCY public: - - enum ConnectionStep { + enum ConnectionStep + { LookupAddress = 1, HandleAddress, SendSTUNRequest, @@ -108,6 +108,14 @@ public: }; Q_ENUM(ConnectionStep); + + enum ConnectReason : quint32 + { + Connect = 0, + SilentDomainDisconnect + }; + Q_ENUM(ConnectReason); + QUuid getSessionUUID() const; void setSessionUUID(const QUuid& sessionUUID); Node::LocalID getSessionLocalID() const; @@ -117,12 +125,18 @@ public: bool isAllowedEditor() const { return _permissions.can(NodePermissions::Permission::canAdjustLocks); } bool getThisNodeCanRez() const { return _permissions.can(NodePermissions::Permission::canRezPermanentEntities); } bool getThisNodeCanRezTmp() const { return _permissions.can(NodePermissions::Permission::canRezTemporaryEntities); } - bool getThisNodeCanRezCertified() const { return _permissions.can(NodePermissions::Permission::canRezPermanentCertifiedEntities); } - bool getThisNodeCanRezTmpCertified() const { return _permissions.can(NodePermissions::Permission::canRezTemporaryCertifiedEntities); } + bool getThisNodeCanRezCertified() const { + return _permissions.can(NodePermissions::Permission::canRezPermanentCertifiedEntities); + } + bool getThisNodeCanRezTmpCertified() const { + return _permissions.can(NodePermissions::Permission::canRezTemporaryCertifiedEntities); + } bool getThisNodeCanWriteAssets() const { return _permissions.can(NodePermissions::Permission::canWriteToAssetServer); } bool getThisNodeCanKick() const { return _permissions.can(NodePermissions::Permission::canKick); } bool getThisNodeCanReplaceContent() const { return _permissions.can(NodePermissions::Permission::canReplaceDomainContent); } - bool getThisNodeCanGetAndSetPrivateUserData() const { return _permissions.can(NodePermissions::Permission::canGetAndSetPrivateUserData); } + bool getThisNodeCanGetAndSetPrivateUserData() const { + return _permissions.can(NodePermissions::Permission::canGetAndSetPrivateUserData); + } quint16 getSocketLocalPort() const { return _nodeSocket.localPort(); } Q_INVOKABLE void setSocketLocalPort(quint16 socketLocalPort); @@ -132,9 +146,18 @@ public: PacketReceiver& getPacketReceiver() { return *_packetReceiver; } virtual bool isDomainServer() const { return true; } - virtual QUuid getDomainUUID() const { assert(false); return QUuid(); } - virtual Node::LocalID getDomainLocalID() const { assert(false); return Node::NULL_LOCAL_ID; } - virtual HifiSockAddr getDomainSockAddr() const { assert(false); return HifiSockAddr(); } + virtual QUuid getDomainUUID() const { + assert(false); + return QUuid(); + } + virtual Node::LocalID getDomainLocalID() const { + assert(false); + return Node::NULL_LOCAL_ID; + } + virtual HifiSockAddr getDomainSockAddr() const { + assert(false); + return HifiSockAddr(); + } // use sendUnreliablePacket to send an unreliable packet (that you do not need to move) // either to a node (via its active socket) or to a manual sockaddr @@ -148,8 +171,9 @@ public: // use sendUnreliableUnorderedPacketList to unreliably send separate packets from the packet list // either to a node's active socket or to a manual sockaddr qint64 sendUnreliableUnorderedPacketList(NLPacketList& packetList, const Node& destinationNode); - qint64 sendUnreliableUnorderedPacketList(NLPacketList& packetList, const HifiSockAddr& sockAddr, - HMACAuth* hmacAuth = nullptr); + qint64 sendUnreliableUnorderedPacketList(NLPacketList& packetList, + const HifiSockAddr& sockAddr, + HMACAuth* hmacAuth = nullptr); // use sendPacketList to send reliable packet lists (ordered or unordered) to a node's active socket // or to a manual sock addr @@ -158,15 +182,22 @@ public: std::function linkedDataCreateCallback; - size_t size() const { QReadLocker readLock(&_nodeMutex); return _nodeHash.size(); } + size_t size() const { + QReadLocker readLock(&_nodeMutex); + return _nodeHash.size(); + } SharedNodePointer nodeWithUUID(const QUuid& nodeUUID); SharedNodePointer nodeWithLocalID(Node::LocalID localID) const; - SharedNodePointer addOrUpdateNode(const QUuid& uuid, NodeType_t nodeType, - const HifiSockAddr& publicSocket, const HifiSockAddr& localSocket, - Node::LocalID localID = Node::NULL_LOCAL_ID, bool isReplicated = false, - bool isUpstream = false, const QUuid& connectionSecret = QUuid(), + SharedNodePointer addOrUpdateNode(const QUuid& uuid, + NodeType_t nodeType, + const HifiSockAddr& publicSocket, + const HifiSockAddr& localSocket, + Node::LocalID localID = Node::NULL_LOCAL_ID, + bool isReplicated = false, + bool isUpstream = false, + const QUuid& connectionSecret = QUuid(), const NodePermissions& permissions = DEFAULT_AGENT_PERMISSIONS); static bool parseSTUNResponse(udt::BasePacket* packet, QHostAddress& newPublicAddress, uint16_t& newPublicPort); @@ -201,7 +232,7 @@ public: // Use this for nested loops instead of taking nested read locks! // This allows multiple threads (i.e. a thread pool) to share a lock // without deadlocking when a dying node attempts to acquire a write lock - template + template void nestedEach(NestedNodeLambda functor, int* lockWaitOut = nullptr, int* nodeTransformOut = nullptr, @@ -221,9 +252,8 @@ public: // so reserve enough memory for the current size // and then back insert all the nodes found nodes.reserve(_nodeHash.size()); - std::transform(_nodeHash.cbegin(), _nodeHash.cend(), std::back_inserter(nodes), [&](const NodeHash::value_type& it) { - return it.second; - }); + std::transform(_nodeHash.cbegin(), _nodeHash.cend(), std::back_inserter(nodes), + [&](const NodeHash::value_type& it) { return it.second; }); endTransform = usecTimestampNow(); if (nodeTransformOut) { @@ -238,7 +268,7 @@ public: } } - template + template void eachNode(NodeLambda functor) { QReadLocker readLock(&_nodeMutex); @@ -247,7 +277,7 @@ public: } } - template + template void eachMatchingNode(PredLambda predicate, NodeLambda functor) { QReadLocker readLock(&_nodeMutex); @@ -258,7 +288,7 @@ public: } } - template + template void eachNodeBreakable(BreakableNodeLambda functor) { QReadLocker readLock(&_nodeMutex); @@ -269,7 +299,7 @@ public: } } - template + template SharedNodePointer nodeMatchingPredicate(const PredLambda predicate) { QReadLocker readLock(&_nodeMutex); @@ -285,7 +315,7 @@ public: // This is unsafe because it does not take a lock // Must only be called when you know that a read lock on the node mutex is held // and will be held for the duration of your iteration - template + template void unsafeEachNode(NodeLambda functor) { for (NodeHash::const_iterator it = _nodeHash.cbegin(); it != _nodeHash.cend(); ++it) { functor(it->second); @@ -295,15 +325,19 @@ public: void putLocalPortIntoSharedMemory(const QString key, QObject* parent, quint16 localPort); bool getLocalServerPortFromSharedMemory(const QString key, quint16& localPort); - const QMap getLastConnectionTimes() const - { QReadLocker readLock(&_connectionTimeLock); return _lastConnectionTimes; } + const QMap getLastConnectionTimes() const { + QReadLocker readLock(&_connectionTimeLock); + return _lastConnectionTimes; + } void flagTimeForConnectionStep(ConnectionStep connectionStep); udt::Socket::StatsVector sampleStatsForAllConnections() { return _nodeSocket.sampleStatsForAllConnections(); } void setConnectionMaxBandwidth(int maxBandwidth) { _nodeSocket.setConnectionMaxBandwidth(maxBandwidth); } - void setPacketFilterOperator(udt::PacketFilterOperator filterOperator) { _nodeSocket.setPacketFilterOperator(filterOperator); } + void setPacketFilterOperator(udt::PacketFilterOperator filterOperator) { + _nodeSocket.setPacketFilterOperator(filterOperator); + } bool packetVersionMatch(const udt::Packet& packet); bool isPacketVerifiedWithSource(const udt::Packet& packet, Node* sourceNode = nullptr); @@ -328,14 +362,9 @@ public: float getInboundKbps() const { return _inboundKbps; } float getOutboundKbps() const { return _outboundKbps; } - const std::set SOLO_NODE_TYPES = { - NodeType::AvatarMixer, - NodeType::AudioMixer, - NodeType::AssetServer, - NodeType::EntityServer, - NodeType::MessagesMixer, - NodeType::EntityScriptServer - }; + const std::set SOLO_NODE_TYPES = + { NodeType::AvatarMixer, NodeType::AudioMixer, NodeType::AssetServer, + NodeType::EntityServer, NodeType::MessagesMixer, NodeType::EntityScriptServer }; public slots: void reset(); @@ -399,11 +428,10 @@ protected: }; LimitedNodeList(int socketListenPort = INVALID_PORT, int dtlsListenPort = INVALID_PORT); - LimitedNodeList(LimitedNodeList const&) = delete; // Don't implement, needed to avoid copies of singleton - void operator=(LimitedNodeList const&) = delete; // Don't implement, needed to avoid copies of singleton + LimitedNodeList(LimitedNodeList const&) = delete; // Don't implement, needed to avoid copies of singleton + void operator=(LimitedNodeList const&) = delete; // Don't implement, needed to avoid copies of singleton - qint64 sendPacket(std::unique_ptr packet, const Node& destinationNode, - const HifiSockAddr& overridenSockAddr); + qint64 sendPacket(std::unique_ptr packet, const Node& destinationNode, const HifiSockAddr& overridenSockAddr); void fillPacketHeader(const NLPacket& packet, HMACAuth* hmacAuth = nullptr); void setLocalSocket(const HifiSockAddr& sockAddr); @@ -415,7 +443,9 @@ protected: void stopInitialSTUNUpdate(bool success); - void sendPacketToIceServer(PacketType packetType, const HifiSockAddr& iceServerSockAddr, const QUuid& clientID, + void sendPacketToIceServer(PacketType packetType, + const HifiSockAddr& iceServerSockAddr, + const QUuid& clientID, const QUuid& peerRequestID = QUuid()); bool sockAddrBelongsToNode(const HifiSockAddr& sockAddr); @@ -426,14 +456,14 @@ protected: bool isDelayedNode(QUuid nodeUUID); NodeHash _nodeHash; - mutable QReadWriteLock _nodeMutex { QReadWriteLock::Recursive }; + mutable QReadWriteLock _nodeMutex{ QReadWriteLock::Recursive }; udt::Socket _nodeSocket; - QUdpSocket* _dtlsSocket { nullptr }; + QUdpSocket* _dtlsSocket{ nullptr }; HifiSockAddr _localSockAddr; HifiSockAddr _publicSockAddr; - HifiSockAddr _stunSockAddr { STUN_SERVER_HOSTNAME, STUN_SERVER_PORT }; - bool _hasTCPCheckedLocalSocket { false }; - bool _useAuthentication { true }; + HifiSockAddr _stunSockAddr{ STUN_SERVER_HOSTNAME, STUN_SERVER_PORT }; + bool _hasTCPCheckedLocalSocket{ false }; + bool _useAuthentication{ true }; PacketReceiver* _packetReceiver; @@ -446,11 +476,11 @@ protected: quint64 _firstSTUNTime = 0; quint64 _publicSocketUpdateTime = 0; - mutable QReadWriteLock _connectionTimeLock { }; + mutable QReadWriteLock _connectionTimeLock{}; QMap _lastConnectionTimes; bool _areConnectionTimesComplete = false; - template + template void eachNodeHashIterator(IteratorLambda functor) { QWriteLocker writeLock(&_nodeMutex); NodeHash::iterator it = _nodeHash.begin(); @@ -461,31 +491,31 @@ protected: } std::unordered_map _connectionIDs; - quint64 _nodeConnectTimestamp { 0 }; - quint64 _nodeDisconnectTimestamp { 0 }; - bool _wasSilentDomainDisconnect { false }; + quint64 _nodeConnectTimestamp{ 0 }; + quint64 _nodeDisconnectTimestamp{ 0 }; + ConnectReason _connectReason { Connect }; private slots: void flagTimeForConnectionStep(ConnectionStep connectionStep, quint64 timestamp); void possiblyTimeoutSTUNAddressLookup(); - void addSTUNHandlerToUnfiltered(); // called once STUN socket known + void addSTUNHandlerToUnfiltered(); // called once STUN socket known private: mutable QReadWriteLock _sessionUUIDLock; QUuid _sessionUUID; using LocalIDMapping = tbb::concurrent_unordered_map; LocalIDMapping _localIDMap; - Node::LocalID _sessionLocalID { 0 }; - bool _flagTimeForConnectionStep { false }; // only keep track in interface + Node::LocalID _sessionLocalID{ 0 }; + bool _flagTimeForConnectionStep{ false }; // only keep track in interface - size_t _maxConnectionRate { DEFAULT_MAX_CONNECTION_RATE }; - size_t _nodesAddedInCurrentTimeSlice { 0 }; + size_t _maxConnectionRate{ DEFAULT_MAX_CONNECTION_RATE }; + size_t _nodesAddedInCurrentTimeSlice{ 0 }; std::vector _delayedNodeAdds; - int _inboundPPS { 0 }; - int _outboundPPS { 0 }; - float _inboundKbps { 0.0f }; - float _outboundKbps { 0.0f }; + int _inboundPPS{ 0 }; + int _outboundPPS{ 0 }; + float _inboundKbps{ 0.0f }; + float _outboundKbps{ 0.0f }; }; -#endif // hifi_LimitedNodeList_h +#endif // hifi_LimitedNodeList_h diff --git a/libraries/networking/src/NodeList.cpp b/libraries/networking/src/NodeList.cpp index fa3c40b138..1f933920eb 100644 --- a/libraries/networking/src/NodeList.cpp +++ b/libraries/networking/src/NodeList.cpp @@ -113,8 +113,7 @@ NodeList::NodeList(char newOwnerType, int socketListenPort, int dtlsListenPort) connect(&_domainHandler, SIGNAL(connectedToDomain(QUrl)), &_keepAlivePingTimer, SLOT(start())); connect(&_domainHandler, &DomainHandler::disconnectedFromDomain, &_keepAlivePingTimer, &QTimer::stop); - connect(&_domainHandler, &DomainHandler::limitOfSilentDomainCheckInsReached, - this, [this]() {_wasSilentDomainDisconnect = true; }); + connect(&_domainHandler, &DomainHandler::limitOfSilentDomainCheckInsReached, this, [this]() { _connectReason = LimitedNodeList::SilentDomainDisconnect; }); // set our sockAddrBelongsToDomainOrNode method as the connection creation filter for the udt::Socket using std::placeholders::_1; @@ -418,7 +417,7 @@ void NodeList::sendDomainServerCheckIn() { auto accountManager = DependencyManager::get(); packetStream << FingerprintUtils::getMachineFingerprint(); - packetStream << quint32(_wasSilentDomainDisconnect ? 1 : 0); + packetStream << _connectReason; if (_nodeDisconnectTimestamp < _nodeConnectTimestamp) { _nodeDisconnectTimestamp = usecTimestampNow(); @@ -683,7 +682,7 @@ void NodeList::processDomainServerList(QSharedPointer message) if (newConnection) { _nodeConnectTimestamp = usecTimestampNow(); - _wasSilentDomainDisconnect = false; + _connectReason = Connect; } qint64 pingLagTime = (now - qint64(connectRequestTimestamp)) / qint64(USECS_PER_MSEC); diff --git a/libraries/networking/src/udt/PacketHeaders.cpp b/libraries/networking/src/udt/PacketHeaders.cpp index 7ebaf5224f..30066b68e8 100644 --- a/libraries/networking/src/udt/PacketHeaders.cpp +++ b/libraries/networking/src/udt/PacketHeaders.cpp @@ -27,7 +27,7 @@ PacketVersion versionForPacketType(PacketType packetType) { case PacketType::StunResponse: return 17; case PacketType::DomainList: - return static_cast(DomainListVersion::HasTimestamp); + return static_cast(DomainListVersion::HasConnectReason); case PacketType::EntityAdd: case PacketType::EntityClone: case PacketType::EntityEdit: diff --git a/libraries/networking/src/udt/PacketHeaders.h b/libraries/networking/src/udt/PacketHeaders.h index 5baf5448dd..93a5d4e2b4 100644 --- a/libraries/networking/src/udt/PacketHeaders.h +++ b/libraries/networking/src/udt/PacketHeaders.h @@ -366,7 +366,8 @@ enum class DomainListVersion : PacketVersion { GetUsernameFromUUIDSupport, GetMachineFingerprintFromUUIDSupport, AuthenticationOptional, - HasTimestamp + HasTimestamp, + HasConnectReason }; enum class AudioVersion : PacketVersion { From 51c2cc793a173b0ac973d762ee515d65d0888da2 Mon Sep 17 00:00:00 2001 From: Zach Fox Date: Wed, 12 Jun 2019 10:20:54 -0700 Subject: [PATCH 06/24] Tinkering with toolbar visibility signal - not quite working --- interface/resources/qml/hifi/Desktop.qml | 8 ++++++++ libraries/ui/src/OffscreenUi.cpp | 6 ++++++ libraries/ui/src/OffscreenUi.h | 4 +++- libraries/ui/src/ui/ToolbarScriptingInterface.cpp | 5 +++++ libraries/ui/src/ui/ToolbarScriptingInterface.h | 6 ++++++ 5 files changed, 28 insertions(+), 1 deletion(-) diff --git a/interface/resources/qml/hifi/Desktop.qml b/interface/resources/qml/hifi/Desktop.qml index 5fa6234504..64a145b0c5 100644 --- a/interface/resources/qml/hifi/Desktop.qml +++ b/interface/resources/qml/hifi/Desktop.qml @@ -12,6 +12,8 @@ import controlsUit 1.0 OriginalDesktop.Desktop { id: desktop + property alias toolbarObjectName: sysToolbar.objectName + MouseArea { id: hoverWatch anchors.fill: parent @@ -70,7 +72,13 @@ OriginalDesktop.Desktop { x: sysToolbar.x buttonModel: tablet ? tablet.buttons : null; shown: tablet ? tablet.toolbarMode : false; + + onVisibleChanged: { + console.log("ZRF HERE DESKTOP.QML: " + visible); + desktop.toolbarVisibleChanged(visible); + } } + signal toolbarVisibleChanged(bool isVisible); QtSettings.Settings { id: settings; diff --git a/libraries/ui/src/OffscreenUi.cpp b/libraries/ui/src/OffscreenUi.cpp index 1e6a01c187..c39159748d 100644 --- a/libraries/ui/src/OffscreenUi.cpp +++ b/libraries/ui/src/OffscreenUi.cpp @@ -688,6 +688,12 @@ void OffscreenUi::createDesktop(const QUrl& url) { menuInitializer(_vrMenu); } + + QString toolbarName = newObject->property("toolbarObjectName").toString(); // will return "com.highfidelity.interface.toolbar.system" + auto toolbarScriptingInterface = DependencyManager::get(); + _currentToolbarProxy = dynamic_cast(toolbarScriptingInterface->getToolbar(toolbarName)); + connect(_desktop, SIGNAL(toolbarVisibleChanged(bool)), _currentToolbarProxy, SLOT(onToolbarVisibleChanged(bool))); + auto keyboardFocus = new KeyboardFocusHack(); connect(_desktop, SIGNAL(showDesktop()), this, SIGNAL(showDesktop())); emit desktopReady(); diff --git a/libraries/ui/src/OffscreenUi.h b/libraries/ui/src/OffscreenUi.h index 6abbc486d0..67c23ce41e 100644 --- a/libraries/ui/src/OffscreenUi.h +++ b/libraries/ui/src/OffscreenUi.h @@ -24,6 +24,7 @@ #include #include "ui/OffscreenQmlSurface.h" +#include "ui/ToolbarScriptingInterface.h" #include "OffscreenQmlElement.h" class VrMenu; @@ -270,7 +271,8 @@ private: QList _modalDialogListeners; std::unordered_map _pressedKeys; VrMenu* _vrMenu { nullptr }; - QQueue> _queuedMenuInitializers; + QQueue> _queuedMenuInitializers; + ToolbarProxy* _currentToolbarProxy; }; #endif diff --git a/libraries/ui/src/ui/ToolbarScriptingInterface.cpp b/libraries/ui/src/ui/ToolbarScriptingInterface.cpp index d01b538004..ebc22d528b 100644 --- a/libraries/ui/src/ui/ToolbarScriptingInterface.cpp +++ b/libraries/ui/src/ui/ToolbarScriptingInterface.cpp @@ -63,6 +63,11 @@ void ToolbarButtonProxy::editProperties(const QVariantMap& properties) { } } +void ToolbarProxy::onToolbarVisibleChanged(bool isVisible) { + qDebug() << "ZRF HERE IN ENGINE SLOT"; + emit ToolbarProxy::toolbarVisibleChanged(isVisible); +} + ToolbarProxy::ToolbarProxy(QObject* qmlObject, QObject* parent) : QmlWrapper(qmlObject, parent) { Q_ASSERT(QThread::currentThread() == qApp->thread()); } diff --git a/libraries/ui/src/ui/ToolbarScriptingInterface.h b/libraries/ui/src/ui/ToolbarScriptingInterface.h index 409ea28fdc..8ce548f7b6 100644 --- a/libraries/ui/src/ui/ToolbarScriptingInterface.h +++ b/libraries/ui/src/ui/ToolbarScriptingInterface.h @@ -129,6 +129,12 @@ public: * @param {string[]} propertyList * @returns {object} */ + +public slots: + void onToolbarVisibleChanged(bool isVisible); + +signals: + void toolbarVisibleChanged(bool isVisible); }; Q_DECLARE_METATYPE(ToolbarProxy*); From 6e6bd18baad192fec6828ad9eb3900e22ab220c3 Mon Sep 17 00:00:00 2001 From: Roxanne Skelly Date: Wed, 12 Jun 2019 11:43:43 -0700 Subject: [PATCH 07/24] Undo Visual Studio mis-formatting --- domain-server/src/DomainGatekeeper.cpp | 2 +- libraries/networking/src/LimitedNodeList.h | 157 +++++++++------------ 2 files changed, 68 insertions(+), 91 deletions(-) diff --git a/domain-server/src/DomainGatekeeper.cpp b/domain-server/src/DomainGatekeeper.cpp index fee6069c7a..709c5810e2 100644 --- a/domain-server/src/DomainGatekeeper.cpp +++ b/domain-server/src/DomainGatekeeper.cpp @@ -126,7 +126,7 @@ void DomainGatekeeper::processConnectRequestPacket(QSharedPointer #ifndef _WIN32 -#include // not on windows, not needed for mac or windows +#include // not on windows, not needed for mac or windows #endif #include @@ -51,7 +51,7 @@ const int INVALID_PORT = -1; const quint64 NODE_SILENCE_THRESHOLD_MSECS = 10 * 1000; -static const size_t DEFAULT_MAX_CONNECTION_RATE{ std::numeric_limits::max() }; +static const size_t DEFAULT_MAX_CONNECTION_RATE { std::numeric_limits::max() }; const char DEFAULT_ASSIGNMENT_SERVER_HOSTNAME[] = "localhost"; @@ -67,26 +67,26 @@ const QHostAddress DEFAULT_ASSIGNMENT_CLIENT_MONITOR_HOSTNAME = QHostAddress::Lo const QString USERNAME_UUID_REPLACEMENT_STATS_KEY = "$username"; using ConnectionID = int64_t; -const ConnectionID NULL_CONNECTION_ID{ -1 }; -const ConnectionID INITIAL_CONNECTION_ID{ 0 }; +const ConnectionID NULL_CONNECTION_ID { -1 }; +const ConnectionID INITIAL_CONNECTION_ID { 0 }; typedef std::pair UUIDNodePair; typedef tbb::concurrent_unordered_map NodeHash; typedef quint8 PingType_t; namespace PingType { -const PingType_t Agnostic = 0; -const PingType_t Local = 1; -const PingType_t Public = 2; -const PingType_t Symmetric = 3; -} // namespace PingType + const PingType_t Agnostic = 0; + const PingType_t Local = 1; + const PingType_t Public = 2; + const PingType_t Symmetric = 3; +} class LimitedNodeList : public QObject, public Dependency { Q_OBJECT SINGLETON_DEPENDENCY public: - enum ConnectionStep - { + + enum ConnectionStep { LookupAddress = 1, HandleAddress, SendSTUNRequest, @@ -109,8 +109,7 @@ public: Q_ENUM(ConnectionStep); - enum ConnectReason : quint32 - { + enum ConnectReason : quint32 { Connect = 0, SilentDomainDisconnect }; @@ -125,18 +124,12 @@ public: bool isAllowedEditor() const { return _permissions.can(NodePermissions::Permission::canAdjustLocks); } bool getThisNodeCanRez() const { return _permissions.can(NodePermissions::Permission::canRezPermanentEntities); } bool getThisNodeCanRezTmp() const { return _permissions.can(NodePermissions::Permission::canRezTemporaryEntities); } - bool getThisNodeCanRezCertified() const { - return _permissions.can(NodePermissions::Permission::canRezPermanentCertifiedEntities); - } - bool getThisNodeCanRezTmpCertified() const { - return _permissions.can(NodePermissions::Permission::canRezTemporaryCertifiedEntities); - } + bool getThisNodeCanRezCertified() const { return _permissions.can(NodePermissions::Permission::canRezPermanentCertifiedEntities); } + bool getThisNodeCanRezTmpCertified() const { return _permissions.can(NodePermissions::Permission::canRezTemporaryCertifiedEntities); } bool getThisNodeCanWriteAssets() const { return _permissions.can(NodePermissions::Permission::canWriteToAssetServer); } bool getThisNodeCanKick() const { return _permissions.can(NodePermissions::Permission::canKick); } bool getThisNodeCanReplaceContent() const { return _permissions.can(NodePermissions::Permission::canReplaceDomainContent); } - bool getThisNodeCanGetAndSetPrivateUserData() const { - return _permissions.can(NodePermissions::Permission::canGetAndSetPrivateUserData); - } + bool getThisNodeCanGetAndSetPrivateUserData() const { return _permissions.can(NodePermissions::Permission::canGetAndSetPrivateUserData); } quint16 getSocketLocalPort() const { return _nodeSocket.localPort(); } Q_INVOKABLE void setSocketLocalPort(quint16 socketLocalPort); @@ -146,18 +139,9 @@ public: PacketReceiver& getPacketReceiver() { return *_packetReceiver; } virtual bool isDomainServer() const { return true; } - virtual QUuid getDomainUUID() const { - assert(false); - return QUuid(); - } - virtual Node::LocalID getDomainLocalID() const { - assert(false); - return Node::NULL_LOCAL_ID; - } - virtual HifiSockAddr getDomainSockAddr() const { - assert(false); - return HifiSockAddr(); - } + virtual QUuid getDomainUUID() const { assert(false); return QUuid(); } + virtual Node::LocalID getDomainLocalID() const { assert(false); return Node::NULL_LOCAL_ID; } + virtual HifiSockAddr getDomainSockAddr() const { assert(false); return HifiSockAddr(); } // use sendUnreliablePacket to send an unreliable packet (that you do not need to move) // either to a node (via its active socket) or to a manual sockaddr @@ -171,9 +155,8 @@ public: // use sendUnreliableUnorderedPacketList to unreliably send separate packets from the packet list // either to a node's active socket or to a manual sockaddr qint64 sendUnreliableUnorderedPacketList(NLPacketList& packetList, const Node& destinationNode); - qint64 sendUnreliableUnorderedPacketList(NLPacketList& packetList, - const HifiSockAddr& sockAddr, - HMACAuth* hmacAuth = nullptr); + qint64 sendUnreliableUnorderedPacketList(NLPacketList& packetList, const HifiSockAddr& sockAddr, + HMACAuth* hmacAuth = nullptr); // use sendPacketList to send reliable packet lists (ordered or unordered) to a node's active socket // or to a manual sock addr @@ -182,22 +165,15 @@ public: std::function linkedDataCreateCallback; - size_t size() const { - QReadLocker readLock(&_nodeMutex); - return _nodeHash.size(); - } + size_t size() const { QReadLocker readLock(&_nodeMutex); return _nodeHash.size(); } SharedNodePointer nodeWithUUID(const QUuid& nodeUUID); SharedNodePointer nodeWithLocalID(Node::LocalID localID) const; - SharedNodePointer addOrUpdateNode(const QUuid& uuid, - NodeType_t nodeType, - const HifiSockAddr& publicSocket, - const HifiSockAddr& localSocket, - Node::LocalID localID = Node::NULL_LOCAL_ID, - bool isReplicated = false, - bool isUpstream = false, - const QUuid& connectionSecret = QUuid(), + SharedNodePointer addOrUpdateNode(const QUuid& uuid, NodeType_t nodeType, + const HifiSockAddr& publicSocket, const HifiSockAddr& localSocket, + Node::LocalID localID = Node::NULL_LOCAL_ID, bool isReplicated = false, + bool isUpstream = false, const QUuid& connectionSecret = QUuid(), const NodePermissions& permissions = DEFAULT_AGENT_PERMISSIONS); static bool parseSTUNResponse(udt::BasePacket* packet, QHostAddress& newPublicAddress, uint16_t& newPublicPort); @@ -232,7 +208,7 @@ public: // Use this for nested loops instead of taking nested read locks! // This allows multiple threads (i.e. a thread pool) to share a lock // without deadlocking when a dying node attempts to acquire a write lock - template + template void nestedEach(NestedNodeLambda functor, int* lockWaitOut = nullptr, int* nodeTransformOut = nullptr, @@ -252,8 +228,9 @@ public: // so reserve enough memory for the current size // and then back insert all the nodes found nodes.reserve(_nodeHash.size()); - std::transform(_nodeHash.cbegin(), _nodeHash.cend(), std::back_inserter(nodes), - [&](const NodeHash::value_type& it) { return it.second; }); + std::transform(_nodeHash.cbegin(), _nodeHash.cend(), std::back_inserter(nodes), [&](const NodeHash::value_type& it) { + return it.second; + }); endTransform = usecTimestampNow(); if (nodeTransformOut) { @@ -268,7 +245,7 @@ public: } } - template + template void eachNode(NodeLambda functor) { QReadLocker readLock(&_nodeMutex); @@ -277,7 +254,7 @@ public: } } - template + template void eachMatchingNode(PredLambda predicate, NodeLambda functor) { QReadLocker readLock(&_nodeMutex); @@ -288,7 +265,7 @@ public: } } - template + template void eachNodeBreakable(BreakableNodeLambda functor) { QReadLocker readLock(&_nodeMutex); @@ -299,7 +276,7 @@ public: } } - template + template SharedNodePointer nodeMatchingPredicate(const PredLambda predicate) { QReadLocker readLock(&_nodeMutex); @@ -315,7 +292,7 @@ public: // This is unsafe because it does not take a lock // Must only be called when you know that a read lock on the node mutex is held // and will be held for the duration of your iteration - template + template void unsafeEachNode(NodeLambda functor) { for (NodeHash::const_iterator it = _nodeHash.cbegin(); it != _nodeHash.cend(); ++it) { functor(it->second); @@ -325,19 +302,15 @@ public: void putLocalPortIntoSharedMemory(const QString key, QObject* parent, quint16 localPort); bool getLocalServerPortFromSharedMemory(const QString key, quint16& localPort); - const QMap getLastConnectionTimes() const { - QReadLocker readLock(&_connectionTimeLock); - return _lastConnectionTimes; - } + const QMap getLastConnectionTimes() const + { QReadLocker readLock(&_connectionTimeLock); return _lastConnectionTimes; } void flagTimeForConnectionStep(ConnectionStep connectionStep); udt::Socket::StatsVector sampleStatsForAllConnections() { return _nodeSocket.sampleStatsForAllConnections(); } void setConnectionMaxBandwidth(int maxBandwidth) { _nodeSocket.setConnectionMaxBandwidth(maxBandwidth); } - void setPacketFilterOperator(udt::PacketFilterOperator filterOperator) { - _nodeSocket.setPacketFilterOperator(filterOperator); - } + void setPacketFilterOperator(udt::PacketFilterOperator filterOperator) { _nodeSocket.setPacketFilterOperator(filterOperator); } bool packetVersionMatch(const udt::Packet& packet); bool isPacketVerifiedWithSource(const udt::Packet& packet, Node* sourceNode = nullptr); @@ -362,9 +335,14 @@ public: float getInboundKbps() const { return _inboundKbps; } float getOutboundKbps() const { return _outboundKbps; } - const std::set SOLO_NODE_TYPES = - { NodeType::AvatarMixer, NodeType::AudioMixer, NodeType::AssetServer, - NodeType::EntityServer, NodeType::MessagesMixer, NodeType::EntityScriptServer }; + const std::set SOLO_NODE_TYPES = { + NodeType::AvatarMixer, + NodeType::AudioMixer, + NodeType::AssetServer, + NodeType::EntityServer, + NodeType::MessagesMixer, + NodeType::EntityScriptServer + }; public slots: void reset(); @@ -428,10 +406,11 @@ protected: }; LimitedNodeList(int socketListenPort = INVALID_PORT, int dtlsListenPort = INVALID_PORT); - LimitedNodeList(LimitedNodeList const&) = delete; // Don't implement, needed to avoid copies of singleton - void operator=(LimitedNodeList const&) = delete; // Don't implement, needed to avoid copies of singleton + LimitedNodeList(LimitedNodeList const&) = delete; // Don't implement, needed to avoid copies of singleton + void operator=(LimitedNodeList const&) = delete; // Don't implement, needed to avoid copies of singleton - qint64 sendPacket(std::unique_ptr packet, const Node& destinationNode, const HifiSockAddr& overridenSockAddr); + qint64 sendPacket(std::unique_ptr packet, const Node& destinationNode, + const HifiSockAddr& overridenSockAddr); void fillPacketHeader(const NLPacket& packet, HMACAuth* hmacAuth = nullptr); void setLocalSocket(const HifiSockAddr& sockAddr); @@ -443,9 +422,7 @@ protected: void stopInitialSTUNUpdate(bool success); - void sendPacketToIceServer(PacketType packetType, - const HifiSockAddr& iceServerSockAddr, - const QUuid& clientID, + void sendPacketToIceServer(PacketType packetType, const HifiSockAddr& iceServerSockAddr, const QUuid& clientID, const QUuid& peerRequestID = QUuid()); bool sockAddrBelongsToNode(const HifiSockAddr& sockAddr); @@ -456,14 +433,14 @@ protected: bool isDelayedNode(QUuid nodeUUID); NodeHash _nodeHash; - mutable QReadWriteLock _nodeMutex{ QReadWriteLock::Recursive }; + mutable QReadWriteLock _nodeMutex { QReadWriteLock::Recursive }; udt::Socket _nodeSocket; - QUdpSocket* _dtlsSocket{ nullptr }; + QUdpSocket* _dtlsSocket { nullptr }; HifiSockAddr _localSockAddr; HifiSockAddr _publicSockAddr; - HifiSockAddr _stunSockAddr{ STUN_SERVER_HOSTNAME, STUN_SERVER_PORT }; - bool _hasTCPCheckedLocalSocket{ false }; - bool _useAuthentication{ true }; + HifiSockAddr _stunSockAddr { STUN_SERVER_HOSTNAME, STUN_SERVER_PORT }; + bool _hasTCPCheckedLocalSocket { false }; + bool _useAuthentication { true }; PacketReceiver* _packetReceiver; @@ -476,11 +453,11 @@ protected: quint64 _firstSTUNTime = 0; quint64 _publicSocketUpdateTime = 0; - mutable QReadWriteLock _connectionTimeLock{}; + mutable QReadWriteLock _connectionTimeLock { }; QMap _lastConnectionTimes; bool _areConnectionTimesComplete = false; - template + template void eachNodeHashIterator(IteratorLambda functor) { QWriteLocker writeLock(&_nodeMutex); NodeHash::iterator it = _nodeHash.begin(); @@ -498,24 +475,24 @@ protected: private slots: void flagTimeForConnectionStep(ConnectionStep connectionStep, quint64 timestamp); void possiblyTimeoutSTUNAddressLookup(); - void addSTUNHandlerToUnfiltered(); // called once STUN socket known + void addSTUNHandlerToUnfiltered(); // called once STUN socket known private: mutable QReadWriteLock _sessionUUIDLock; QUuid _sessionUUID; using LocalIDMapping = tbb::concurrent_unordered_map; LocalIDMapping _localIDMap; - Node::LocalID _sessionLocalID{ 0 }; - bool _flagTimeForConnectionStep{ false }; // only keep track in interface + Node::LocalID _sessionLocalID { 0 }; + bool _flagTimeForConnectionStep { false }; // only keep track in interface - size_t _maxConnectionRate{ DEFAULT_MAX_CONNECTION_RATE }; - size_t _nodesAddedInCurrentTimeSlice{ 0 }; + size_t _maxConnectionRate { DEFAULT_MAX_CONNECTION_RATE }; + size_t _nodesAddedInCurrentTimeSlice { 0 }; std::vector _delayedNodeAdds; - int _inboundPPS{ 0 }; - int _outboundPPS{ 0 }; - float _inboundKbps{ 0.0f }; - float _outboundKbps{ 0.0f }; + int _inboundPPS { 0 }; + int _outboundPPS { 0 }; + float _inboundKbps { 0.0f }; + float _outboundKbps { 0.0f }; }; -#endif // hifi_LimitedNodeList_h +#endif // hifi_LimitedNodeList_h From ca0c9e236bd8f1d41589369574e7de7b47f68eca Mon Sep 17 00:00:00 2001 From: Roxanne Skelly Date: Wed, 12 Jun 2019 11:58:26 -0700 Subject: [PATCH 08/24] Cleanup --- libraries/networking/src/NodeList.cpp | 1 + libraries/networking/src/udt/Socket.cpp | 10 +++------- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/libraries/networking/src/NodeList.cpp b/libraries/networking/src/NodeList.cpp index 1f933920eb..86b33bbe20 100644 --- a/libraries/networking/src/NodeList.cpp +++ b/libraries/networking/src/NodeList.cpp @@ -452,6 +452,7 @@ void NodeList::sendDomainServerCheckIn() { static const int MAX_CHECKINS_TOGETHER = 20; static const int REBIND_CHECKIN_COUNT = 2; int outstandingCheckins = _domainHandler.getCheckInPacketsSinceLastReply(); + if (outstandingCheckins > REBIND_CHECKIN_COUNT) { _nodeSocket.rebind(); } diff --git a/libraries/networking/src/udt/Socket.cpp b/libraries/networking/src/udt/Socket.cpp index b8e2784017..9871935853 100644 --- a/libraries/networking/src/udt/Socket.cpp +++ b/libraries/networking/src/udt/Socket.cpp @@ -62,9 +62,9 @@ void Socket::bind(const QHostAddress& address, quint16 port) { #elif defined(Q_OS_WIN) auto sd = _udpSocket.socketDescriptor(); int val = 0; // false - if (setsockopt(sd, IPPROTO_IP, IP_DONTFRAGMENT, (const char*)&val, sizeof(val))) { - auto err = WSAGetLastError(); - qCWarning(networking) << "Socket::bind Cannot setsockopt IP_DONTFRAGMENT" << err; + if (setsockopt(sd, IPPROTO_IP, IP_DONTFRAGMENT, (const char *)&val, sizeof(val))) { + auto wsaErr = WSAGetLastError(); + qCWarning(networking) << "Socket::bind Cannot setsockopt IP_DONTFRAGMENT" << wsaErr; } #endif } @@ -234,7 +234,6 @@ qint64 Socket::writeDatagram(const QByteArray& datagram, const HifiSockAddr& soc return -1; } qint64 bytesWritten = _udpSocket.writeDatagram(datagram, sockAddr.getAddress(), sockAddr.getPort()); - int pending = _udpSocket.bytesToWrite(); if (bytesWritten < 0 || pending) { int wsaError = 0; @@ -243,9 +242,6 @@ qint64 Socket::writeDatagram(const QByteArray& datagram, const HifiSockAddr& soc #endif qCDebug(networking) << "udt::writeDatagram (" << _udpSocket.state() << ") error - " << wsaError << _udpSocket.error() << "(" << _udpSocket.errorString() << ")" << (pending ? "pending bytes:" : "pending:") << pending; - - qCDebug(networking) << "udt::writeDatagram (" << _udpSocket.state() << ") error - " << _udpSocket.error() << "(" << _udpSocket.errorString() << ")"; - #ifdef DEBUG_EVENT_QUEUE int nodeListQueueSize = ::hifi::qt::getEventQueueSize(thread()); qCDebug(networking) << "Networking queue size - " << nodeListQueueSize; From fade8f9c043006769e41d8b2aab012a6ef4e01f6 Mon Sep 17 00:00:00 2001 From: Zach Fox Date: Wed, 12 Jun 2019 12:42:58 -0700 Subject: [PATCH 09/24] It works! --- interface/resources/qml/hifi/Desktop.qml | 6 +++--- libraries/ui/src/OffscreenUi.cpp | 3 +-- libraries/ui/src/ui/ToolbarScriptingInterface.cpp | 10 +++++----- libraries/ui/src/ui/ToolbarScriptingInterface.h | 12 ++++++------ 4 files changed, 15 insertions(+), 16 deletions(-) diff --git a/interface/resources/qml/hifi/Desktop.qml b/interface/resources/qml/hifi/Desktop.qml index 64a145b0c5..87647efe3f 100644 --- a/interface/resources/qml/hifi/Desktop.qml +++ b/interface/resources/qml/hifi/Desktop.qml @@ -74,11 +74,11 @@ OriginalDesktop.Desktop { shown: tablet ? tablet.toolbarMode : false; onVisibleChanged: { - console.log("ZRF HERE DESKTOP.QML: " + visible); - desktop.toolbarVisibleChanged(visible); + console.log("ZRF HERE DESKTOP.QML: " + visible + " " + sysToolbar.objectName); + desktop.toolbarVisibleChanged(visible, sysToolbar.objectName); } } - signal toolbarVisibleChanged(bool isVisible); + signal toolbarVisibleChanged(bool isVisible, string toolbarName); QtSettings.Settings { id: settings; diff --git a/libraries/ui/src/OffscreenUi.cpp b/libraries/ui/src/OffscreenUi.cpp index c39159748d..32512e6316 100644 --- a/libraries/ui/src/OffscreenUi.cpp +++ b/libraries/ui/src/OffscreenUi.cpp @@ -691,8 +691,7 @@ void OffscreenUi::createDesktop(const QUrl& url) { QString toolbarName = newObject->property("toolbarObjectName").toString(); // will return "com.highfidelity.interface.toolbar.system" auto toolbarScriptingInterface = DependencyManager::get(); - _currentToolbarProxy = dynamic_cast(toolbarScriptingInterface->getToolbar(toolbarName)); - connect(_desktop, SIGNAL(toolbarVisibleChanged(bool)), _currentToolbarProxy, SLOT(onToolbarVisibleChanged(bool))); + connect(_desktop, SIGNAL(toolbarVisibleChanged(bool, QString)), toolbarScriptingInterface.data(), SLOT(onToolbarVisibleChanged(bool, QString))); auto keyboardFocus = new KeyboardFocusHack(); connect(_desktop, SIGNAL(showDesktop()), this, SIGNAL(showDesktop())); diff --git a/libraries/ui/src/ui/ToolbarScriptingInterface.cpp b/libraries/ui/src/ui/ToolbarScriptingInterface.cpp index ebc22d528b..dc31d08e42 100644 --- a/libraries/ui/src/ui/ToolbarScriptingInterface.cpp +++ b/libraries/ui/src/ui/ToolbarScriptingInterface.cpp @@ -63,11 +63,6 @@ void ToolbarButtonProxy::editProperties(const QVariantMap& properties) { } } -void ToolbarProxy::onToolbarVisibleChanged(bool isVisible) { - qDebug() << "ZRF HERE IN ENGINE SLOT"; - emit ToolbarProxy::toolbarVisibleChanged(isVisible); -} - ToolbarProxy::ToolbarProxy(QObject* qmlObject, QObject* parent) : QmlWrapper(qmlObject, parent) { Q_ASSERT(QThread::currentThread() == qApp->thread()); } @@ -125,3 +120,8 @@ ToolbarProxy* ToolbarScriptingInterface::getToolbar(const QString& toolbarId) { return new ToolbarProxy(rawToolbar); } + +void ToolbarScriptingInterface::onToolbarVisibleChanged(bool isVisible, QString toolbarName) { + qDebug() << "ZRF HERE IN ENGINE SLOT" << isVisible << toolbarName; + emit ToolbarScriptingInterface::toolbarVisibleChanged(isVisible, toolbarName); +} diff --git a/libraries/ui/src/ui/ToolbarScriptingInterface.h b/libraries/ui/src/ui/ToolbarScriptingInterface.h index 8ce548f7b6..8266bb93f2 100644 --- a/libraries/ui/src/ui/ToolbarScriptingInterface.h +++ b/libraries/ui/src/ui/ToolbarScriptingInterface.h @@ -129,12 +129,6 @@ public: * @param {string[]} propertyList * @returns {object} */ - -public slots: - void onToolbarVisibleChanged(bool isVisible); - -signals: - void toolbarVisibleChanged(bool isVisible); }; Q_DECLARE_METATYPE(ToolbarProxy*); @@ -156,6 +150,12 @@ public: * @returns {ToolbarProxy} */ Q_INVOKABLE ToolbarProxy* getToolbar(const QString& toolbarId); + +public slots: + void onToolbarVisibleChanged(bool isVisible, QString toolbarName); + +signals: + void toolbarVisibleChanged(bool isVisible, QString toolbarName); }; From 34e9acc0b5647040a6f5e6282bc432c5c1bd4517 Mon Sep 17 00:00:00 2001 From: Preston Bezos Date: Wed, 12 Jun 2019 14:31:43 -0700 Subject: [PATCH 10/24] better fix for the toolbar remnant --- interface/resources/qml/hifi/Desktop.qml | 1 - libraries/ui/src/OffscreenUi.cpp | 2 +- .../ui/src/ui/ToolbarScriptingInterface.cpp | 7 +------ .../ui/src/ui/ToolbarScriptingInterface.h | 3 --- scripts/simplifiedUI/ui/simplifiedUI.js | 19 +++++++++++++------ 5 files changed, 15 insertions(+), 17 deletions(-) diff --git a/interface/resources/qml/hifi/Desktop.qml b/interface/resources/qml/hifi/Desktop.qml index 87647efe3f..3239471a00 100644 --- a/interface/resources/qml/hifi/Desktop.qml +++ b/interface/resources/qml/hifi/Desktop.qml @@ -74,7 +74,6 @@ OriginalDesktop.Desktop { shown: tablet ? tablet.toolbarMode : false; onVisibleChanged: { - console.log("ZRF HERE DESKTOP.QML: " + visible + " " + sysToolbar.objectName); desktop.toolbarVisibleChanged(visible, sysToolbar.objectName); } } diff --git a/libraries/ui/src/OffscreenUi.cpp b/libraries/ui/src/OffscreenUi.cpp index 32512e6316..0b114a2e3e 100644 --- a/libraries/ui/src/OffscreenUi.cpp +++ b/libraries/ui/src/OffscreenUi.cpp @@ -691,7 +691,7 @@ void OffscreenUi::createDesktop(const QUrl& url) { QString toolbarName = newObject->property("toolbarObjectName").toString(); // will return "com.highfidelity.interface.toolbar.system" auto toolbarScriptingInterface = DependencyManager::get(); - connect(_desktop, SIGNAL(toolbarVisibleChanged(bool, QString)), toolbarScriptingInterface.data(), SLOT(onToolbarVisibleChanged(bool, QString))); + connect(_desktop, SIGNAL(toolbarVisibleChanged(bool, QString)), toolbarScriptingInterface.data(), SIGNAL(toolbarVisibleChanged(bool, QString))); auto keyboardFocus = new KeyboardFocusHack(); connect(_desktop, SIGNAL(showDesktop()), this, SIGNAL(showDesktop())); diff --git a/libraries/ui/src/ui/ToolbarScriptingInterface.cpp b/libraries/ui/src/ui/ToolbarScriptingInterface.cpp index dc31d08e42..7ddc6463c3 100644 --- a/libraries/ui/src/ui/ToolbarScriptingInterface.cpp +++ b/libraries/ui/src/ui/ToolbarScriptingInterface.cpp @@ -119,9 +119,4 @@ ToolbarProxy* ToolbarScriptingInterface::getToolbar(const QString& toolbarId) { } return new ToolbarProxy(rawToolbar); -} - -void ToolbarScriptingInterface::onToolbarVisibleChanged(bool isVisible, QString toolbarName) { - qDebug() << "ZRF HERE IN ENGINE SLOT" << isVisible << toolbarName; - emit ToolbarScriptingInterface::toolbarVisibleChanged(isVisible, toolbarName); -} +} \ No newline at end of file diff --git a/libraries/ui/src/ui/ToolbarScriptingInterface.h b/libraries/ui/src/ui/ToolbarScriptingInterface.h index 8266bb93f2..952d3cce95 100644 --- a/libraries/ui/src/ui/ToolbarScriptingInterface.h +++ b/libraries/ui/src/ui/ToolbarScriptingInterface.h @@ -151,9 +151,6 @@ public: */ Q_INVOKABLE ToolbarProxy* getToolbar(const QString& toolbarId); -public slots: - void onToolbarVisibleChanged(bool isVisible, QString toolbarName); - signals: void toolbarVisibleChanged(bool isVisible, QString toolbarName); }; diff --git a/scripts/simplifiedUI/ui/simplifiedUI.js b/scripts/simplifiedUI/ui/simplifiedUI.js index bafc5fffe1..84ee93ecbf 100644 --- a/scripts/simplifiedUI/ui/simplifiedUI.js +++ b/scripts/simplifiedUI/ui/simplifiedUI.js @@ -457,12 +457,19 @@ function onGeometryChanged(rect) { } } -function ensureFirstPersonCameraInHMD(isHMDMode) { +function onDisplayModeChanged(isHMDMode) { if (isHMDMode) { Camera.setModeString("first person"); } } +function onToolbarVisibleChanged(isVisible, toolbarName) { + var toolbar = Toolbars.getToolbar(toolbarName); + if (isVisible) { + toolbar.writeProperty("visible", false); + } +} + function onStatusChanged() { sendLocalStatusToQml(); @@ -505,11 +512,12 @@ function startup() { updateOutputDeviceMutedOverlay(isOutputMuted()); Audio.mutedDesktopChanged.connect(onDesktopInputDeviceMutedChanged); Window.geometryChanged.connect(onGeometryChanged); - HMD.displayModeChanged.connect(ensureFirstPersonCameraInHMD); + HMD.displayModeChanged.connect(onDisplayModeChanged); Audio.avatarGainChanged.connect(maybeUpdateOutputDeviceMutedOverlay); Audio.localInjectorGainChanged.connect(maybeUpdateOutputDeviceMutedOverlay); Audio.serverInjectorGainChanged.connect(maybeUpdateOutputDeviceMutedOverlay); Audio.systemInjectorGainChanged.connect(maybeUpdateOutputDeviceMutedOverlay); + Toolbars.toolbarVisibleChanged.connect(onToolbarVisibleChanged); oldShowAudioTools = AvatarInputs.showAudioTools; AvatarInputs.showAudioTools = false; @@ -535,9 +543,7 @@ function shutdown() { if (!HMD.active) { var toolbar = Toolbars.getToolbar(TOOLBAR_NAME); - if (toolbar) { - toolbar.writeProperty("visible", true); - } + toolbar.writeProperty("visible", true); } } @@ -561,11 +567,12 @@ function shutdown() { Audio.mutedDesktopChanged.disconnect(onDesktopInputDeviceMutedChanged); Window.geometryChanged.disconnect(onGeometryChanged); - HMD.displayModeChanged.disconnect(ensureFirstPersonCameraInHMD); + HMD.displayModeChanged.disconnect(onDisplayModeChanged); Audio.avatarGainChanged.disconnect(maybeUpdateOutputDeviceMutedOverlay); Audio.localInjectorGainChanged.disconnect(maybeUpdateOutputDeviceMutedOverlay); Audio.serverInjectorGainChanged.disconnect(maybeUpdateOutputDeviceMutedOverlay); Audio.systemInjectorGainChanged.disconnect(maybeUpdateOutputDeviceMutedOverlay); + Toolbars.toolbarVisibleChanged.disconnect(onToolbarVisibleChanged); AvatarInputs.showAudioTools = oldShowAudioTools; AvatarInputs.showBubbleTools = oldShowBubbleTools; From 8fa80f89350d525e6f0d774041be6efed9108f81 Mon Sep 17 00:00:00 2001 From: Preston Bezos Date: Wed, 12 Jun 2019 14:57:37 -0700 Subject: [PATCH 11/24] fixed some formatting problems --- scripts/simplifiedUI/ui/simplifiedUI.js | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/scripts/simplifiedUI/ui/simplifiedUI.js b/scripts/simplifiedUI/ui/simplifiedUI.js index 91d8096881..84ee93ecbf 100644 --- a/scripts/simplifiedUI/ui/simplifiedUI.js +++ b/scripts/simplifiedUI/ui/simplifiedUI.js @@ -457,19 +457,9 @@ function onGeometryChanged(rect) { } } -<<<<<<< HEAD -======= -var TIMEOUT_BEFORE_REHIDE_TOOLBAR_MS = 700; ->>>>>>> f360adccbc827bb52dc4a73ebe2c6890e8be039e function onDisplayModeChanged(isHMDMode) { if (isHMDMode) { Camera.setModeString("first person"); - } else if (Settings.getValue("simplifiedUI/keepExistingUIAndScripts", false)) { - // works for now, but not a permanent fix by any means. - Script.setTimeout(function () { - var toolbar = Toolbars.getToolbar(TOOLBAR_NAME); - toolbar.writeProperty("visible", false); - }, TIMEOUT_BEFORE_REHIDE_TOOLBAR_MS); } } From 29d795af5b3b48982141e13e08a1848cfde5f05f Mon Sep 17 00:00:00 2001 From: Preston Bezos Date: Wed, 12 Jun 2019 15:36:20 -0700 Subject: [PATCH 12/24] hopefully good now --- libraries/ui/src/OffscreenUi.cpp | 1 + libraries/ui/src/OffscreenUi.h | 2 -- libraries/ui/src/ui/ToolbarScriptingInterface.cpp | 2 +- scripts/simplifiedUI/ui/simplifiedUI.js | 8 +++++--- 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/libraries/ui/src/OffscreenUi.cpp b/libraries/ui/src/OffscreenUi.cpp index 0b114a2e3e..e49ee811e0 100644 --- a/libraries/ui/src/OffscreenUi.cpp +++ b/libraries/ui/src/OffscreenUi.cpp @@ -27,6 +27,7 @@ #include "VrMenu.h" #include "ui/Logging.h" +#include "ui/ToolbarScriptingInterface.h" #include #include "MainWindow.h" diff --git a/libraries/ui/src/OffscreenUi.h b/libraries/ui/src/OffscreenUi.h index 67c23ce41e..13326f8c2d 100644 --- a/libraries/ui/src/OffscreenUi.h +++ b/libraries/ui/src/OffscreenUi.h @@ -24,7 +24,6 @@ #include #include "ui/OffscreenQmlSurface.h" -#include "ui/ToolbarScriptingInterface.h" #include "OffscreenQmlElement.h" class VrMenu; @@ -272,7 +271,6 @@ private: std::unordered_map _pressedKeys; VrMenu* _vrMenu { nullptr }; QQueue> _queuedMenuInitializers; - ToolbarProxy* _currentToolbarProxy; }; #endif diff --git a/libraries/ui/src/ui/ToolbarScriptingInterface.cpp b/libraries/ui/src/ui/ToolbarScriptingInterface.cpp index 7ddc6463c3..d01b538004 100644 --- a/libraries/ui/src/ui/ToolbarScriptingInterface.cpp +++ b/libraries/ui/src/ui/ToolbarScriptingInterface.cpp @@ -119,4 +119,4 @@ ToolbarProxy* ToolbarScriptingInterface::getToolbar(const QString& toolbarId) { } return new ToolbarProxy(rawToolbar); -} \ No newline at end of file +} diff --git a/scripts/simplifiedUI/ui/simplifiedUI.js b/scripts/simplifiedUI/ui/simplifiedUI.js index 84ee93ecbf..73b3d14fec 100644 --- a/scripts/simplifiedUI/ui/simplifiedUI.js +++ b/scripts/simplifiedUI/ui/simplifiedUI.js @@ -464,8 +464,8 @@ function onDisplayModeChanged(isHMDMode) { } function onToolbarVisibleChanged(isVisible, toolbarName) { - var toolbar = Toolbars.getToolbar(toolbarName); - if (isVisible) { + if (isVisible && toolbarName == TOOLBAR_NAME) { + var toolbar = Toolbars.getToolbar(toolbarName); toolbar.writeProperty("visible", false); } } @@ -497,7 +497,9 @@ function startup() { if (!HMD.active) { var toolbar = Toolbars.getToolbar(TOOLBAR_NAME); - toolbar.writeProperty("visible", false); + if (toolbar) { + toolbar.writeProperty("visible", false); + } } } From 8dcf6e6a036d74af7707dd19600e879deb2a1f74 Mon Sep 17 00:00:00 2001 From: Preston Bezos Date: Wed, 12 Jun 2019 15:47:19 -0700 Subject: [PATCH 13/24] removed a dead line of code, made a couple formating changes --- libraries/ui/src/OffscreenUi.cpp | 1 - libraries/ui/src/OffscreenUi.h | 2 +- scripts/simplifiedUI/ui/simplifiedUI.js | 4 +++- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/libraries/ui/src/OffscreenUi.cpp b/libraries/ui/src/OffscreenUi.cpp index e49ee811e0..f0b27904ae 100644 --- a/libraries/ui/src/OffscreenUi.cpp +++ b/libraries/ui/src/OffscreenUi.cpp @@ -690,7 +690,6 @@ void OffscreenUi::createDesktop(const QUrl& url) { } - QString toolbarName = newObject->property("toolbarObjectName").toString(); // will return "com.highfidelity.interface.toolbar.system" auto toolbarScriptingInterface = DependencyManager::get(); connect(_desktop, SIGNAL(toolbarVisibleChanged(bool, QString)), toolbarScriptingInterface.data(), SIGNAL(toolbarVisibleChanged(bool, QString))); diff --git a/libraries/ui/src/OffscreenUi.h b/libraries/ui/src/OffscreenUi.h index 13326f8c2d..6abbc486d0 100644 --- a/libraries/ui/src/OffscreenUi.h +++ b/libraries/ui/src/OffscreenUi.h @@ -270,7 +270,7 @@ private: QList _modalDialogListeners; std::unordered_map _pressedKeys; VrMenu* _vrMenu { nullptr }; - QQueue> _queuedMenuInitializers; + QQueue> _queuedMenuInitializers; }; #endif diff --git a/scripts/simplifiedUI/ui/simplifiedUI.js b/scripts/simplifiedUI/ui/simplifiedUI.js index 73b3d14fec..45dd02dc2a 100644 --- a/scripts/simplifiedUI/ui/simplifiedUI.js +++ b/scripts/simplifiedUI/ui/simplifiedUI.js @@ -466,7 +466,9 @@ function onDisplayModeChanged(isHMDMode) { function onToolbarVisibleChanged(isVisible, toolbarName) { if (isVisible && toolbarName == TOOLBAR_NAME) { var toolbar = Toolbars.getToolbar(toolbarName); - toolbar.writeProperty("visible", false); + if (toolbar) { + toolbar.writeProperty("visible", false); + } } } From 3cd3f1a508f2c3acdaa9b345eb24bbf3be0a32f2 Mon Sep 17 00:00:00 2001 From: Preston Bezos Date: Wed, 12 Jun 2019 15:56:27 -0700 Subject: [PATCH 14/24] one last fix --- scripts/simplifiedUI/ui/simplifiedUI.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/scripts/simplifiedUI/ui/simplifiedUI.js b/scripts/simplifiedUI/ui/simplifiedUI.js index 45dd02dc2a..428ade8fd6 100644 --- a/scripts/simplifiedUI/ui/simplifiedUI.js +++ b/scripts/simplifiedUI/ui/simplifiedUI.js @@ -547,7 +547,9 @@ function shutdown() { if (!HMD.active) { var toolbar = Toolbars.getToolbar(TOOLBAR_NAME); - toolbar.writeProperty("visible", true); + if (toolbar) { + toolbar.writeProperty("visible", true); + } } } From 2eeec3518d860ab34a34bdbebe97e36402ee62be Mon Sep 17 00:00:00 2001 From: Preston Bezos Date: Wed, 12 Jun 2019 16:03:03 -0700 Subject: [PATCH 15/24] one last fix --- scripts/simplifiedUI/ui/simplifiedUI.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/simplifiedUI/ui/simplifiedUI.js b/scripts/simplifiedUI/ui/simplifiedUI.js index 428ade8fd6..da37038c28 100644 --- a/scripts/simplifiedUI/ui/simplifiedUI.js +++ b/scripts/simplifiedUI/ui/simplifiedUI.js @@ -464,7 +464,7 @@ function onDisplayModeChanged(isHMDMode) { } function onToolbarVisibleChanged(isVisible, toolbarName) { - if (isVisible && toolbarName == TOOLBAR_NAME) { + if (isVisible && toolbarName == TOOLBAR_NAME && Settings.getValue("simplifiedUI/keepExistingUIAndScripts", false)) { var toolbar = Toolbars.getToolbar(toolbarName); if (toolbar) { toolbar.writeProperty("visible", false); From eee52deefeb32e1db3c3799141a052641f08dffd Mon Sep 17 00:00:00 2001 From: Andrew Meadows Date: Wed, 12 Jun 2019 16:07:15 -0700 Subject: [PATCH 16/24] destroy WebSurfaces on shutdown --- interface/src/Application.cpp | 1 + .../src/EntityTreeRenderer.cpp | 28 +++++++++++++------ .../src/RenderableWebEntityItem.cpp | 20 +++++++------ .../src/RenderableWebEntityItem.h | 1 + libraries/entities/src/WebEntityItem.cpp | 2 +- 5 files changed, 34 insertions(+), 18 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 2f9a151c2f..f9470782bf 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -2708,6 +2708,7 @@ void Application::cleanupBeforeQuit() { } getEntities()->shutdown(); // tell the entities system we're shutting down, so it will stop running scripts + getEntities()->clear(); // Clear any queued processing (I/O, FBX/OBJ/Texture parsing) QThreadPool::globalInstance()->clear(); diff --git a/libraries/entities-renderer/src/EntityTreeRenderer.cpp b/libraries/entities-renderer/src/EntityTreeRenderer.cpp index 1ecbcb0c8b..8671b3da7e 100644 --- a/libraries/entities-renderer/src/EntityTreeRenderer.cpp +++ b/libraries/entities-renderer/src/EntityTreeRenderer.cpp @@ -256,18 +256,28 @@ void EntityTreeRenderer::clear() { } // reset the engine - if (_wantScripts && !_shuttingDown) { - resetEntitiesScriptEngine(); - } - // remove all entities from the scene auto scene = _viewState->getMain3DScene(); - if (scene) { - for (const auto& entry : _entitiesInScene) { - const auto& renderer = entry.second; - fadeOutRenderable(renderer); + if (_shuttingDown) { + if (scene) { + render::Transaction transaction; + for (const auto& entry : _entitiesInScene) { + const auto& renderer = entry.second; + renderer->removeFromScene(scene, transaction); + } + scene->enqueueTransaction(transaction); } } else { - qCWarning(entitiesrenderer) << "EntitityTreeRenderer::clear(), Unexpected null scene, possibly during application shutdown"; + if (_wantScripts) { + resetEntitiesScriptEngine(); + } + if (scene) { + for (const auto& entry : _entitiesInScene) { + const auto& renderer = entry.second; + fadeOutRenderable(renderer); + } + } else { + qCWarning(entitiesrenderer) << "EntitityTreeRenderer::clear(), Unexpected null scene"; + } } _entitiesInScene.clear(); _renderablesToUpdate.clear(); diff --git a/libraries/entities-renderer/src/RenderableWebEntityItem.cpp b/libraries/entities-renderer/src/RenderableWebEntityItem.cpp index 3b615ba467..3334a958f3 100644 --- a/libraries/entities-renderer/src/RenderableWebEntityItem.cpp +++ b/libraries/entities-renderer/src/RenderableWebEntityItem.cpp @@ -7,6 +7,7 @@ // #include "RenderableWebEntityItem.h" +#include #include #include @@ -46,7 +47,7 @@ static uint64_t MAX_NO_RENDER_INTERVAL = 30 * USECS_PER_SECOND; static uint8_t YOUTUBE_MAX_FPS = 30; // Don't allow more than 20 concurrent web views -static uint32_t _currentWebCount { 0 }; +static std::atomic _currentWebCount(0); static const uint32_t MAX_CONCURRENT_WEB_VIEWS = 20; static QTouchDevice _touchDevice; @@ -356,16 +357,15 @@ void WebEntityRenderer::buildWebSurface(const EntityItemPointer& entity, const Q void WebEntityRenderer::destroyWebSurface() { QSharedPointer webSurface; - ContentType contentType = ContentType::NoContent; withWriteLock([&] { webSurface.swap(_webSurface); - _contentType = contentType; - }); + _contentType = ContentType::NoContent; - if (webSurface) { - --_currentWebCount; - WebEntityRenderer::releaseWebSurface(webSurface, _cachedWebSurface, _connections); - } + if (webSurface) { + --_currentWebCount; + WebEntityRenderer::releaseWebSurface(webSurface, _cachedWebSurface, _connections); + } + }); } glm::vec2 WebEntityRenderer::getWindowSize(const TypedEntityPointer& entity) const { @@ -469,6 +469,10 @@ void WebEntityRenderer::handlePointerEventAsMouse(const PointerEvent& event) { QCoreApplication::sendEvent(_webSurface->getWindow(), &mouseEvent); } +void WebEntityRenderer::onRemoveFromSceneTyped(const TypedEntityPointer& entity) { + destroyWebSurface(); +} + void WebEntityRenderer::setProxyWindow(QWindow* proxyWindow) { withReadLock([&] { if (_webSurface) { diff --git a/libraries/entities-renderer/src/RenderableWebEntityItem.h b/libraries/entities-renderer/src/RenderableWebEntityItem.h index 7118774d30..6cda1601c8 100644 --- a/libraries/entities-renderer/src/RenderableWebEntityItem.h +++ b/libraries/entities-renderer/src/RenderableWebEntityItem.h @@ -64,6 +64,7 @@ protected: void handlePointerEventAsTouch(const PointerEvent& event); void handlePointerEventAsMouse(const PointerEvent& event); + void onRemoveFromSceneTyped(const TypedEntityPointer& entity) override; private: void onTimeout(); void buildWebSurface(const EntityItemPointer& entity, const QString& newSourceURL); diff --git a/libraries/entities/src/WebEntityItem.cpp b/libraries/entities/src/WebEntityItem.cpp index 0748790df9..b40de7e42a 100644 --- a/libraries/entities/src/WebEntityItem.cpp +++ b/libraries/entities/src/WebEntityItem.cpp @@ -343,4 +343,4 @@ PulsePropertyGroup WebEntityItem::getPulseProperties() const { return resultWithReadLock([&] { return _pulseProperties; }); -} \ No newline at end of file +} From e32d6e96ce67b01a2b2627a0e3e5c4e5e146a17d Mon Sep 17 00:00:00 2001 From: Preston Bezos Date: Wed, 12 Jun 2019 16:12:24 -0700 Subject: [PATCH 17/24] code was backwards --- scripts/simplifiedUI/ui/simplifiedUI.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/simplifiedUI/ui/simplifiedUI.js b/scripts/simplifiedUI/ui/simplifiedUI.js index da37038c28..16f081fb6b 100644 --- a/scripts/simplifiedUI/ui/simplifiedUI.js +++ b/scripts/simplifiedUI/ui/simplifiedUI.js @@ -464,7 +464,7 @@ function onDisplayModeChanged(isHMDMode) { } function onToolbarVisibleChanged(isVisible, toolbarName) { - if (isVisible && toolbarName == TOOLBAR_NAME && Settings.getValue("simplifiedUI/keepExistingUIAndScripts", false)) { + if (isVisible && toolbarName == TOOLBAR_NAME && !Settings.getValue("simplifiedUI/keepExistingUIAndScripts", false)) { var toolbar = Toolbars.getToolbar(toolbarName); if (toolbar) { toolbar.writeProperty("visible", false); From 20b17291b41e4ff11943a502e2caff35f10bdca6 Mon Sep 17 00:00:00 2001 From: luiscuenca Date: Thu, 13 Jun 2019 09:05:55 -0700 Subject: [PATCH 18/24] Reset detailed motion states when the workload zone changes --- interface/src/avatar/AvatarManager.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interface/src/avatar/AvatarManager.cpp b/interface/src/avatar/AvatarManager.cpp index bb8b7ba7f4..efe3d59d90 100755 --- a/interface/src/avatar/AvatarManager.cpp +++ b/interface/src/avatar/AvatarManager.cpp @@ -490,7 +490,7 @@ void AvatarManager::buildPhysicsTransaction(PhysicsEngine::Transaction& transact _myAvatar->getCharacterController()->buildPhysicsTransaction(transaction); for (auto avatar : _otherAvatarsToChangeInPhysics) { bool isInPhysics = avatar->isInPhysicsSimulation(); - if (isInPhysics != avatar->shouldBeInPhysicsSimulation()) { + if (isInPhysics != avatar->shouldBeInPhysicsSimulation() || avatar->_needsReinsertion) { if (isInPhysics) { transaction.objectsToRemove.push_back(avatar->_motionState); avatar->_motionState = nullptr; From 667af8575fc53ad54e46db56d038d00901858abf Mon Sep 17 00:00:00 2001 From: dante ruiz Date: Thu, 13 Jun 2019 10:03:46 -0700 Subject: [PATCH 19/24] add bookmark arg and fixing focus --- launchers/darwin/src/Launcher.m | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/launchers/darwin/src/Launcher.m b/launchers/darwin/src/Launcher.m index f586269864..d60c4080a2 100644 --- a/launchers/darwin/src/Launcher.m +++ b/launchers/darwin/src/Launcher.m @@ -46,6 +46,7 @@ static BOOL const DELETE_ZIP_FILES = TRUE; } -(void)awakeFromNib { + [[NSApplication sharedApplication] activateIgnoringOtherApps:TRUE]; [[[NSWorkspace sharedWorkspace] notificationCenter] addObserver:self selector:@selector(didTerminateApp:) name:NSWorkspaceDidTerminateApplicationNotification @@ -114,6 +115,7 @@ static BOOL const DELETE_ZIP_FILES = TRUE; userInfo:nil repeats:NO]; } + [[NSApplication sharedApplication] activateIgnoringOtherApps:TRUE]; } - (void) setDownloadContextFilename:(NSString *)aFilename @@ -277,6 +279,7 @@ static BOOL const DELETE_ZIP_FILES = TRUE; -(void)onSplashScreenTimerFinished:(NSTimer *)timer { + [[NSApplication sharedApplication] activateIgnoringOtherApps:TRUE]; [self showLoginScreen]; } @@ -336,6 +339,7 @@ static BOOL const DELETE_ZIP_FILES = TRUE; NSString* scriptsPath = [[self getAppPath] stringByAppendingString:@"interface.app/Contents/Resources/scripts/simplifiedUI/"]; NSString* domainUrl = [[Settings sharedSettings] getDomainUrl]; NSString* userToken = [[Launcher sharedLauncher] getTokenString]; + NSString* homeBookmark = [[NSString stringWithFormat:@"hqhome="] stringByAppendingString:domainUrl]; NSArray* arguments; if (userToken != nil) { arguments = [NSArray arrayWithObjects: @@ -344,6 +348,7 @@ static BOOL const DELETE_ZIP_FILES = TRUE; @"--cache", contentPath, @"--displayName", displayName, @"--scripts", scriptsPath, + @"--setBookmark", homeBookmark, @"--no-updater", @"--no-launcher", nil]; } else { @@ -351,6 +356,7 @@ static BOOL const DELETE_ZIP_FILES = TRUE; @"--url" , domainUrl, @"--cache", contentPath, @"--scripts", scriptsPath, + @"--setBookmark", homeBookmark, @"--no-updater", @"--no-launcher", nil]; } From 2a1d5f6a07f064fa59988e9d8f5093bee27467b8 Mon Sep 17 00:00:00 2001 From: luiscuenca Date: Thu, 13 Jun 2019 10:05:34 -0700 Subject: [PATCH 20/24] add bookmark parameter --- launchers/win32/LauncherManager.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/launchers/win32/LauncherManager.cpp b/launchers/win32/LauncherManager.cpp index 35903a0887..fc79287457 100644 --- a/launchers/win32/LauncherManager.cpp +++ b/launchers/win32/LauncherManager.cpp @@ -234,9 +234,10 @@ HWND LauncherManager::launchApplication() { CString parsedTokens = _tokensJSON; parsedTokens.Replace(_T("\""), _T("\\\"")); tokensParam = _T("--tokens \""); - tokensParam += parsedTokens + _T("\""); + tokensParam += parsedTokens + _T("\" "); } - CString params = urlParam + scriptsParam + cacheParam + nameParam + tokensParam + EXTRA_PARAMETERS; + CString bookmarkParam = _T("--setBookmark hqhome=\"") + _domainURL + ("\" "); + CString params = urlParam + scriptsParam + cacheParam + nameParam + tokensParam + bookmarkParam + EXTRA_PARAMETERS; _shouldLaunch = FALSE; return LauncherUtils::executeOnForeground(interfaceExe, params); } From 4ccd7bd808897265d68d712d91782ae3ffb29ef8 Mon Sep 17 00:00:00 2001 From: Zach Fox Date: Thu, 13 Jun 2019 10:17:14 -0700 Subject: [PATCH 21/24] BUGZ-658: Don't let the user switch avatar models to Woody --- .../qml/hifi/simplifiedUI/topBar/SimplifiedTopBar.qml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/interface/resources/qml/hifi/simplifiedUI/topBar/SimplifiedTopBar.qml b/interface/resources/qml/hifi/simplifiedUI/topBar/SimplifiedTopBar.qml index 85b3cf149f..6e86849d03 100644 --- a/interface/resources/qml/hifi/simplifiedUI/topBar/SimplifiedTopBar.qml +++ b/interface/resources/qml/hifi/simplifiedUI/topBar/SimplifiedTopBar.qml @@ -47,6 +47,11 @@ Rectangle { onSkeletonModelURLChanged: { root.updatePreviewUrl(); + + if (MyAvatar.skeletonModelURL.indexOf("defaultAvatar" > -1) && topBarInventoryModel.count > 0) { + Settings.setValue("simplifiedUI/alreadyAutoSelectedAvatar", true); + MyAvatar.skeletonModelURL = topBarInventoryModel.get(0).download_url; + } } } From 289e948d6b2c24fdbf817d2e5daadda1afa23ae3 Mon Sep 17 00:00:00 2001 From: Zach Fox Date: Thu, 13 Jun 2019 10:27:18 -0700 Subject: [PATCH 22/24] BUGZ-671: Make 'Your Profile' Home button go to bookmark 'hqhome' --- .../resources/qml/hifi/simplifiedUI/avatarApp/AvatarApp.qml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interface/resources/qml/hifi/simplifiedUI/avatarApp/AvatarApp.qml b/interface/resources/qml/hifi/simplifiedUI/avatarApp/AvatarApp.qml index 957df6d584..ef9a3cbe24 100644 --- a/interface/resources/qml/hifi/simplifiedUI/avatarApp/AvatarApp.qml +++ b/interface/resources/qml/hifi/simplifiedUI/avatarApp/AvatarApp.qml @@ -122,7 +122,7 @@ Rectangle { Tablet.playSound(TabletEnums.ButtonClick); // Can't use `Window.location` in QML, so just use what setting `Window.location` actually calls under the hood: // AddressManager.handleLookupString(). - AddressManager.handleLookupString(LocationBookmarks.getHomeLocationAddress()); + AddressManager.handleLookupString(LocationBookmarks.getAddress("hqhome")); } } } From b08bb93ff739c13636dab49c72db07cf886cbdfb Mon Sep 17 00:00:00 2001 From: Andrew Meadows Date: Thu, 13 Jun 2019 10:53:55 -0700 Subject: [PATCH 23/24] add comment about why WebEntityRenderer::onRemoveFromSceneTyped() --- libraries/entities-renderer/src/RenderableWebEntityItem.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libraries/entities-renderer/src/RenderableWebEntityItem.cpp b/libraries/entities-renderer/src/RenderableWebEntityItem.cpp index 3334a958f3..5b5fc08460 100644 --- a/libraries/entities-renderer/src/RenderableWebEntityItem.cpp +++ b/libraries/entities-renderer/src/RenderableWebEntityItem.cpp @@ -470,6 +470,8 @@ void WebEntityRenderer::handlePointerEventAsMouse(const PointerEvent& event) { } void WebEntityRenderer::onRemoveFromSceneTyped(const TypedEntityPointer& entity) { + // HACK: destroyWebSurface() here to avoid a crash on shutdown. + // TODO: fix the real problem: EntityRenderer<>::dtor never called on shutdown for smart-pointer resource leak. destroyWebSurface(); } From 1a0002db0cda0a4f2183dc7dbfd7973391c27c63 Mon Sep 17 00:00:00 2001 From: Zach Fox Date: Thu, 13 Jun 2019 13:06:40 -0700 Subject: [PATCH 24/24] BUGZ-676: Remove references to interstitial from SUI version of progress.js --- scripts/simplifiedUI/system/progress.js | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/scripts/simplifiedUI/system/progress.js b/scripts/simplifiedUI/system/progress.js index b373612790..a641dd4556 100644 --- a/scripts/simplifiedUI/system/progress.js +++ b/scripts/simplifiedUI/system/progress.js @@ -83,9 +83,7 @@ // The initial delay cooldown keeps us from tracking progress before the allotted time // has passed. INITIAL_DELAY_COOLDOWN_TIME = 1000, - initialDelayCooldown = 0, - - isInInterstitialMode = false; + initialDelayCooldown = 0; function fade() { @@ -267,7 +265,7 @@ // Update state if (!visible) { // Not visible because no recent downloads - if ((displayProgress < 100 || gpuTextures > 0) && !isInInterstitialMode && !isInterstitialOverlaysVisible) { // Have started downloading so fade in + if (displayProgress < 100 || gpuTextures > 0) { // Have started downloading so fade in visible = true; alphaDelta = ALPHA_DELTA_IN; fadeTimer = Script.setInterval(fade, FADE_INTERVAL); @@ -307,9 +305,6 @@ } else { x = x * BAR_HMD_REPEAT; } - if (isInInterstitialMode || isInterstitialOverlaysVisible) { - visible = false; - } // Update progress bar Overlays.editOverlay(barDesktop.overlay, { @@ -349,10 +344,6 @@ } } - function interstitialModeChanged(inMode) { - isInInterstitialMode = inMode; - } - function setUp() { var is4k = Window.innerWidth > 3000; @@ -378,7 +369,6 @@ } setUp(); - Window.interstitialModeChanged.connect(interstitialModeChanged); GlobalServices.downloadInfoChanged.connect(onDownloadInfoChanged); GlobalServices.updateDownloadInfo(); Script.setInterval(update, 1000 / 60);