Repository: flutter
Issue: StrictMode DiskReadViolation related to Typeface
Labels: platform-android,has reproducible steps,P2,perf: startup,team-android,triaged-android,found in release: 3.19,found in release: 3.21

### Summary 
Flutter reads typeface on the main thread and we should not do file io on the main thread. Below is a way to detect if we have any violations. 

### Steps to reproduce

- Enable StrictMode in Android by adding this below onCreate():
```
       StrictMode.setThreadPolicy(
            StrictMode.ThreadPolicy.Builder()
                .detectDiskReads()
                .detectDiskWrites()
                .penaltyLog()
                .build()
        )
        StrictMode.setVmPolicy(
            StrictMode.VmPolicy.Builder()
                .detectLeakedSqlLiteObjects()
                .detectLeakedClosableObjects()
                .penaltyLog() //.penaltyDeath()
                .penaltyDeath()
                .build()
        )
```
-   Run Flutter application on Android device
-   In terminal type: `adb logcat '*:S StrictMode:V flutter:V'`
-  Observe logs during app startup and you should see `android.os.strictmode.DiskReadViolation` violating MainThread mostly between 1000ms to 4500ms


### Expected results

It shouldn't be that the MainThread is violated by Typeface.

### Actual results

There are several DiskReadViolation violation in the logs

### Code sample

There is no code associated with this issue 

### Screenshots or Video

<details open>
<summary>Screenshots / Video demonstration</summary>

[Upload media here]

</details>


### Logs

<details open><summary>Logs</summary>

