Bug 1046369 - Add architecture to logged library load errors. r=blassey, a=sylvestre
authorRichard Newman <rnewman@mozilla.com>
Fri, 01 Aug 2014 15:07:00 -0700
changeset 208220 429123ab0700
parent 208219 51f2c08f86ee
child 208221 c110771b033f
push id3778
push userrnewman@mozilla.com
push date2014-08-03 22:25 +0000
treeherdermozilla-beta@429123ab0700 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersblassey, sylvestre
bugs1046369
milestone32.0
Bug 1046369 - Add architecture to logged library load errors. r=blassey, a=sylvestre
mobile/android/base/mozglue/GeckoLoader.java.in
--- a/mobile/android/base/mozglue/GeckoLoader.java.in
+++ b/mobile/android/base/mozglue/GeckoLoader.java.in
@@ -16,18 +16,19 @@ import java.io.File;
 import java.text.DecimalFormat;
 import java.text.DecimalFormatSymbols;
 import java.text.NumberFormat;
 import java.util.Locale;
 
 public final class GeckoLoader {
     private static final String LOGTAG = "GeckoLoader";
 
-    // This matches AppConstants, but we're built earlier.
+    // These match AppConstants, but we're built earlier.
     private static final String ANDROID_PACKAGE_NAME = "@ANDROID_PACKAGE_NAME@";
+    private static final String MOZ_APP_ABI = "@MOZ_APP_ABI@";
 
     private static volatile Intent sIntent;
     private static File sCacheFile;
     private static File sGREDir;
 
     private static final Object sLibLoadingLock = new Object();
     // Must hold sLibLoadingLock while accessing the following boolean variables.
     private static boolean sSQLiteLibsLoaded;
@@ -261,16 +262,18 @@ public final class GeckoLoader {
         loadLibsSetup(context);
         loadNSSLibsNative(apkName, false);
     }
 
     private static String getLoadDiagnostics(final Context context, final String lib) {
         final StringBuilder message = new StringBuilder("LOAD ");
         message.append(lib);
 
+        // These might differ. If so, we know why the library won't load!
+        message.append(": ABI: " + MOZ_APP_ABI + ", " + android.os.Build.CPU_ABI);
         message.append(": Data: " + context.getApplicationInfo().dataDir);
         try {
             final boolean appLibExists = new File("/data/app-lib/" + ANDROID_PACKAGE_NAME + "/lib" + lib + ".so").exists();
             final boolean dataDataExists = new File("/data/data/" + ANDROID_PACKAGE_NAME + "/lib/lib" + lib + ".so").exists();
             message.append(", ax=" + appLibExists);
             message.append(", ddx=" + dataDataExists);
         } catch (Throwable e) {
             message.append(": ax/ddx fail, ");
@@ -333,19 +336,27 @@ public final class GeckoLoader {
 
             if (Build.VERSION.SDK_INT < 9) {
                 // We can't use nativeLibraryDir.
                 return e;
             }
 
             // Attempt 2: use nativeLibraryDir, which should also work.
             final String libDir = context.getApplicationInfo().nativeLibraryDir;
-            if (attemptLoad(libDir + "/lib" + lib + ".so")) {
-                // Success!
-                return null;
+            final String libPath = libDir + "/lib" + lib + ".so";
+
+            // Does it even exist?
+            if (new File(libPath).exists()) {
+                if (attemptLoad(libPath)) {
+                    // Success!
+                    return null;
+                }
+                Log.wtf(LOGTAG, "Library exists but couldn't load!");
+            } else {
+                Log.wtf(LOGTAG, "Library doesn't exist when it should.");
             }
 
             // We failed. Return the original cause.
             return e;
         }
     }
 
     public static void doLoadLibrary(final Context context, final String lib) {