[Libreoffice-commits] core.git: Branch 'feature/droid_calcimpress3' - 9 commits - android/experimental android/Module_android.mk bin/lolcat desktop/inc desktop/source sal/android vcl/android

Tor Lillqvist tml at collabora.com
Wed Oct 15 05:42:37 PDT 2014


 android/Module_android.mk                                                       |    1 
 android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitTileProvider.java |   19 ++++++++--
 bin/lolcat                                                                      |   19 ++++++++++
 desktop/inc/app.hxx                                                             |    1 
 desktop/source/lib/init.cxx                                                     |    7 +++
 sal/android/libreofficekit-jni.c                                                |   11 ++---
 vcl/android/androidinst.cxx                                                     |    2 +
 7 files changed, 49 insertions(+), 11 deletions(-)

New commits:
commit 566eba8b492384a2a218858ed23709f32e056cc7
Author: Tor Lillqvist <tml at collabora.com>
Date:   Wed Oct 15 15:39:24 2014 +0300

    Add a SAL_INFO
    
    The "bootstrap" errors tend to end up being displayed in some error dialog
    attempt which of course does nothing on mobile platforms, and that crack seems
    to crash on Android even, so this should give us some chance to get some idea
    at least what the code thinks is wrong...
    
    Change-Id: I070b017baf042ff692766d1efd1511e1addb6ecf