```console
StrictMode policy violation; ~duration=2116 ms: android.os.strictmode.DiskReadViolation
03-13 13:23:05.427  9537  9537 D StrictMode: 	at android.os.StrictMode$AndroidBlockGuardPolicy.onReadFromDisk(StrictMode.java:1504)
03-13 13:23:05.427  9537  9537 D StrictMode: 	at java.io.UnixFileSystem.getBooleanAttributes(UnixFileSystem.java:241)
03-13 13:23:05.427  9537  9537 D StrictMode: 	at java.io.File.isDirectory(File.java:845)
03-13 13:23:05.427  9537  9537 D StrictMode: 	at android.graphics.Typeface.getFullFlipFont(Typeface.java:1498)
03-13 13:23:05.427  9537  9537 D StrictMode: 	at android.graphics.Typeface.getFontPathFlipFont(Typeface.java:1481)
03-13 13:23:05.427  9537  9537 D StrictMode: 	at android.graphics.Typeface.SetFlipFonts(Typeface.java:1571)
03-13 13:23:05.427  9537  9537 D StrictMode: 	at android.graphics.Typeface.SetAppTypeFace(Typeface.java:1742)
03-13 13:23:05.427  9537  9537 D StrictMode: 	at android.app.Activity.onCreate(Activity.java:1072)
03-13 13:23:05.427  9537  9537 D StrictMode: 	at io.flutter.embedding.android.FlutterActivity.onCreate(FlutterActivity.java:631)
03-13 13:23:05.427  9537  9537 D StrictMode: 	at com.gopuff.godrive2.staging.MainActivity.onCreate(MainActivity.kt:56)
03-13 13:23:05.427  9537  9537 D StrictMode: 	at android.app.Activity.performCreate(Activity.java:7327)
03-13 13:23:05.427  9537  9537 D StrictMode: 	at android.app.Activity.performCreate(Activity.java:7318)
03-13 13:23:05.427  9537  9537 D StrictMode: 	at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1271)
03-13 13:23:05.427  9537  9537 D StrictMode: 	at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3096)
03-13 13:23:05.427  9537  9537 D StrictMode: 	at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3259)
03-13 13:23:05.427  9537  9537 D StrictMode: 	at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)
03-13 13:23:05.427  9537  9537 D StrictMode: 	at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
03-13 13:23:05.427  9537  9537 D StrictMode: 	at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
03-13 13:23:05.427  9537  9537 D StrictMode: 	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1950)
03-13 13:23:05.427  9537  9537 D StrictMode: 	at android.os.Handler.dispatchMessage(Handler.java:106)
03-13 13:23:05.427  9537  9537 D StrictMode: 	at android.os.Looper.loop(Looper.java:214)
03-13 13:23:05.427  9537  9537 D StrictMode: 	at android.app.ActivityThread.main(ActivityThread.java:7073)
03-13 13:23:05.427  9537  9537 D StrictMode: 	at java.lang.reflect.Method.invoke(Native Method)
03-13 13:23:05.427  9537  9537 D StrictMode: 	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:494)
03-13 13:23:05.427  9537  9537 D StrictMode: 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:964)



03-15 13:54:46.675 29151 29580 I flutter : The Dart VM service is listening on http://127.0.0.1:43352/zBStX3ZSbLw=/
03-15 13:54:48.587 29151 29151 D StrictMode: StrictMode policy violation; ~duration=4191 ms: android.os.strictmode.DiskReadViolation
03-15 13:54:48.587 29151 29151 D StrictMode: 	at android.os.StrictMode$AndroidBlockGuardPolicy.onReadFromDisk(StrictMode.java:1504)
03-15 13:54:48.587 29151 29151 D StrictMode: 	at java.io.UnixFileSystem.getBooleanAttributes(UnixFileSystem.java:241)
03-15 13:54:48.587 29151 29151 D StrictMode: 	at java.io.File.isDirectory(File.java:845)
03-15 13:54:48.587 29151 29151 D StrictMode: 	at android.graphics.Typeface.getFullFlipFont(Typeface.java:1498)
03-15 13:54:48.587 29151 29151 D StrictMode: 	at android.graphics.Typeface.getFontPathFlipFont(Typeface.java:1481)
03-15 13:54:48.587 29151 29151 D StrictMode: 	at android.graphics.Typeface.SetFlipFonts(Typeface.java:1571)
03-15 13:54:48.587 29151 29151 D StrictMode: 	at android.graphics.Typeface.SetAppTypeFace(Typeface.java:1742)
03-15 13:54:48.587 29151 29151 D StrictMode: 	at android.app.Activity.onCreate(Activity.java:1072)
03-15 13:54:48.587 29151 29151 D StrictMode: 	at io.flutter.embedding.android.FlutterActivity.onCreate(FlutterActivity.java:631)
03-15 13:54:48.587 29151 29151 D StrictMode: 	at com.gopuff.godrive2.staging.MainActivity.onCreate(MainActivity.kt:56)
03-15 13:54:48.587 29151 29151 D StrictMode: 	at android.app.Activity.performCreate(Activity.java:7327)
03-15 13:54:48.587 29151 29151 D StrictMode: 	at android.app.Activity.performCreate(Activity.java:7318)
03-15 13:54:48.587 29151 29151 D StrictMode: 	at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1271)
03-15 13:54:48.587 29151 29151 D StrictMode: 	at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3096)
03-15 13:54:48.587 29151 29151 D StrictMode: 	at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3259)
03-15 13:54:48.587 29151 29151 D StrictMode: 	at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)
03-15 13:54:48.587 29151 29151 D StrictMode: 	at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
03-15 13:54:48.587 29151 29151 D StrictMode: 	at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
03-15 13:54:48.587 29151 29151 D StrictMode: 	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1950)
03-15 13:54:48.587 29151 29151 D StrictMode: 	at android.os.Handler.dispatchMessage(Handler.java:106)
03-15 13:54:48.587 29151 29151 D StrictMode: 	at android.os.Looper.loop(Looper.java:214)
03-15 13:54:48.587 29151 29151 D StrictMode: 	at android.app.ActivityThread.main(ActivityThread.java:7073)
03-15 13:54:48.587 29151 29151 D StrictMode: 	at java.lang.reflect.Method.invoke(Native Method)
03-15 13:54:48.587 29151 29151 D StrictMode: 	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:494)
03-15 13:54:48.587 29151 29151 D StrictMode: 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:964)
03-15 13:54:48.588 29151 29151 D StrictMode: StrictMode policy violation; ~duration=4191 ms: android.os.strictmode.DiskReadViolation
03-15 13:54:48.588 29151 29151 D StrictMode: 	at android.os.StrictMode$AndroidBlockGuardPolicy.onReadFromDisk(StrictMode.java:1504)
03-15 13:54:48.588 29151 29151 D StrictMode: 	at java.io.UnixFileSystem.list(UnixFileSystem.java:302)
03-15 13:54:48.588 29151 29151 D StrictMode: 	at java.io.File.list(File.java:1131)
03-15 13:54:48.588 29151 29151 D StrictMode: 	at android.graphics.Typeface.getFullFlipFont(Typeface.java:1498)
03-15 13:54:48.588 29151 29151 D StrictMode: 	at android.graphics.Typeface.getFontPathFlipFont(Typeface.java:1481)
03-15 13:54:48.588 29151 29151 D StrictMode: 	at android.graphics.Typeface.SetFlipFonts(Typeface.java:1571)
03-15 13:54:48.588 29151 29151 D StrictMode: 	at android.graphics.Typeface.SetAppTypeFace(Typeface.java:1742)
03-15 13:54:48.588 29151 29151 D StrictMode: 	at android.app.Activity.onCreate(Activity.java:1072)
03-15 13:54:48.588 29151 29151 D StrictMode: 	at io.flutter.embedding.android.FlutterActivity.onCreate(FlutterActivity.java:631)
03-15 13:54:48.588 29151 29151 D StrictMode: 	at com.gopuff.godrive2.staging.MainActivity.onCreate(MainActivity.kt:56)
03-15 13:54:48.588 29151 29151 D StrictMode: 	at android.app.Activity.performCreate(Activity.java:7327)
03-15 13:54:48.588 29151 29151 D StrictMode: 	at android.app.Activity.performCreate(Activity.java:7318)
03-15 13:54:48.588 29151 29151 D StrictMode: 	at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1271)
03-15 13:54:48.588 29151 29151 D StrictMode: 	at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3096)
03-15 13:54:48.588 29151 29151 D StrictMode: 	at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3259)
03-15 13:54:48.588 29151 29151 D StrictMode: 	at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)
03-15 13:54:48.588 29151 29151 D StrictMode: 	at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
03-15 13:54:48.588 29151 29151 D StrictMode: 	at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
03-15 13:54:48.588 29151 29151 D StrictMode: 	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1950)
03-15 13:54:48.588 29151 29151 D StrictMode: 	at android.os.Handler.dispatchMessage(Handler.java:106)
03-15 13:54:48.588 29151 29151 D StrictMode: 	at android.os.Looper.loop(Looper.java:214)
03-15 13:54:48.588 29151 29151 D StrictMode: 	at android.app.ActivityThread.main(ActivityThread.java:7073)
03-15 13:54:48.588 29151 29151 D StrictMode: 	at java.lang.reflect.Method.invoke(Native Method)
03-15 13:54:48.588 29151 29151 D StrictMode: 	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:494)
03-15 13:54:48.588 29151 29151 D StrictMode: 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:964)

```

</details>


### Flutter Doctor output

<details open><summary>Doctor output</summary>

```console
[!] Flutter (Channel [user-branch], 3.16.9, on macOS 14.0 23A344 darwin-arm64, locale en-RS)
    ! Flutter version 3.16.9 on channel [user-branch] at /Users/radivojeostojic/Documents/development/flutter
      Currently on an unknown channel. Run `flutter channel` to switch to an official channel.
      If that doesn't fix the issue, reinstall Flutter by following instructions at https://flutter.dev/docs/get-started/install.
    ! Warning: `dart` on your path resolves to /opt/homebrew/Cellar/dart/2.17.6/libexec/bin/dart, which is not inside your current Flutter SDK checkout at
      /Users/radivojeostojic/Documents/development/flutter. Consider adding /Users/radivojeostojic/Documents/development/flutter/bin to the front of your path.
    ! Upstream repository unknown source is not a standard remote.
      Set environment variable "FLUTTER_GIT_URL" to unknown source to dismiss this error.
    • Framework revision 41456452f2 (8 weeks ago), 2024-01-25 10:06:23 -0800
    • Engine revision f40e976bed
    • Dart version 3.2.6
    • DevTools version 2.28.5
    • If those were intentional, you can disregard the above warnings; however it is recommended to use "git" directly to perform update checks and upgrades.

[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.1)
    • Android SDK at /Users/radivojeostojic/Library/Android/sdk
    • Platform android-34, build-tools 33.0.1
    • Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 11.0.15+0-b2043.56-8887301)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 15.3)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 15E204a
    • CocoaPods version 1.12.1

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2022.1)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 11.0.15+0-b2043.56-8887301)

[✓] VS Code (version 1.68.1)
    • VS Code at /Users/radivojeostojic/Downloads/Visual Studio Code.app/Contents
    • Flutter extension version 3.60.0

[✓] Connected device (4 available)
    • SM G955U1 (mobile)         • 988bdc37395638324a                   • android-arm64  • Android 9 (API 28)
    • iPhone 15 Pro Max (mobile) • 9D762A9B-159B-4456-B8E3-99ECD5B453D0 • ios            • com.apple.CoreSimulator.SimRuntime.iOS-17-2 (simulator)
    • macOS (desktop)            • macos                                • darwin-arm64   • macOS 14.0 23A344 darwin-arm64
    • Chrome (web)               • chrome                               • web-javascript • Google Chrome 122.0.6261.129
    ! Error: Browsing on the local area network for Radivoje’s iPhone. Ensure the device is unlocked and attached with a cable or associated with the same local area
      network as this Mac.
      The device must be opted into Developer Mode to connect wirelessly. (code -27)

[✓] Network resources
    • All expected network resources are available.

! Doctor found issues in 1 category.
```

</details>