[Android] Fix deadlock at app startup

Geoffrey Métais git at videolan.org
Fri Nov 3 12:00:46 CET 2017


vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Fri Nov  3 11:48:12 2017 +0100| [584d29b1335975df05964ccb32677bda7a8df6fc] | committer: Geoffrey Métais

Fix deadlock at app startup

> https://code.videolan.org/videolan/vlc-android/commit/584d29b1335975df05964ccb32677bda7a8df6fc
---

 medialibrary/src/org/videolan/medialibrary/Medialibrary.java | 10 ++--------
 vlc-android/src/org/videolan/vlc/VLCApplication.java         |  7 ++++++-
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/medialibrary/src/org/videolan/medialibrary/Medialibrary.java b/medialibrary/src/org/videolan/medialibrary/Medialibrary.java
index a3c687e34..f48915d5e 100644
--- a/medialibrary/src/org/videolan/medialibrary/Medialibrary.java
+++ b/medialibrary/src/org/videolan/medialibrary/Medialibrary.java
@@ -67,13 +67,7 @@ public class Medialibrary {
     private final List<EntryPointsEventsCb> entryPointsEventsCbList = new ArrayList<>();
     private static Context sContext;
 
-    static {
-        LibVLC.loadLibraries();
-    }
-
-    private static class MedialibraryHolder {
-        public static final Medialibrary instance = new Medialibrary();
-    }
+    private static final Medialibrary instance = new Medialibrary();
 
     public static Context getContext() {
         return sContext;
@@ -143,7 +137,7 @@ public class Medialibrary {
     }
 
     public static Medialibrary getInstance() {
-        return MedialibraryHolder.instance;
+        return instance;
     }
 
     @WorkerThread
diff --git a/vlc-android/src/org/videolan/vlc/VLCApplication.java b/vlc-android/src/org/videolan/vlc/VLCApplication.java
index f54c87ce5..60625984e 100644
--- a/vlc-android/src/org/videolan/vlc/VLCApplication.java
+++ b/vlc-android/src/org/videolan/vlc/VLCApplication.java
@@ -36,6 +36,7 @@ import android.support.v4.util.SimpleArrayMap;
 import android.util.Log;
 
 import org.videolan.libvlc.Dialog;
+import org.videolan.libvlc.LibVLC;
 import org.videolan.libvlc.util.AndroidUtil;
 import org.videolan.medialibrary.Medialibrary;
 import org.videolan.vlc.gui.DialogActivity;
@@ -74,7 +75,7 @@ public class VLCApplication extends Application {
     public static final ThreadFactory THREAD_FACTORY = new ThreadFactory() {
         @Override
         public Thread newThread(Runnable runnable) {
-            Thread thread = new Thread(runnable);
+            final Thread thread = new Thread(runnable);
             thread.setPriority(Process.THREAD_PRIORITY_DEFAULT+Process.THREAD_PRIORITY_LESS_FAVORABLE);
             return thread;
         }
@@ -93,9 +94,12 @@ public class VLCApplication extends Application {
 
         setLocale();
 
+        LibVLC.loadLibraries();
+
         runBackground(new Runnable() {
             @Override
             public void run() {
+
                 if (AndroidUtil.isOOrLater)
                     NotificationHelper.createNotificationChannels();
                 // Prepare cache folder constants
@@ -112,6 +116,7 @@ public class VLCApplication extends Application {
                     AndroidDevices.setRemoteControlReceiverEnabled(false);
             }
         });
+
         if (sActivityCbListener != null)
             registerActivityLifecycleCallbacks(sActivityCbListener);
         else



More information about the Android mailing list