Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Calling javascript functions via QJSEngine from multiple threads possible?
Forum Updated to NodeBB v4.3 + New Features

Calling javascript functions via QJSEngine from multiple threads possible?

Scheduled Pinned Locked Moved General and Desktop
2 Posts 2 Posters 2.9k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    jimknopf
    wrote on last edited by
    #1

    Hi,

    I am working on a multithreaded application, and I try to use Javascript functions in this application, i.e. the worker threads would evaluate some JS code during their execution. What I found is the following:
    when I use the new QJSEngine (the v8 stuff), and when I try the following (by calling run()), the program crashes:

    @
    QJSEngine *script_engine; // global variable
    function run_func()
    {
    QJSValue result = engine->evaluate("1+1");
    }

    function run()
    {
    script_engine = new QScriptEngine;
    QList<int> jobs;
    for (int i=0;i<100;++i) jobs.append(i);
    qDebug() << "starting jobs...";
    QtConcurrent::blockingMap (jobs, run_func );
    qDebug() << "jobs finished";
    delete script_engine;
    }
    @

    it plots an message [after the "starting jobs..." line]:
    @

    Fatal error in q:\qt5_workdir\w\s\qtjsbackend\src\3rdparty\v8\src\isolate.h, line 446

    CHECK(isolate != 0) failed

    @
    I use Qt 5.1.1, and MSVC2010 32bit.

    For me it looks as if only one thread can use the JS-Engine (note: this is a console app, no GUI or QML around). However, https://bugreports.qt-project.org/browse/QTBUG-23099 hints otherwise (and is closed). I did not find much in the documentation about that...
    I tried the same thing with the "old" QScriptEngine, and the result was similar, i.e. a crash but here without a nice warning.

    So the questions are:
    (1) can a Javascript engine be used from multiple threads (QtConcurrent)?
    (2) can I use multiple Javascript-engines in parallel (one engine for each thread) [I tried this briefly but got the same CHECK-error in "isolate.h"]?
    (3) are there differences between QJsEngine and QScriptEngine with regard to multithreaded script execution?

    thanks a lot for your answers!

    best,
    werner

    1 Reply Last reply
    0
    • G Offline
      G Offline
      GoKuNiX
      wrote on last edited by
      #2

      Hi,

      I encountered the same problem and filed a bugreport on it.
      Please upvote it.

      https://bugreports.qt-project.org/browse/QTBUG-33705

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved