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

Commit 639701e8 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Fix for race condition when loading fonts from font provider"

parents 68be4332 faa67eb0
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();