diff --git a/desktop/inc/app.hxx b/desktop/inc/app.hxx
index 33e7c0c..7f07e86 100644
--- a/desktop/inc/app.hxx
+++ b/desktop/inc/app.hxx
@@ -96,6 +96,7 @@ class Desktop : public Application
         {
             if ( m_aBootstrapError == BE_OK )
             {
+                SAL_INFO("desktop.app", "SetBootstrapError: " << nError << " '" << aMessage << "'");
                 m_aBootstrapError = nError;
                 m_aBootstrapErrorMessage = aMessage;
             }
commit a9d0d78d4a25e189482bbd27d0bf3b5fc07fb8a4
Author: Tor Lillqvist <tml at collabora.com>
Date:   Wed Oct 15 15:39:04 2014 +0300

    Use maximum logging verbosity while attempting the restart
    
    Change-Id: I3e3162474db1edef3b92e252b249fe373dedbbfd

diff --git a/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitTileProvider.java b/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitTileProvider.java
index 16de4a0..74ad782 100644
--- a/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitTileProvider.java
+++ b/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitTileProvider.java
@@ -43,6 +43,7 @@ public class LOKitTileProvider implements TileProvider {
         mDocument = mOffice.documentLoad(input);
 
         if (mDocument == null) {
+            LibreOfficeKit.putenv("SAL_LOG=+WARN+INFO");
             Log.i(LOGTAG, "====> mOffice.documentLoad() returned null, trying to restart 'Office' and loading again");
             mOffice.destroy();
             Log.i(LOGTAG, "====> mOffice.destroy() done");
@@ -51,6 +52,7 @@ public class LOKitTileProvider implements TileProvider {
             mOffice = new Office(handle);
             Log.i(LOGTAG, "====> new Office created");
             mDocument = mOffice.documentLoad(input);
+            LibreOfficeKit.putenv("SAL_LOG=-WARN+INFO.lok");
         }
 
         Log.i(LOGTAG, "====> mDocument = " + mDocument);
commit c56b8ff134c4d0318f0833db8a034761f002990b
Author: Tor Lillqvist <tml at collabora.com>
Date:   Wed Oct 15 13:12:37 2014 +0300

    Reduce log verbiage
    
    Change-Id: I0da75df61d129aaaf03ac546fcf1e5dbcff9d404

diff --git a/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitTileProvider.java b/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitTileProvider.java
index 7e90987..16de4a0 100644
--- a/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitTileProvider.java
+++ b/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitTileProvider.java
@@ -34,7 +34,7 @@ public class LOKitTileProvider implements TileProvider {
         mTileWidth = pixelToTwip(TILE_SIZE, mDPI);
         mTileHeight = pixelToTwip(TILE_SIZE, mDPI);
 
-        LibreOfficeKit.putenv("SAL_LOG=+WARN+INFO-INFO.legacy.osl-INFO.i18nlangtag");
+        LibreOfficeKit.putenv("SAL_LOG=-WARN+INFO.lok");
         LibreOfficeKit.init(LibreOfficeMainActivity.mAppContext);
 
         mOffice = new Office(LibreOfficeKit.getLibreOfficeKitHandle());
commit 9e0a82ff59d0f615573e654817b1859216c099c9
Author: Tor Lillqvist <tml at collabora.com>
Date:   Wed Oct 15 12:36:04 2014 +0300

    Add a small script to run adb logcat with filtering
    
    We use arbitrary tags when logging stuff in our code so we can't use the
    built-in filtering of adb logcat.
    
    Change-Id: I2d607b86bde975c5cbdd17adc22d0fc15076be51

diff --git a/bin/lolcat b/bin/lolcat
new file mode 100755
index 0000000..a97137b
--- /dev/null
+++ b/bin/lolcat
@@ -0,0 +1,19 @@
+#!/usr/bin/perl -w
+
+use strict;
+
+die "Usage: $0 identifier\n" .
+    "(identifier is for example org.libreoffice)" unless $#ARGV == 0;
+
+my $id = $ARGV[0];
+
+open (LOGCAT, "adb logcat |") || die "Could not open pipe from adb logcat";
+my $pid = '';
+
+while (<LOGCAT>) {
+  if (m!^I/ActivityManager\( *\d+\): Start proc $id for activity .*: pid=(\d+)!) {
+    $pid = $1;
+  } elsif (m!^[EIW]/[^(]+\( *$pid\)!) {
+    print $_;
+  }
+}
commit 695f8181efcedd86659ff80500b212bbdb5c8cbc
Author: Tor Lillqvist <tml at collabora.com>
Date:   Wed Oct 15 12:08:38 2014 +0300

    If loading a document fails, try restarting the 'main loop' and try again
    
    Does not work, though, we end up with a crash that is hard to debug thanks to
    the rubbish tool-chain.
    
    Change-Id: Ie1954e35e649fac8dd106f0ccbc6951c4a6c1c63

diff --git a/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitTileProvider.java b/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitTileProvider.java
index bd1b27b..7e90987 100644
--- a/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitTileProvider.java
+++ b/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitTileProvider.java
@@ -16,7 +16,7 @@ import java.nio.ByteBuffer;
 public class LOKitTileProvider implements TileProvider {
     private static final String LOGTAG = LOKitTileProvider.class.getSimpleName();
     private static int TILE_SIZE = 256;
-    private final Office mOffice;
+    private Office mOffice;
     private Document mDocument;
     private final LayerController mLayerController;
     private final float mTileWidth;
@@ -42,6 +42,19 @@ public class LOKitTileProvider implements TileProvider {
         mInputFile = input;
         mDocument = mOffice.documentLoad(input);
 
+        if (mDocument == null) {
+            Log.i(LOGTAG, "====> mOffice.documentLoad() returned null, trying to restart 'Office' and loading again");
+            mOffice.destroy();
+            Log.i(LOGTAG, "====> mOffice.destroy() done");
+            long handle = LibreOfficeKit.getLibreOfficeKitHandle();
+            Log.i(LOGTAG, "====> getLibreOfficeKitHandle() = " + handle);
+            mOffice = new Office(handle);
+            Log.i(LOGTAG, "====> new Office created");
+            mDocument = mOffice.documentLoad(input);
+        }
+
+        Log.i(LOGTAG, "====> mDocument = " + mDocument);
+
         if (checkDocument()) {
             int parts = mDocument.getParts();
             Log.i(LOGTAG, "Document parts: " + parts);
commit c809b37e55221dbe445d1705b057f76b6527e92e
Author: Tor Lillqvist <tml at collabora.com>
Date:   Wed Oct 15 12:02:44 2014 +0300

    Call DetachCurrentThread() in the AndroidSalInstance destructor
    
    As we call AttachCurrentThread() in the constructor, it seems logical to call
    DetachCurrentThread() in the destructor. Some warning messages in the logcat
    indicated that DetachCurrentThread() hadn't been called for a thread that
    died.
    
    Actually I would prefer to call both AttachCurrentThread() and
    DetachCurrentThread() in the actual thread function, instead of somewhat
    haphazardly and imlicitly in the AndroidSalInstance constructor and
    destructor. Do we know for sure that the lifetime of the AndroidSalInstance
    singleton (is is a singleton, right?) is 1:1 coupled to that of the LO "main
    thread"?
    
    Change-Id: Ifcc0e0b9af88b19389c416c5646499d44ad0e941

diff --git a/vcl/android/androidinst.cxx b/vcl/android/androidinst.cxx
index 262a7c1..8059d33 100644
--- a/vcl/android/androidinst.cxx
+++ b/vcl/android/androidinst.cxx
@@ -192,6 +192,8 @@ AndroidSalInstance::AndroidSalInstance( SalYieldMutex *pMutex )
 
 AndroidSalInstance::~AndroidSalInstance()
 {
+    int res = (lo_get_javavm())->DetachCurrentThread();
+    LOGI("DetachCurrentThread res=%d", res);
     LOGI("destroyed Android Sal Instance");
 }
 
commit 36ba14a7a4d56958da7f65d27d064a613d656714
Author: Tor Lillqvist <tml at collabora.com>
Date:   Wed Oct 15 10:59:20 2014 +0300

    Skip the 'desktop' app for now
    
    Change-Id: I040bd49f8cfeec74c3225135a110140c1816be43

diff --git a/android/Module_android.mk b/android/Module_android.mk
index 4b8485a..725aa3d 100644
--- a/android/Module_android.mk
+++ b/android/Module_android.mk
@@ -13,7 +13,6 @@ ifeq ($(OS),ANDROID)
 
 $(eval $(call gb_Module_add_targets,android,\
 	CustomTarget_lo_android \
-	CustomTarget_android_desktop \
 ))
 
 endif
commit 0664f5afb2f036288a5e69a4448928e0b8223048
Author: Tor Lillqvist <tml at collabora.com>
Date:   Wed Oct 15 10:55:42 2014 +0300

    The 'bInitialized' state needs to be global, and unset in lo_destroy()
    
    I assume, for lo_destroy() to be useful at all. Not that I know for sure what
    the exact intended semantics of lo_destroy() and lo_initialize() are. But I
    assume that the idea is that after lo_destroy() has been called,
    lo_initialize() can be called again.
    
    Change-Id: I2dea26db150d19ed438427e1c119a5297b9bc9c3

diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 9613514..fd6bbb0 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -655,11 +655,12 @@ static void* lo_startmain(void*)
     return 0;
 }
 
+static bool bInitialized = false;
+
 static int lo_initialize(LibreOfficeKit* pThis, const char* pAppPath)
 {
     LibLibreOffice_Impl* pLib = static_cast<LibLibreOffice_Impl*>(pThis);
 
-    static bool bInitialized = false;
     if (bInitialized)
         return 1;
 
@@ -778,10 +779,14 @@ static void lo_destroy(LibreOfficeKit *pThis)
     LibLibreOffice_Impl* pLib = static_cast<LibLibreOffice_Impl*>(pThis);
     gImpl = NULL;
 
+    SAL_INFO("lok", "lo_destroy");
+
     Application::Quit();
     pthread_join(pLib->maThread, NULL);
 
     delete pLib;
+    bInitialized = false;
+    SAL_INFO("lok", "lo_destroy done");
 }
 
 }
commit 2da55209d4a91b5bfe839043e92f57f7bd754923
Author: Tor Lillqvist <tml at collabora.com>
Date:   Wed Oct 15 10:17:15 2014 +0300

    Don't keep the LibreOfficeKit pointer in a global variable
    
    It is invalid in case lo_destroy() has been called.
    
    Change-Id: I45533b66d32fc650e48748da8ea1d2f2aaa381e0

diff --git a/sal/android/libreofficekit-jni.c b/sal/android/libreofficekit-jni.c
index 12bb3f9..4161982 100644
--- a/sal/android/libreofficekit-jni.c
+++ b/sal/android/libreofficekit-jni.c
@@ -40,7 +40,7 @@ extern void Java_org_libreoffice_android_Bootstrap_redirect_1stdio(JNIEnv* env,
 
 extern LibreOfficeKit* libreofficekit_hook(const char* install_path);
 
-static LibreOfficeKit* gpOffice;
+static char *full_program_dir = NULL;
 
 /// Call the same method from Bootstrap.
 __attribute__ ((visibility("default")))
@@ -73,7 +73,6 @@ jboolean Java_org_libreoffice_kit_LibreOfficeKit_initializeNative
 
     const char program_dir[] = "/program";
     size_t data_dir_len;
-    char *full_program_dir;
 
     (void) clazz;
 
@@ -128,6 +127,7 @@ jboolean Java_org_libreoffice_kit_LibreOfficeKit_initializeNative
     extract_files(UNPACK_TREE_GZ, UNPACK_TREE_GZ, 1);
 
     // LibreOfficeKit expects a path to the program/ directory
+    free(full_program_dir);
     data_dir_len = strlen(data_dir);
     full_program_dir = malloc(data_dir_len + sizeof(program_dir));
 
@@ -135,10 +135,7 @@ jboolean Java_org_libreoffice_kit_LibreOfficeKit_initializeNative
     strncpy(full_program_dir + data_dir_len, program_dir, sizeof(program_dir));
 
     // Initialize LibreOfficeKit
-    gpOffice = libreofficekit_hook(full_program_dir);
-
-    free(full_program_dir);
-    if (!gpOffice)
+    if (!libreofficekit_hook(full_program_dir))
     {
         LOGE("libreofficekit_hook returned null");
         return JNI_FALSE;
@@ -156,7 +153,7 @@ jlong Java_org_libreoffice_kit_LibreOfficeKit_getLibreOfficeKitHandle
     (void) env;
     (void) clazz;
 
-    return (jlong) (intptr_t) gpOffice;
+    return (jlong) (intptr_t) libreofficekit_hook(full_program_dir);
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */


More information about the Libreoffice-commits mailing list