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 recording deadlocks #1

Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,10 @@ float RecordingScriptingInterface::playerLength() const {
}

void RecordingScriptingInterface::playClip(NetworkClipLoaderPointer clipLoader, const QString& url, const ScriptValue& callback) {
Locker lock(_mutex);
_player->queueClip(clipLoader->getClip());
{
Locker lock(_mutex);
_player->queueClip(clipLoader->getClip());
}

if (callback.isFunction()) {
auto engine = callback.engine();
Expand All @@ -75,8 +77,6 @@ void RecordingScriptingInterface::playClip(NetworkClipLoaderPointer clipLoader,
}

void RecordingScriptingInterface::loadRecording(const QString& url, const ScriptValue& callback) {
Locker lock(_mutex);

auto clipLoader = DependencyManager::get<recording::ClipCache>()->getClipLoader(url);

if (clipLoader->isLoaded()) {
Expand All @@ -85,6 +85,8 @@ void RecordingScriptingInterface::loadRecording(const QString& url, const Script
return;
}

Locker lock(_mutex);

// hold a strong pointer to the loading clip so that it has a chance to load
_clipLoaders.insert(clipLoader);

Expand Down
1 change: 0 additions & 1 deletion libraries/script-engine/src/AssetScriptingInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,6 @@ Promise AssetScriptingInterface::jsPromiseReady(Promise promise, const ScriptVal
void AssetScriptingInterface::jsCallback(const ScriptValue& handler,
const ScriptValue& error, const ScriptValue& result) {
Q_ASSERT(thread() == QThread::currentThread());
Q_ASSERT(engine());
//V8TODO: which kind of script context guard needs to be used here?
ScriptContextGuard scriptContextGuard(_scriptManager->engine()->currentContext());
auto errorValue = !error.toBool() ? engine()->nullValue() : error;
Expand Down