Bug 84746 - android: prune redundant configmgr settings
Summary: android: prune redundant configmgr settings
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Android Viewer (show other bugs)
(earliest affected) rc
Hardware: Other All
: medium normal
Assignee: Tor Lillqvist
Keywords: difficultyBeginner, easyHack, skillScript, topicCleanup
Depends on:
Blocks: mabAndroid
  Show dependency treegraph
Reported: 2014-10-07 10:49 UTC by Michael Meeks
Modified: 2015-12-16 00:18 UTC (History)
2 users (show)

See Also:
Crash report or crash signature:


Note You need to log in before you can comment on or make changes to this bug.
Description Michael Meeks 2014-10-07 10:49:16 UTC
I've written a tool for this:


It needs running on main.xcd (the biggest configmgr data file) - and applying in Makefile.shared - if DISABLE_UI=TRUE - some of the other profiles replicate the whole LibreOffice UI on Android.

That should chop 45% out of the main.xcd. My profiles suggest that configmgr initialization is 90%+ of the LibreOfficeKit lok_init time - particularly when we don't have the dlopen / dynamic linking cost at run-time.

So this should help us start ~30% faster (perhaps). Help merging & testing much appreciated.
Comment 1 Michael Meeks 2014-10-07 10:50:18 UTC
The file with the rule to hack this into is android/Bootstrap/Makefile.shared.
Comment 2 Tor Lillqvist 2014-10-21 18:59:48 UTC
It seems that the use of the xmlns prefix 'xs' inside attribute *values* in our xcd files (as in oor:type="xs:boolean"), but without having any actual elements or attributes with the 'xs' prefix, is somewhat hard for xml.etree.ElementTree to understand. It just leaves out the xmlns:xs="http://www.w3.org/2001/XMLSchema" thing from the output XML. And I guess that is what then causes the LO code to not like the xcd file. It says: bootstrapping exception 'invalid type xs:boolean'. Hmm...
Comment 3 Tor Lillqvist 2014-10-21 19:23:18 UTC
I tried this:

diff --git a/android/mobile-config.py b/android/mobile-config.py
index d28c7c0..0f044dc 100755
--- a/android/mobile-config.py
+++ b/android/mobile-config.py
@@ -92,4 +92,11 @@ if __name__ == '__main__':
             saved = saved + size
     print "saved %d of %d bytes: %2.f%%" % (saved, total, saved*100.0/total)
+    # The namespace prefixes xs and oor are present in attribute *values*, and namespace
+    # declarations for them are needed, even if no actual elements or attributes with these
+    # namespace prefixes are present. Fun.
+    root.set('xmlns:xs', 'http://www.w3.org/2001/XMLSchema')
+    root.set('xmlns:oor', 'http://openoffice.org/2001/registry')
     tree.write(sys.argv[2], 'UTF-8', True)

and that gets past the XML issues. But then I get:

bootstrapping exception 'set member node .uno:DBClearQuery references undefined template org.openoffice.Office.UI.Commands:LabelType in file:///assets/share/registry/main.xcd'

Comment 4 Tor Lillqvist 2014-10-22 11:31:48 UTC
I tried making the mobile-config.py script less eager to remove stuff, dropped first org.openoffice.Office.UI/Commands and then org.openoffice.Office.UI/WindowState from the list of pruned thingies (because error messages indicated that those were missing), but no. The app then fails to work correctly, without any useful warning or error message (I did change the SAL_LOG to display warnings). Will try a bit more, but this approach is starting to look futile.
Comment 5 Tor Lillqvist 2014-10-27 08:11:47 UTC
I figured out a problem in the mobile-config.py script: it calls remove() on a child of the root object while it is iterating the very same children. This s a bit like modifying an iterator that is being used in C++, and causes it to skip one child for each removed child. Thus failing to prune some stuff it was supposed to prune.
Comment 6 Tor Lillqvist 2014-10-27 10:29:29 UTC
Now then the loading of the document just silently fails again. After some debugging it seems to be caused by an attempt to get the configured application background colour, or something... Exceptions are fun.

