Skip to content

Commit c902412

Browse files
committed
fix(main): gate frame deferral to Android-only and await Crashlytics setup
- Wrap deferFirstFrame/allowFirstFrame in a `deferFrame` flag so the delay applies only on Android, where the Impeller Vulkan format-0x38 probe race exists. iOS/web/desktop are unaffected and no longer incur the deferred-frame path. - Add missing `await` before setCrashlyticsCollectionEnabled so it completes before deleteUnsentReports is called.
1 parent f1a4039 commit c902412

1 file changed

Lines changed: 12 additions & 9 deletions

File tree

lib/main.dart

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,20 +27,23 @@ void main() {
2727
runZonedGuarded(
2828
() async {
2929
final binding = WidgetsFlutterBinding.ensureInitialized();
30-
// Defer the first frame until after async initialization completes.
31-
// This reduces the risk of a one-frame splash freeze on devices with
32-
// non-standard Gralloc HALs (e.g. Xiaomi/MediaTek) where the Impeller
33-
// Vulkan capability probe fails and falls back — a process that competes
34-
// with the first vsync signal. Holding the first frame gives the raster
35-
// thread time to finish the probe and swapchain fallback before any
30+
// Defer the first frame on Android only. On Android, the Impeller Vulkan
31+
// backend probes pixel format 0x38 during engine startup; on devices with
32+
// non-standard Gralloc HALs (e.g. Xiaomi/MediaTek) the probe fails and
33+
// Impeller falls back to a compatible format on the raster thread. That
34+
// fallback races with the first vsync signal and can cause a one-frame
35+
// freeze on the splash screen. Holding the first frame until async
36+
// bootstrap completes gives the raster thread time to finish before any
3637
// frame is submitted for rasterization.
37-
binding.deferFirstFrame();
38+
// iOS/web/desktop are not affected by this probe issue.
39+
final deferFrame = !kIsWeb && defaultTargetPlatform == TargetPlatform.android;
40+
if (deferFrame) binding.deferFirstFrame();
3841

3942
try {
4043
final instanceRegistry = await bootstrap();
4144

4245
if (!kIsWeb && kDebugMode) {
43-
FirebaseCrashlytics.instance.setCrashlyticsCollectionEnabled(false);
46+
await FirebaseCrashlytics.instance.setCrashlyticsCollectionEnabled(false);
4447
await FirebaseCrashlytics.instance.deleteUnsentReports();
4548
}
4649

@@ -55,7 +58,7 @@ void main() {
5558

5659
runApp(RootApp(instanceRegistry: instanceRegistry));
5760
} finally {
58-
binding.allowFirstFrame();
61+
if (deferFrame) binding.allowFirstFrame();
5962
}
6063
},
6164
(error, stackTrace) {

0 commit comments

Comments
 (0)