[Libreoffice-commits] core.git: Branch 'distro/lhm/libreoffice-6-4+backports' - desktop/source officecfg/registry stoc/source
Serge Krot (via logerrit)
logerrit at kemper.freedesktop.org
Sun Sep 27 10:03:43 UTC 2020
desktop/source/app/app.cxx | 51 +++++++++++++
officecfg/registry/schema/org/openoffice/Office/Common.xcs | 7 +
stoc/source/javaloader/javaloader.cxx | 8 +-
3 files changed, 65 insertions(+), 1 deletion(-)
New commits:
commit d0fdfe0e92a1989c61613fcb8deeb3256eb0816a
Author: Serge Krot <Serge.Krot at cib.de>
AuthorDate: Wed Mar 25 16:56:18 2020 +0100
Commit: Thorsten Behrens <Thorsten.Behrens at CIB.de>
CommitDate: Sun Sep 27 12:03:08 2020 +0200
speed-up: preload JVM when PreloadJVM is set
Change-Id: I57f77f127f7cb45fb181b755b40873d47015e5b2
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/91059
Tested-by: Thorsten Behrens <Thorsten.Behrens at CIB.de>
Reviewed-by: Thorsten Behrens <Thorsten.Behrens at CIB.de>
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/103390
diff --git a/desktop/source/app/app.cxx b/desktop/source/app/app.cxx
index e5d0939b2e93..2da91af2cccb 100644
--- a/desktop/source/app/app.cxx
+++ b/desktop/source/app/app.cxx
@@ -83,6 +83,7 @@
#include <com/sun/star/office/Quickstart.hpp>
#include <com/sun/star/system/XSystemShellExecute.hpp>
#include <com/sun/star/system/SystemShellExecute.hpp>
+#include <com/sun/star/loader/XImplementationLoader.hpp>
#include <desktop/exithelper.h>
#include <sal/log.hxx>
@@ -129,6 +130,7 @@
#include <vcl/graphicfilter.hxx>
#include <vcl/window.hxx>
#include "langselect.hxx"
+#include <salhelper/thread.hxx>
#if defined MACOSX
#include <errno.h>
@@ -1217,6 +1219,38 @@ void Desktop::AppEvent( const ApplicationEvent& rAppEvent )
HandleAppEvent( rAppEvent );
}
+namespace {
+
+class JVMloadThread : public salhelper::Thread {
+public:
+ JVMloadThread() : salhelper::Thread("Preload JVM thread")
+ {
+ }
+
+private:
+ virtual void execute() override final
+ {
+ Reference< XMultiServiceFactory > xSMgr = comphelper::getProcessServiceFactory();
+
+ Reference< css::loader::XImplementationLoader > xJavaComponentLoader(
+ xSMgr->createInstance("com.sun.star.comp.stoc.JavaComponentLoader"),
+ css::uno::UNO_QUERY_THROW);
+
+ if (xJavaComponentLoader.is())
+ {
+ const css::uno::Reference< ::com::sun::star::registry::XRegistryKey > xRegistryKey;
+ try
+ {
+ xJavaComponentLoader->activate("", "", "", xRegistryKey);
+ }
+ catch (...)
+ {
+ SAL_WARN("desktop.app", "Cannot activate factory during JVM preloading");
+ }
+ }
+ }
+};
+
struct ExecuteGlobals
{
Reference < css::document::XDocumentEventListener > xGlobalBroadcaster;
@@ -1224,12 +1258,14 @@ struct ExecuteGlobals
bool bUseSystemFileDialog;
std::unique_ptr<SvtLanguageOptions> pLanguageOptions;
std::unique_ptr<SvtPathOptions> pPathOptions;
+ rtl::Reference< JVMloadThread > xJVMloadThread;
ExecuteGlobals()
: bRestartRequested( false )
, bUseSystemFileDialog( true )
{}
};
+}
static ExecuteGlobals* pExecGlobals = nullptr;
@@ -1254,6 +1290,15 @@ int Desktop::Main()
// Detect desktop environment - need to do this as early as possible
css::uno::setCurrentContext( new DesktopContext( css::uno::getCurrentContext() ) );
+ if (officecfg::Office::Common::Misc::PreloadJVM::get() && pExecGlobals)
+ {
+ SAL_INFO("desktop.app", "Preload JVM");
+
+ // pre-load JVM
+ pExecGlobals->xJVMloadThread = new JVMloadThread();
+ pExecGlobals->xJVMloadThread->launch();
+ }
+
CommandLineArgs& rCmdLineArgs = GetCommandLineArgs();
Translate::SetReadStringHook(ReplaceStringHookProc);
@@ -1663,6 +1708,12 @@ int Desktop::doShutdown()
if (m_aUpdateThread.joinable())
m_aUpdateThread.join();
+ if (pExecGlobals->xJVMloadThread.is())
+ {
+ pExecGlobals->xJVMloadThread->join();
+ pExecGlobals->xJVMloadThread.clear();
+ }
+
pExecGlobals->bRestartRequested = pExecGlobals->bRestartRequested ||
OfficeRestartManager::get(comphelper::getProcessComponentContext())->
isRestartRequested(true);
diff --git a/officecfg/registry/schema/org/openoffice/Office/Common.xcs b/officecfg/registry/schema/org/openoffice/Office/Common.xcs
index cebb7d7ec0ef..3a9472e924fc 100644
--- a/officecfg/registry/schema/org/openoffice/Office/Common.xcs
+++ b/officecfg/registry/schema/org/openoffice/Office/Common.xcs
@@ -5723,6 +5723,13 @@
</info>
<value>true</value>
</prop>
+ <prop oor:name="PreloadJVM" oor:type="xs:boolean" oor:nillable="false">
+ <info>
+ <desc>Specifies if the JVM should be preloaded during LO start up.</desc>
+ <label>PreloadJVM</label>
+ </info>
+ <value>false</value>
+ </prop>
<prop oor:name="FilePickerPlacesUrls" oor:type="oor:string-list" oor:nillable="false">
<info>
<desc>List of URLs of the places the user bookmarked in the file picker dialog.</desc>
diff --git a/stoc/source/javaloader/javaloader.cxx b/stoc/source/javaloader/javaloader.cxx
index 4af288f737b8..36b26c0a609d 100644
--- a/stoc/source/javaloader/javaloader.cxx
+++ b/stoc/source/javaloader/javaloader.cxx
@@ -311,11 +311,17 @@ sal_Bool SAL_CALL JavaComponentLoader::writeRegistryInfo(
return loader->writeRegistryInfo(xKey, blabla, rLibName);
}
-
css::uno::Reference<XInterface> SAL_CALL JavaComponentLoader::activate(
const OUString & rImplName, const OUString & blabla, const OUString & rLibName,
const css::uno::Reference<XRegistryKey> & xKey)
{
+ if (rImplName.isEmpty() && blabla.isEmpty() && rLibName.isEmpty())
+ {
+ // preload JVM was requested
+ (void)getJavaLoader();
+ return css::uno::Reference<XInterface>();
+ }
+
const css::uno::Reference<XImplementationLoader> & loader = getJavaLoader();
if (!loader.is())
throw CannotActivateFactoryException("Could not create Java implementation loader");
More information about the Libreoffice-commits
mailing list