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

Commit faa67eb0 authored by Edgar Arriaga's avatar Edgar Arriaga
Browse files

Fix for race condition when loading fonts from font provider

Change-Id: Ia5713c53e5d881e4d9836622375a0da4ffe5a674
parent 29f3a0b6
Loading
Loading
Loading
Loading
+10 −3
Original line number Diff line number Diff line
@@ -334,10 +334,17 @@ public class FontsContract {
            return cachedTypeface;
        }

        // Unfortunately the typeface is not available at this time, but requesting from the font
        // provider takes too much time. For now, request the font data to ensure it is in the cache
        // next time and return.
        synchronized (sLock) {
            // It is possible that Font is loaded during the thread sleep time
            // re-check the cache to avoid re-loading the font
            cachedTypeface = sTypefaceCache.get(id);
            if (cachedTypeface != null) {
                return cachedTypeface;
            }

            // Unfortunately the typeface is not available at this time, but requesting from
            // the font provider takes too much time. For now, request the font data to ensure
            // it is in the cache next time and return.
            if (sHandler == null) {
                sThread = new HandlerThread("fonts", Process.THREAD_PRIORITY_BACKGROUND);
                sThread.start();