Kaydet (Commit) 1aedb6c4 authored tarafından Michael Meeks's avatar Michael Meeks

LOK: provide user feedback while preloading.

Problems are hard enough to debug in a jailed kit process inside
a docker image; provide some visual feedback via stderr.

Change-Id: I54b0a21c1375be2acc9da0bbacf959a419471b08
Reviewed-on: https://gerrit.libreoffice.org/45256Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarMichael Meeks <michael.meeks@collabora.com>
üst 6481a06b
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
#include <sal/config.h> #include <sal/config.h>
#include <algorithm> #include <algorithm>
#include <iostream>
#include <cassert> #include <cassert>
#include <vector> #include <vector>
...@@ -39,6 +40,7 @@ ...@@ -39,6 +40,7 @@
#include <rtl/uri.hxx> #include <rtl/uri.hxx>
#include <rtl/ustring.hxx> #include <rtl/ustring.hxx>
#include <rtl/strbuf.hxx> #include <rtl/strbuf.hxx>
#include <rtl/ustrbuf.hxx>
#include <sal/log.hxx> #include <sal/log.hxx>
#include <uno/environment.hxx> #include <uno/environment.hxx>
...@@ -1806,6 +1808,33 @@ cppuhelper::ServiceManager::findServiceImplementation( ...@@ -1806,6 +1808,33 @@ cppuhelper::ServiceManager::findServiceImplementation(
return impl; return impl;
} }
/// Make a simpler unique name for preload / progress reporting.
static rtl::OUString simplifyModule(const rtl::OUString &uri)
{
sal_Int32 nIdx;
OUStringBuffer edit(uri);
if ((nIdx = edit.lastIndexOf('/')) > 0)
edit.remove(0,nIdx+1);
if ((nIdx = edit.lastIndexOf(':')) > 0)
edit.remove(0,nIdx+1);
if ((nIdx = edit.lastIndexOf("lo.so")) > 0)
edit.truncate(nIdx);
if ((nIdx = edit.lastIndexOf(".3")) > 0)
edit.truncate(nIdx);
if ((nIdx = edit.lastIndexOf("gcc3.so")) > 0)
edit.truncate(nIdx);
if ((nIdx = edit.lastIndexOf(".so")) > 0)
edit.truncate(nIdx);
if ((nIdx = edit.lastIndexOf("_uno")) > 0)
edit.truncate(nIdx);
if ((nIdx = edit.lastIndexOf(".jar")) > 0)
edit.truncate(nIdx);
if (edit.indexOf("lib") == 0)
edit.remove(0,3);
return edit.makeStringAndClear();
}
/// Used only by LibreOfficeKit when used by Online to pre-initialize
void cppuhelper::ServiceManager::preloadImplementations() { void cppuhelper::ServiceManager::preloadImplementations() {
#ifdef DISABLE_DYNLOADING #ifdef DISABLE_DYNLOADING
abort(); abort();
...@@ -1814,6 +1843,9 @@ void cppuhelper::ServiceManager::preloadImplementations() { ...@@ -1814,6 +1843,9 @@ void cppuhelper::ServiceManager::preloadImplementations() {
osl::MutexGuard g(rBHelper.rMutex); osl::MutexGuard g(rBHelper.rMutex);
css::uno::Environment aSourceEnv(css::uno::Environment::getCurrent()); css::uno::Environment aSourceEnv(css::uno::Environment::getCurrent());
std::cerr << "preload: ";
std::vector<OUString> aReported;
// loop all implementations // loop all implementations
for (Data::NamedImplementations::const_iterator iterator( for (Data::NamedImplementations::const_iterator iterator(
data_.namedImplementations.begin()); data_.namedImplementations.begin());
...@@ -1821,8 +1853,15 @@ void cppuhelper::ServiceManager::preloadImplementations() { ...@@ -1821,8 +1853,15 @@ void cppuhelper::ServiceManager::preloadImplementations() {
{ {
try try
{ {
const rtl::OUString &aLibrary = iterator->second->info->uri;
if (std::find(aReported.begin(), aReported.end(), aLibrary) == aReported.end())
{
std::cerr << simplifyModule(aLibrary) << " ";
aReported.push_back(aLibrary);
}
// expand absolute URI implementation component library // expand absolute URI implementation component library
aUri = cppu::bootstrap_expandUri(iterator->second->info->uri); aUri = cppu::bootstrap_expandUri(aLibrary);
} }
catch (css::lang::IllegalArgumentException& aError) catch (css::lang::IllegalArgumentException& aError)
{ {
...@@ -1922,6 +1961,7 @@ void cppuhelper::ServiceManager::preloadImplementations() { ...@@ -1922,6 +1961,7 @@ void cppuhelper::ServiceManager::preloadImplementations() {
aModule.release(); aModule.release();
} }
} }
std::cerr << std::endl;
#endif #endif
} }
......
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
#include <stdlib.h> #include <stdlib.h>
#include <memory> #include <memory>
#include <iostream>
#include <boost/property_tree/json_parser.hpp> #include <boost/property_tree/json_parser.hpp>
#include <LibreOfficeKit/LibreOfficeKit.h> #include <LibreOfficeKit/LibreOfficeKit.h>
...@@ -3482,6 +3483,7 @@ static void lo_status_indicator_callback(void *data, comphelper::LibreOfficeKit: ...@@ -3482,6 +3483,7 @@ static void lo_status_indicator_callback(void *data, comphelper::LibreOfficeKit:
} }
} }
/// Used only by LibreOfficeKit when used by Online to pre-initialize
static void preloadData() static void preloadData()
{ {
// First: sit down and read all dictionaries: yum. // First: sit down and read all dictionaries: yum.
...@@ -3491,14 +3493,14 @@ static void preloadData() ...@@ -3491,14 +3493,14 @@ static void preloadData()
css::uno::Reference<linguistic2::XSupportedLocales> xLocales(xSpellChecker, css::uno::UNO_QUERY_THROW); css::uno::Reference<linguistic2::XSupportedLocales> xLocales(xSpellChecker, css::uno::UNO_QUERY_THROW);
uno::Sequence< css::lang::Locale > aLocales = xLocales->getLocales(); uno::Sequence< css::lang::Locale > aLocales = xLocales->getLocales();
SAL_INFO("lok", "Preloading #" << aLocales.getLength() << " dictionaries"); std::cerr << "Preloading dictionaries: ";
for (auto &it : aLocales) for (auto &it : aLocales)
{ {
SAL_INFO("lok", " load " << it.Language << "_" << it.Country); std::cerr << it.Language << "_" << it.Country << " ";
css::beans::PropertyValues aNone; css::beans::PropertyValues aNone;
xSpellChecker->isValid("forcefed", it, aNone); xSpellChecker->isValid("forcefed", it, aNone);
} }
SAL_INFO("lok", "Preloading done"); std::cerr << "\n";
} }
static int lo_initialize(LibreOfficeKit* pThis, const char* pAppPath, const char* pUserProfileUrl) static int lo_initialize(LibreOfficeKit* pThis, const char* pAppPath, const char* pUserProfileUrl)
...@@ -3596,6 +3598,7 @@ static int lo_initialize(LibreOfficeKit* pThis, const char* pAppPath, const char ...@@ -3596,6 +3598,7 @@ static int lo_initialize(LibreOfficeKit* pThis, const char* pAppPath, const char
if (eStage == PRE_INIT) if (eStage == PRE_INIT)
{ {
std::cerr << "Init vcl\n";
InitVCL(); InitVCL();
// pre-load all component libraries. // pre-load all component libraries.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment