Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit e5b6447

Browse files
committed
Update changes as review requested.
1 parent 322cd0b commit e5b6447

File tree

4 files changed

+12
-13
lines changed

4 files changed

+12
-13
lines changed

shell/common/engine.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -366,8 +366,6 @@ class Engine final : public RuntimeDelegate, PointerDataDispatcher::Delegate {
366366
//----------------------------------------------------------------------------
367367
/// @brief Setup default font manager according to specific platform.
368368
///
369-
/// @attention This operation calls `SkFontMgr::RefDefault` which is
370-
/// time-consuming except running at linux and windows.
371369
void SetupDefaultFontManager();
372370

373371
//----------------------------------------------------------------------------

shell/platform/android/flutter_main.cc

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -156,8 +156,9 @@ void FlutterMain::SetupObservatoryUriCallback(JNIEnv* env) {
156156
});
157157
}
158158

159-
static void CreateDefaultFontManager(JNIEnv* env, jclass jcaller) {
160-
sk_sp<SkFontMgr> font_mgr(SkFontMgr::RefDefault());
159+
static void PrefetchDefaultFontManager(JNIEnv* env, jclass jcaller) {
160+
// Initialize a singleton owned by Skia.
161+
SkFontMgr::RefDefault();
161162
}
162163

163164
bool FlutterMain::Register(JNIEnv* env) {
@@ -169,9 +170,9 @@ bool FlutterMain::Register(JNIEnv* env) {
169170
.fnPtr = reinterpret_cast<void*>(&Init),
170171
},
171172
{
172-
.name = "nativeCreateDefaultFontManager",
173+
.name = "nativePrefetchDefaultFontManager",
173174
.signature = "()V",
174-
.fnPtr = reinterpret_cast<void*>(&CreateDefaultFontManager),
175+
.fnPtr = reinterpret_cast<void*>(&PrefetchDefaultFontManager),
175176
},
176177
};
177178

shell/platform/android/io/flutter/embedding/engine/FlutterJNI.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,11 +107,11 @@ public static native void nativeInit(
107107
long initTimeMillis);
108108

109109
/**
110-
* Create the default font manager provided by SkFontMgr::RefDefault() which is a process-wide
110+
* Prefetch the default font manager provided by SkFontMgr::RefDefault() which is a process-wide
111111
* singleton owned by Skia. Note that, the first call to SkFontMgr::RefDefault() will take
112112
* noticeable time, but later calls will return a reference to the preexisting font manager.
113113
*/
114-
public static native void nativeCreateDefaultFontManager();
114+
public static native void nativePrefetchDefaultFontManager();
115115

116116
// TODO(mattcarroll): add javadocs
117117
@UiThread

shell/platform/android/io/flutter/embedding/engine/loader/FlutterLoader.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -144,16 +144,16 @@ public InitResult call() {
144144

145145
System.loadLibrary("flutter");
146146

147-
// Pre-warm the default font manager as soon as possible on a background thread.
147+
// Prefetch the default font manager as soon as possible on a background thread.
148148
// It helps to reduce time cost of engine setup that blocks the platform thread.
149-
new Thread(
149+
Executors.newSingleThreadExecutor()
150+
.execute(
150151
new Runnable() {
151152
@Override
152153
public void run() {
153-
FlutterJNI.nativeCreateDefaultFontManager();
154+
FlutterJNI.nativePrefetchDefaultFontManager();
154155
}
155-
})
156-
.start();
156+
});
157157

158158
if (resourceExtractor != null) {
159159
resourceExtractor.waitForCompletion();

0 commit comments

Comments
 (0)