#0  0x6d39b0d4 in __cxa_throw () from /home/tml/lo/android-calcimpress3/android/experimental/LOAndroid3/obj/local/armeabi-v7a/liblo-native-code.so
#1  0x6902a518 in configmgr::RootAccess::getNode() () at /home/tml/lo/android-calcimpress3/configmgr/source/rootaccess.cxx:224
#2  0x6904525e in configmgr::Access::isValue() () at /home/tml/lo/android-calcimpress3/configmgr/source/access.cxx:114
#3  0x69013176 in configmgr::configuration_provider::(anonymous namespace)::Service::createInstanceWithArguments(rtl::OUString const&, com::sun::star::uno::Sequence<com::sun::star::uno::Any> const&) () at /home/tml/lo/android-calcimpress3/configmgr/source/configurationprovider.cxx:273
#4  0x6bfc3fea in utl::ConfigManager::acquireTree(utl::ConfigItem&) () at /home/tml/lo/android-calcimpress3/unotools/source/config/configmgr.cxx:161
#5  0x6bfc419c in utl::ConfigManager::addConfigItem(utl::ConfigItem&) ()
    at /home/tml/lo/android-calcimpress3/unotools/source/config/configmgr.cxx:174
#6  0x6bfc0008 in utl::ConfigItem::ConfigItem(rtl::OUString const&, short) ()
    at /home/tml/lo/android-calcimpress3/unotools/source/config/configitem.cxx:177
#7  0x6ae1fcb4 in svtools::ColorConfig_Impl::ColorConfig_Impl(bool) () at /home/tml/lo/android-calcimpress3/svtools/source/config/colorcfg.cxx:192
#8  0x6ae20770 in svtools::ColorConfig::ColorConfig() () at /home/tml/lo/android-calcimpress3/svtools/source/config/colorcfg.cxx:397
#9  0x693a5bfa in (anonymous namespace)::TaskCreatorService::implts_createContainerWindow(com::sun::star::uno::Reference<com::sun::star::awt::XWindow> const&, com::sun::star::awt::Rectangle const&, bool) () at /home/tml/lo/android-calcimpress3/framework/source/services/taskcreatorsrv.cxx:276
#10 0x693a56d0 in (anonymous namespace)::TaskCreatorService::createInstanceWithArguments(com::sun::star::uno::Sequence<com::sun::star::uno::Any> const&) () at /home/tml/lo/android-calcimpress3/framework/source/services/taskcreatorsrv.cxx:167
#11 0x693efc6c in framework::TaskCreator::createTask(rtl::OUString const&, bool) ()
    at /home/tml/lo/android-calcimpress3/framework/source/classes/taskcreator.cxx:114
#12 0x69382016 in framework::Desktop::findFrame(rtl::OUString const&, long) ()
    at /home/tml/lo/android-calcimpress3/framework/source/services/desktop.cxx:921
#13 0x69410d48 in framework::LoadEnv::impl_loadContent() () at /home/tml/lo/android-calcimpress3/framework/source/loadenv/loadenv.cxx:1029
#14 0x6940e98c in framework::LoadEnv::startLoading() () at /home/tml/lo/android-calcimpress3/framework/source/loadenv/loadenv.cxx:383
#15 0x6940dc94 in framework::LoadEnv::loadComponentFromURL(com::sun::star::uno::Reference<com::sun::star::frame::XComponentLoader> const&, com::sun::star::uno::Reference<com::sun::star::uno::XComponentContext> const&, rtl::OUString const&, rtl::OUString const&, long, com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue> const&) () at /home/tml/lo/android-calcimpress3/framework/source/loadenv/loadenv.cxx:164
#16 0x6938162e in framework::Desktop::loadComponentFromURL(rtl::OUString const&, rtl::OUString const&, long, com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue> const&) () at /home/tml/lo/android-calcimpress3/framework/source/services/desktop.cxx:567
#17 0x6ac92bc6 in lo_documentLoad () at /home/tml/lo/android-calcimpress3/desktop/source/lib/init.cxx:306
#18 0x6ac95390 in Java_org_libreoffice_kit_Office_documentLoadNative () at /home/tml/lo/android-calcimpress3/desktop/source/lib/lokandroid.cxx:82
Comment 7 Tor Lillqvist 2014-10-27 12:37:36 UTC
Now the pruning seems to work. I had to keep org.openoffice.Office/UI as there is stuff in there which is needed in many places around the code.
Comment 8 Tor Lillqvist 2014-10-27 13:05:07 UTC
Sigh, I was too optimistic, for some documents I now get: LibreOffice 4.4 - Fatal Error': 'cannot find /org.openoffice.Office.UI.Factories/Registered/UIElementFactories
Comment 9 Tor Lillqvist 2014-10-27 14:37:16 UTC
OK, so after keeping also org.openoffice.Office.UI/Factories, this now seems to work. The droid_calcimpress3 branch contains the commits.

In an optimised build tree, the time for reading the .xcd files dropped from ~800ms to ~600ms on my device, a tablet a couple of years old.
Comment 11 Robinson Tryon (qubit) 2015-12-16 00:18:51 UTC
Migrating Whiteboard tags to Keywords: (EasyHack DifficultyBeginner SkillScript TopicCleanup)