offapi/org/libreoffice/embindtest/XTest.idl | 2 - unotest/source/embindtest/embindtest.cxx | 30 +++++++++++++++++++++++++--- unotest/source/embindtest/embindtest.js | 3 +- 3 files changed, 30 insertions(+), 5 deletions(-)
New commits: commit b418f3d8d332276e6990cf7532a8f66aeb1d2f6c Author: Stephan Bergmann <stephan.bergm...@allotropia.de> AuthorDate: Tue Sep 10 12:49:49 2024 +0200 Commit: Stephan Bergmann <stephan.bergm...@allotropia.de> CommitDate: Tue Sep 10 19:52:15 2024 +0200 Demonstrate that Embind is not multi-threading capable Enabling the line commented out with "TODO" in embindtest.js would fail with something like > Aborted(Assertion failed: invalid handle: 8) > worker.js onmessage() captured an uncaught exception: RuntimeError: unreachable > RuntimeError: unreachable > at soffice.wasm.__trap (http://localhost:6931/soffice.wasm:wasm-function[446445]:0x8f952b3) > at ___trap (blob:http://localhost:6931/7e945427-df90-49c0-a2b5-28c5ecfbe1a5:16657:54) > at abort (blob:http://localhost:6931/7e945427-df90-49c0-a2b5-28c5ecfbe1a5:1091:5) > at assert (blob:http://localhost:6931/7e945427-df90-49c0-a2b5-28c5ecfbe1a5:731:5) > at HandleAllocator.get (blob:http://localhost:6931/7e945427-df90-49c0-a2b5-28c5ecfbe1a5:7212:11) > at Object.toValue (blob:http://localhost:6931/7e945427-df90-49c0-a2b5-28c5ecfbe1a5:7270:30) > at __emval_call_void_method (blob:http://localhost:6931/7e945427-df90-49c0-a2b5-28c5ecfbe1a5:10183:22) > at soffice.wasm.the_wrappers::com::sun::star::task::XJobExecutor::trigger(rtl::OUString const&) (http://localhost:6931/soffice.wasm:wasm-function[77042]:0xafbb24) > at soffice.wasm.(anonymous namespace)::JobExecutorThread::execute() (http://localhost:6931/soffice.wasm:wasm-function[243534]:0x43250b5) > at soffice.wasm.non-virtual thunk to salhelper::Thread::run() (http://localhost:6931/soffice.wasm:wasm-function[87641]:0xdff5cf) Change-Id: I4e35dc19c5c0f97de7158bf9c07fd31716ffff84 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/173132 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <stephan.bergm...@allotropia.de> diff --git a/offapi/org/libreoffice/embindtest/XTest.idl b/offapi/org/libreoffice/embindtest/XTest.idl index 276ce260a8e1..e579a606202a 100644 --- a/offapi/org/libreoffice/embindtest/XTest.idl +++ b/offapi/org/libreoffice/embindtest/XTest.idl @@ -129,7 +129,7 @@ interface XTest { [out] XTest value18); void throwRuntimeException(); void passJob([in] com::sun::star::task::XJob object); - void passJobExecutor([in] com::sun::star::task::XJobExecutor object); + void passJobExecutor([in] com::sun::star::task::XJobExecutor object, [in] boolean newThread); void passInterface([in] com::sun::star::uno::XInterface object); boolean checkAttributes([in] org::libreoffice::embindtest::XAttributes object); [attribute] string StringAttribute; diff --git a/unotest/source/embindtest/embindtest.cxx b/unotest/source/embindtest/embindtest.cxx index 60150dcd2ad9..4a335f6f6be3 100644 --- a/unotest/source/embindtest/embindtest.cxx +++ b/unotest/source/embindtest/embindtest.cxx @@ -67,6 +67,21 @@ private: } }; +class JobExecutorThread : public salhelper::Thread +{ +public: + JobExecutorThread(css::uno::Reference<css::task::XJobExecutor> const& object) + : Thread("jobexecutor") + , object_(object) + { + } + +private: + void execute() override { object_->trigger(u"executor thread"_ustr); } + + css::uno::Reference<css::task::XJobExecutor> object_; +}; + class Test : public cppu::WeakImplHelper<org::libreoffice::embindtest::XTest> { sal_Bool SAL_CALL getBoolean() override { return true; } @@ -861,10 +876,19 @@ class Test : public cppu::WeakImplHelper<org::libreoffice::embindtest::XTest> } } - void SAL_CALL - passJobExecutor(css::uno::Reference<css::task::XJobExecutor> const& object) override + void SAL_CALL passJobExecutor(css::uno::Reference<css::task::XJobExecutor> const& object, + sal_Bool newThread) override { - object->trigger(u"executor"_ustr); + if (newThread) + { + JobExecutorThread t(object); + t.launch(); + t.join(); + } + else + { + object->trigger(u"executor"_ustr); + } } void SAL_CALL passInterface(css::uno::Reference<css::uno::XInterface> const& object) override diff --git a/unotest/source/embindtest/embindtest.js b/unotest/source/embindtest/embindtest.js index 9551a9a56bca..082150ff6605 100644 --- a/unotest/source/embindtest/embindtest.js +++ b/unotest/source/embindtest/embindtest.js @@ -878,7 +878,8 @@ Module.uno_init.then(function() { s.delete(); } test.passJob(css.task.XJob.query(obj)); - test.passJobExecutor(css.task.XJobExecutor.query(obj)); + test.passJobExecutor(css.task.XJobExecutor.query(obj), false); + //TODO: test.passJobExecutor(css.task.XJobExecutor.query(obj), true); test.passInterface(obj); css.task.XJobExecutor.query(obj).trigger('from JS'); {