Merge pull request #1 from overte-org/fix/recording_deadlock

Fix recording deadlocks
This commit is contained in:
HifiExperiments 2024-06-06 17:02:15 -07:00 committed by GitHub
commit e351a92310
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
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;