Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix stuttering and freezing of client while computing sync state changes (macOS VFS) #7397

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/gui/macOS/fileproviderxpc.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@
* for more details.
*/

#include <QObject>

Check failure on line 15 in src/gui/macOS/fileproviderxpc.h

View workflow job for this annotation

GitHub Actions / build

src/gui/macOS/fileproviderxpc.h:15:10 [clang-diagnostic-error]

'QObject' file not found
#include <QHash>
#include <QDateTime>

#include "accountstate.h"

Expand All @@ -34,7 +35,7 @@
public:
explicit FileProviderXPC(QObject *parent = nullptr);

[[nodiscard]] bool fileProviderExtReachable(const QString &extensionAccountId) const;
[[nodiscard]] bool fileProviderExtReachable(const QString &extensionAccountId);

// Returns enabled and set state of fast enumeration for the given extension
[[nodiscard]] std::optional<std::pair<bool, bool>> fastEnumerationStateForExtension(const QString &extensionAccountId) const;
Expand All @@ -53,6 +54,7 @@

private:
QHash<QString, void*> _clientCommServices;
QHash<QString, QDateTime> _unreachableAccountExtensions;
};

} // namespace OCC::Mac
20 changes: 18 additions & 2 deletions src/gui/macOS/fileproviderxpc_mac.mm
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
#include "gui/macOS/fileproviderxpc_mac_utils.h"

namespace {
constexpr int64_t semaphoreWaitDelta = 3000000000; // 3 seconds
constexpr int64_t semaphoreWaitDelta = 1000000000; // 1 seconds
constexpr auto reachableRetryTimeout = 300; // seconds
}

namespace OCC::Mac {
Expand Down Expand Up @@ -143,19 +144,34 @@
}
}

bool FileProviderXPC::fileProviderExtReachable(const QString &extensionAccountId) const
bool FileProviderXPC::fileProviderExtReachable(const QString &extensionAccountId)
{
const auto lastUnreachableTime = _unreachableAccountExtensions.value(extensionAccountId);
if (lastUnreachableTime.isValid() && lastUnreachableTime.secsTo(QDateTime::currentDateTime()) < ::reachableRetryTimeout) {
qCInfo(lcFileProviderXPC) << "File provider extension was unreachable less than a minute ago. "
<< "Not checking again";
return false;
}

const auto service = (NSObject<ClientCommunicationProtocol> *)_clientCommServices.value(extensionAccountId);
if (service == nil) {
return false;
}

__block auto response = false;
dispatch_semaphore_t semaphore = dispatch_semaphore_create(0);
[service getExtensionAccountIdWithCompletionHandler:^(NSString *const, NSError *const) {
response = true;
dispatch_semaphore_signal(semaphore);
}];
dispatch_semaphore_wait(semaphore, dispatch_time(DISPATCH_TIME_NOW, semaphoreWaitDelta));

if (response) {
_unreachableAccountExtensions.remove(extensionAccountId);
} else {
qCWarning(lcFileProviderXPC) << "Could not reach file provider extension.";
_unreachableAccountExtensions.insert(extensionAccountId, QDateTime::currentDateTime());
}
return response;
}

Expand Down
Loading