Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 166b5e74 authored by Kshitij's avatar Kshitij
Browse files

fix: Prioritize first-load of model

- When launcher is in foreground, especially with taskbar, it may
  stall/lock the UI thread.
- If the model is in the middle of loading and hasn't ever finished
  loading, it may need the user to navigate to another app or lock the
  device to finish model load, which is terrible UX
- This has worked so far but is a noticeable issue on tablets, and slower
  phones too
- Do not wait for idle and continue scheduling work on the UI thread so
  that the model has fully loaded at least once. After this, it can stall
  all it wants
parent a64b5d62
Loading
Loading
Loading
Loading
+4 −0
Original line number Original line Diff line number Diff line
@@ -575,6 +575,10 @@ public class LauncherModel extends LauncherApps.Callback implements InstallSessi
            }
            }
        }
        }


        public boolean isModelLoaded() {
            return mModelLoaded;
        }

        @Override
        @Override
        public void close() {
        public void close() {
            synchronized (mLock) {
            synchronized (mLock) {
+9 −3
Original line number Original line Diff line number Diff line
@@ -234,7 +234,9 @@ public class LoaderTask implements Runnable {
            logASplit(timingLogger, "sendFirstScreenActiveInstallsBroadcast");
            logASplit(timingLogger, "sendFirstScreenActiveInstallsBroadcast");


            // Take a break
            // Take a break
            if (transaction.isModelLoaded()) {
                waitForIdle();
                waitForIdle();
            }
            logASplit(timingLogger, "step 1 complete");
            logASplit(timingLogger, "step 1 complete");
            verifyNotStopped();
            verifyNotStopped();


@@ -268,7 +270,9 @@ public class LoaderTask implements Runnable {
                    mApp.getModel()::onPackageIconsUpdated);
                    mApp.getModel()::onPackageIconsUpdated);


            // Take a break
            // Take a break
            if (transaction.isModelLoaded()) {
                waitForIdle();
                waitForIdle();
            }
            logASplit(timingLogger, "step 2 complete");
            logASplit(timingLogger, "step 2 complete");
            verifyNotStopped();
            verifyNotStopped();


@@ -286,7 +290,9 @@ public class LoaderTask implements Runnable {
                    new ShortcutCachingLogic(), (pkgs, user) -> { });
                    new ShortcutCachingLogic(), (pkgs, user) -> { });


            // Take a break
            // Take a break
            if (transaction.isModelLoaded()) {
                waitForIdle();
                waitForIdle();
            }
            logASplit(timingLogger, "step 3 complete");
            logASplit(timingLogger, "step 3 complete");
            verifyNotStopped();
            verifyNotStopped();