Fix recording deadlocks

This commit is contained in:
Karol Suprynowicz 2024-06-07 01:24:34 +02:00
parent 444d52070a
commit 5ba1fcecb5
2 changed files with 6 additions and 5 deletions

View file

@ -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();
@ -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()) {
@ -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);

View file

@ -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;