mirror of
https://github.com/overte-org/overte.git
synced 2025-08-07 01:39:23 +02:00
Fixed deadlock in Create App
This commit is contained in:
parent
99592e7d85
commit
546d04167f
4 changed files with 18 additions and 4 deletions
|
@ -264,6 +264,7 @@ find_library(V8_ICUI18N_LIBRARY_RELEASE
|
||||||
MESSAGE("V8_ICUI18N_LIBRARY_RELEASE: ${V8_ICUI18N_LIBRARY_RELEASE}")
|
MESSAGE("V8_ICUI18N_LIBRARY_RELEASE: ${V8_ICUI18N_LIBRARY_RELEASE}")
|
||||||
|
|
||||||
# Base build with snapshot
|
# Base build with snapshot
|
||||||
|
MESSAGE("1")
|
||||||
if(MSVC)
|
if(MSVC)
|
||||||
if(V8_LIBRARY_DEBUG AND V8_LIBRARY_RELEASE AND V8_SNAPSHOT_LIBRARY_DEBUG AND V8_SNAPSHOT_LIBRARY_RELEASE)
|
if(V8_LIBRARY_DEBUG AND V8_LIBRARY_RELEASE AND V8_SNAPSHOT_LIBRARY_DEBUG AND V8_SNAPSHOT_LIBRARY_RELEASE)
|
||||||
set(V8_LIBRARY
|
set(V8_LIBRARY
|
||||||
|
@ -280,10 +281,13 @@ if(MSVC)
|
||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
else()
|
else()
|
||||||
if(CMAKE_BUILD_TYPE EQUAL "Debug")
|
MESSAGE("2")
|
||||||
|
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
|
||||||
|
MESSAGE("3")
|
||||||
if(V8_LIBRARY_DEBUG AND V8_PLATFORM_LIBRARY_DEBUG AND V8_SAMPLER_LIBRARY_DEBUG)
|
if(V8_LIBRARY_DEBUG AND V8_PLATFORM_LIBRARY_DEBUG AND V8_SAMPLER_LIBRARY_DEBUG)
|
||||||
set(V8_LIBRARY ${V8_LIBRARY_DEBUG} ${V8_PLATFORM_LIBRARY_DEBUG} ${V8_SAMPLER_LIBRARY_DEBUG}) # ${V8_ICU_LIBRARY_DEBUG})
|
set(V8_LIBRARY ${V8_LIBRARY_DEBUG} ${V8_PLATFORM_LIBRARY_DEBUG} ${V8_SAMPLER_LIBRARY_DEBUG}) # ${V8_ICU_LIBRARY_DEBUG})
|
||||||
elseif(V8_LIBRARY_DEBUG AND V8_PLATFORM_LIBRARY_DEBUG)
|
elseif(V8_LIBRARY_DEBUG AND V8_PLATFORM_LIBRARY_DEBUG)
|
||||||
|
MESSAGE("4")
|
||||||
set(V8_LIBRARY ${V8_LIBRARY_DEBUG} ${V8_PLATFORM_LIBRARY_DEBUG}) # ${V8_SAMPLER_LIBRARY_DEBUG}) # ${V8_ICU_LIBRARY_DEBUG})
|
set(V8_LIBRARY ${V8_LIBRARY_DEBUG} ${V8_PLATFORM_LIBRARY_DEBUG}) # ${V8_SAMPLER_LIBRARY_DEBUG}) # ${V8_ICU_LIBRARY_DEBUG})
|
||||||
else()
|
else()
|
||||||
if(V8_LIBRARY_RELEASE AND V8_PLATFORM_LIBRARY_RELEASE AND V8_SAMPLER_LIBRARY_RELEASE)
|
if(V8_LIBRARY_RELEASE AND V8_PLATFORM_LIBRARY_RELEASE AND V8_SAMPLER_LIBRARY_RELEASE)
|
||||||
|
|
|
@ -21,6 +21,7 @@
|
||||||
#include <QJsonObject>
|
#include <QJsonObject>
|
||||||
#include <QJsonDocument>
|
#include <QJsonDocument>
|
||||||
#include <QJsonArray>
|
#include <QJsonArray>
|
||||||
|
#include <QtWidgets/QApplication>
|
||||||
|
|
||||||
#include <shared/QtHelpers.h>
|
#include <shared/QtHelpers.h>
|
||||||
#include <VariantMapToScriptValue.h>
|
#include <VariantMapToScriptValue.h>
|
||||||
|
@ -1633,12 +1634,15 @@ bool EntityScriptingInterface::queryPropertyMetadata(const QUuid& entityID,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool EntityScriptingInterface::getServerScriptStatus(const QUuid& entityID, const ScriptValue& callback) {
|
//bool EntityScriptingInterface::getServerScriptStatus(const QUuid& entityID, const ScriptValue& callback) {
|
||||||
|
bool EntityScriptingInterface::getServerScriptStatus(const QUuid& entityID, ScriptValue callback) {
|
||||||
auto client = DependencyManager::get<EntityScriptClient>();
|
auto client = DependencyManager::get<EntityScriptClient>();
|
||||||
auto request = client->createScriptStatusRequest(entityID);
|
auto request = client->createScriptStatusRequest(entityID);
|
||||||
|
|
||||||
auto engine = callback.engine();
|
auto engine = callback.engine();
|
||||||
auto manager = engine->manager();
|
auto manager = engine->manager();
|
||||||
|
Q_ASSERT(QThread::currentThread() == engine->thread());
|
||||||
|
Q_ASSERT(QThread::currentThread() == engine->manager()->thread());
|
||||||
if (!manager) {
|
if (!manager) {
|
||||||
engine->raiseException(engine->makeError(engine->newValue("This script does not belong to a ScriptManager")));
|
engine->raiseException(engine->makeError(engine->newValue("This script does not belong to a ScriptManager")));
|
||||||
engine->maybeEmitUncaughtException(__FUNCTION__);
|
engine->maybeEmitUncaughtException(__FUNCTION__);
|
||||||
|
@ -1647,13 +1651,16 @@ bool EntityScriptingInterface::getServerScriptStatus(const QUuid& entityID, cons
|
||||||
|
|
||||||
connect(request, &GetScriptStatusRequest::finished, manager, [callback](GetScriptStatusRequest* request) mutable {
|
connect(request, &GetScriptStatusRequest::finished, manager, [callback](GetScriptStatusRequest* request) mutable {
|
||||||
auto engine = callback.engine();
|
auto engine = callback.engine();
|
||||||
// V8TODO: it seems to sometimes be called on a wrong thread, reading to script engine crashes. I added an assert for now
|
// V8TODO: it seems to sometimes be called on a wrong thread, reading to script engine crashes. I added an assert for now.
|
||||||
|
// V8TODO: somehow the asserts are not happening here, but destructor still runs on main thread sometimes and deadlocks.
|
||||||
Q_ASSERT(QThread::currentThread() == engine->thread());
|
Q_ASSERT(QThread::currentThread() == engine->thread());
|
||||||
Q_ASSERT(QThread::currentThread() == engine->manager()->thread());
|
Q_ASSERT(QThread::currentThread() == engine->manager()->thread());
|
||||||
QString statusString = EntityScriptStatus_::valueToKey(request->getStatus());
|
QString statusString = EntityScriptStatus_::valueToKey(request->getStatus());
|
||||||
ScriptValueList args { engine->newValue(request->getResponseReceived()), engine->newValue(request->getIsRunning()), engine->newValue(statusString.toLower()), engine->newValue(request->getErrorInfo()) };
|
ScriptValueList args { engine->newValue(request->getResponseReceived()), engine->newValue(request->getIsRunning()), engine->newValue(statusString.toLower()), engine->newValue(request->getErrorInfo()) };
|
||||||
callback.call(ScriptValue(), args);
|
callback.call(ScriptValue(), args);
|
||||||
request->deleteLater();
|
request->deleteLater();
|
||||||
|
// This causes ScriptValueProxy to be released, and thus its destructor is called on script engine thread and not main thread
|
||||||
|
callback = ScriptValue();
|
||||||
});
|
});
|
||||||
request->start();
|
request->start();
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -871,7 +871,8 @@ public slots:
|
||||||
* @param {string} errorInfo - <code>""</code> if there is a server entity script running, otherwise it may contain extra
|
* @param {string} errorInfo - <code>""</code> if there is a server entity script running, otherwise it may contain extra
|
||||||
* information on the error.
|
* information on the error.
|
||||||
*/
|
*/
|
||||||
Q_INVOKABLE bool getServerScriptStatus(const QUuid& entityID, const ScriptValue& callback);
|
//Q_INVOKABLE bool getServerScriptStatus(const QUuid& entityID, const ScriptValue& callback);
|
||||||
|
Q_INVOKABLE bool getServerScriptStatus(const QUuid& entityID, ScriptValue callback);
|
||||||
|
|
||||||
/*@jsdoc
|
/*@jsdoc
|
||||||
* Gets metadata for certain entity properties such as <code>script</code> and <code>serverScripts</code>.
|
* Gets metadata for certain entity properties such as <code>script</code> and <code>serverScripts</code>.
|
||||||
|
|
|
@ -20,6 +20,8 @@
|
||||||
|
|
||||||
|
|
||||||
void ScriptValueV8Wrapper::release() {
|
void ScriptValueV8Wrapper::release() {
|
||||||
|
// V8TODO: maybe add an assert to check if it happens on script engine thread?
|
||||||
|
// With v8::Locker in V8ScriptValue such requirement shouldn't be necessary but deleting on different threadwww can cause deadlocks sometimes
|
||||||
delete this;
|
delete this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue