Flutter iOS crash on cold start - EXC_BAD_ACCESS Stack overflow in UIKit view hierarchy

I'm experiencing intermittent crashes on iOS when launching a Flutter app after it was killed from the app switcher. The app works fine when resumed from background.

Environment:

  • Flutter 3.38.3

Crash signature:

EXC_BAD_ACCESS (SIGBUS) Stack overflow in (null) compare:options:range:locale: >

Thread 0: CFStringGetLength → CFStringCompareWithOptionsAndLocale → UIKitCore ( 85+ inlined recursive calls)

What I've tried:

  • Increased stack size to 64MB (-Wl,-stack_size,0x4000000) - didn't help
  • Disabled iOS State Restoration - didn't help
  • Added snapshot overlay in applicationWillResignActive - helped for background issue, but not cold start

Key observation: The crash happens intermittently. Sometimes the app opens on 2nd attempt, sometimes on 5th. This suggests a race condition between Flutter engine initialization and iOS view hierarchy traversal.

Question: Is there a way to delay iOS view hierarchy operations until Flutter is fully initialized?

Any help appreciated!

Flutter iOS crash on cold start - EXC_BAD_ACCESS Stack overflow in UIKit view hierarchy
 
 
Q